Swiper js duplicated slides - swiper.js

I am facing an issue in swiper js. When it has only 2 slides it duplicates the slides one more time. I don't need loop and when it is 3 and less than 3 i don't need navigation too. I have tried loopDestroy() function, but when i use this it displays blank space after last slide. Here's the code.
var swiperproject = new Swiper(".project-details-swiper", {
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
slidesPerView: 3,
spaceBetween: 30,
slidesPerGroup: 1,
//loop: true,
loopFillGroupWithBlank: true,
});

loop by is nature "duplicate" slides.
You can add your own logic and pass loop true/false related to this logic.
let loop_slider = true;
let num_of_slides = 4;
let num_of_slides_before_init = document.querySelectorAll(".swiper-slide").length;
if(num_of_slides_before_init < num_of_slides){
loop_slider = false;
}
Snippet example:
let loop_slider = true;
const num_of_slides = 4;
let swiper_sliders = document.querySelectorAll(".swiper");
// forEach method, could be shipped as part of an Object Literal/Module
// for class
for (const this_slider of swiper_sliders){
//work as per usual
let num_of_slides_before_init = this_slider.querySelectorAll(".swiper-slide").length;
if(num_of_slides_before_init < num_of_slides){
loop_slider = false;
}
var swiper = new Swiper(this_slider, {
slidesPerView: 3,
loop: loop_slider,
spaceBetween: 30,
pagination: {
el: ".swiper-pagination",
clickable: true,
},
});
};
html,
body {
position: relative;
height: 100%;
}
body {
background: #eee;
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
font-size: 14px;
color: #000;
margin: 0;
padding: 0;
}
.swiper {
width: 100%;
height: 100%;
}
.swiper-slide {
text-align: center;
font-size: 18px;
background: #fff;
/* Center slide text vertically */
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
.swiper-slide img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
[scroll]{
min-height: 100vh;
background: gray;
}
<link href="https://cdn.jsdelivr.net/npm/swiper#8.4.5/swiper-bundle.min.css" rel="stylesheet"/>
<h1>Loop true (Dynamic)</h1>
<div class="swiper mySwiper">
<div class="swiper-wrapper">
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
<div class="swiper-slide">Slide 4</div>
</div>
<div class="swiper-pagination"></div>
</div>
<br><br>
<h1>Loop false (Dynamic)</h1>
<div class="swiper mySwiper">
<div class="swiper-wrapper">
<div class="swiper-slide">Slide 1</div>
</div>
<div class="swiper-pagination"></div>
</div>
<script src="https://cdn.jsdelivr.net/npm/swiper#8/swiper-bundle.min.js"></script>

Related

How do I add a carousel on Google Sites?

What I'm trying to achieve is to create an eye catching carousel. The one currently used on Google sites isn't to my liking. I used the below code for a logo carousel, but I want only images. I'm new to coding and need help from more experienced coders who know exactly what to do and why? I want to understand what I'm doing. I will appreciate all the help I can receive on this issue. Thank you in advance.
<div class=”container”>
<!--<h2> Our Partners/ Our Clients</h2> →
<section class=”customer-logos slider”>
<div class=”slide”><img src=”link”</div>
<div class=”slide”><img src=”link”</div>
<div class=”slide”><img src=”link”</div>
<div class=”slide”><img src=”link”</div>
<div class=”slide”><img src=”link”</div>
<div class=”slide”><img src=”link”</div>
<div class=”slide”><img src=”link”</div>
<div class=”slide”><img src=”link”</div>
<div class=”slide”><img src=”link”</div>
<div class=”slide”><img src=”link”</div>
</section>
</div>
<script>
$ (document) .ready(function){
$ (‘ .customer-logos’) .slick ({
slicktoshow: 4;
slidestoscroll: 1;
autoplay: true;
autoplayspeed: 1500;
arrows: false;
dots: false;
pauseonhover: false;
responsive: [{
Breakpoint: 768;
settings: {
slidestoshow: 4;
}
}]
}];
}];
</script>
<!DOCTYPE html>
<html>
<head>
<link href:”//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/boostrap.min.css” rel=”stylesheet” id=”bootstrap-css>
<script src=”//madcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootsrap.min.js”</script>
<script src=”//cdnjs.cloudfare.com/ajax/libs/jquery/3.2.1/jquery.min.js”></script>
<script src=”https://cdnjs.cloudfare.com/ajax/libs/slick-carousel/1.6.0/slick.js”></script>
<style>
body{
overflow: hidden;
}
h2{
text-align: center;
padding: 20px;
}
/ * Slider */
.slick-slider {
}
.slick-slider img{
width: 100%;
}
.slick-slider
{
position: relative;
display: block;
box-sizing: border-box;
-webkit-user-select: none;
-moz-user-select: none;
ms-user-select: none;
user-select: none;
-webkit-touch-callout: none;
-Khtml-user-select: none;
-ms-touch-action: pan-y;
touch-action: pan-y;
-webkit-tap-highlight-color: transparent;
}
.slick-list
{
position: relative;
display: block;
overflow: hidden;
margin: 0;
padding: 0;
}
.slick-list: focus
{
outline:none;
}
.slick-list .dragging
{
cursor: pointer;
cursor: hand;
}
.slick-slider .slick-track,
.slick-slider .slick-list
{
-webkit-transform: translate3d(0,0,0);
-moz-tranform: translate3d(0,0,0);
-ms-transform: translate3d(0,0,0);
-0-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
.slick-track
{
position: relative;
top: 0;
left: 0;
display: block;
}
.slick-track: before;
.slick-track: after;
{
display:table;
content: “”;
}
.slick-track: after
{
clear: both;
}
.slick-loading .slick-track
{
visibility: hidden;
}
.slick-verticial .slick-slide
{
display: none;
height: auto;
border: 1 px solid transparent;
}
.slick-arrow .slick-hidden{
display: none;
}
</style>
</head>
<body>
<div class=”container”>
</body>
</html>

building a overlay fullscreen navbar in vue.js, by toggle navbar height from 0% to 100%

Trying to implement the overlay fullscreen menu with Vue.js, html/css/js is [this solution]https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_overlay2
But stuck with how to toggle div height from 0% to 100%. I did create 2 classes,
'navbar'
'navbar_open'
but I am not sure how to toggle between them in Vue. I could see that once #click triggered, the class="navbar navbar_open"
<div id="myNav" class="navbar navbar_open">
<div class="closebtn">
<i class="fa fa-times"></i>
</div>
<div class="navbar-content">
<a>Home</a><a>Contact</a>
</div>
</div>
below is the App.vue file,
<template>
<div id="app">
<!-- Banner/Header -->
<!-- Hamburger -->
<div id="myNav" class="navbar" :class="{ navbar_open: showNavbar }">
<div class="closebtn" v-on:click="showNavbar = !showNavbar">
<i class="fa fa-times"></i>
</div>
<div class="navbar-content">
<a>Home</a>
<a>Contact</a>
</div>
</div>
<div class="openbtn">
<i class="fa fa-bars" v-on:click="showNavbar = !showNavbar"></i>
</div>
<router-view />
</div>
</template>
<script>
export default {
data() {
return {
showNavbar: false
};
},
methods: {
toggleNavbar() {
this.showNavbar = !showNavbar;
},
setHeightValue(showNavbar) {
const heightValue = this.showNavbar ? '100%' : '0%';
return heightValue;
}
},
created() {
this.setHeightValue();
}
};
</script>
<style>
#import url('https://use.fontawesome.com/releases/v5.9.0/css/all.css');
.navbar_open {
width: 100%;
height: 100%;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.9);
overflow-y: hidden;
transition: 0.5s;
background-color: #2b4c72;
}
.navbar {
width: 100%;
height: 0%;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.9);
overflow-y: hidden;
transition: 0.5s;
background-color: #2b4c72;
}
.navbar-content {
position: relative;
top: 25%;
width: 100%;
text-align: center;
margin-top: 30px;
}
.navbar a {
padding: 8px;
text-decoration: none;
font-size: 36px;
color: #818181;
display: block;
transition: 0.3s;
}
.navbar a:hover,
.navbar a:focus {
color: #f1f1f1;
}
.navbar .closebtn {
position: absolute;
top: 20px;
left: 45px;
font-size: 60px;
color: white;
cursor: pointer;
}
.openbtn {
font-size: 30px;
}
#media screen and (max-height: 450px) {
.navbar {
overflow-y: auto;
}
.navbar a {
font-size: 20px;
}
.navbar .closebtn {
font-size: 40px;
top: 15px;
right: 35px;
}
}
</style>
I see that you have unused method toggleNavbar. You call setHeightValue only when your component is created and then never again (I think you can remove this method). This menu is not 100% height probably because you embedded this component in another container (<div id="app:...) which has smaller height so height: 100% will be 100% height of parent container. Instead of 100% you can use 100vh (vh - is a viewport unit and it will always take 100% viewport height [if 50vh then 50% of total viewport height]). You should also apply only navbar_open but now you are applying bot classes if your navbar is open: navabar navbar_open so you should add this classes conditionally:
:class="{ 'navbar_open': showNavbar, 'navbar': !showNavbar }"
You have also Two different buttons responsible for two different actions:
closebtn -> close navigation
openbtn -> open navigation
So you should create two different methods openNavigation closeNavigation
<div id="app">
<!-- Banner/Header -->
<!-- Hamburger -->
<div id="myNav" :class="{ 'navbar_open': showNavbar, 'navbar': !showNavbar }">
<div class="closebtn" #click="closeNavigation">
<i class="fa fa-times"></i>
</div>
<div class="navbar-content">
<a>Home</a>
<a>Contact</a>
</div>
</div>
<div class="openbtn">
<i class="fa fa-bars" #click="showNavigation"></i>
</div>
<router-view />
</div>
</template>
<script>
export default {
data() {
return {
showNavbar: false
};
},
methods: {
openNavigation() {
this.showNavbar = true;
},
closeNaviagation() {
this.showNavbar = false;
}
}
};
</script>
<style>
...
.navbar_open {
width: 100%;
height: 100vh; // <--- 100vh instead of 100%
position: fixed;
...
</style>

Parent smooth height variation when new child is added [Vue]

I have read vue transitions documentation and is pretty clear how to apply them to the desired elements. But how to make height variations smooth to the parent container (grey) when a new child (green) is added/removed to a flex column? I have tried to animate max-height of the new child from 0, but isn't working. Here is my case:
fiddle: link
code:
HTML
<html>
<body>
<div id="app" class="demo">
<div>
<button v-on:click="on=!on">
toggle
</button>
</div>
<div class="background">
<div class="container">
<transition name="fade-outin" mode="out-in">
<red v-if="on"></red>
<blue v-else></blue>
</transition>
<transition name="fade-down">
<div v-if="!on">
<div style="height: 25px"></div>
<green></green>
</div>
</transition>
</div>
</div>
</div>
</body>
</html>
JS
var red = {
template: "<div style='width:150px; height:150px; border:10px solid red;'></div>"
};
var blue = {
template: "<div style='width:150px; height:150px; border:10px solid blue;'></div>"
};
var green = {
template: "<div style='width:150px; height:150px; border:10px solid green;'></div>"
};
var app = new Vue({
el: '#app',
data: {
on: true
},
components: {
red,
blue,
green
}
})
CSS
body {
padding: 20px;
}
.background {
border: 1px solid #000;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
width: 100%;
height: 500px;
overflow: hidden;
}
.container {
background-color: #abc;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 20px;
}
.fade-outin-enter-active, .fade-outin-leave-active {
transition: opacity 0.5s ease-in-out;
}
.fade-outin-enter, .fade-outin-leave-to {
opacity: 0;
}
.fade-down-enter-active {
transition: all 0.5s ease-in-out 0.5s;
}
.fade-down-leave-active {
transition: all 0.5s ease-in-out;
}
.fade-down-enter, .fade-down-leave-to {
max-height: 0;
opacity: 0;
transform: translateY(-65px);
}
Thanks for your time,
H25E
You can't use transition with height: auto, the CSS need a value to apply the transitions.
In this case, you must to use the max-height for animate your component. See this article for more details: https://dev.to/sarah_chima/using-css-transitions-on-the-height-property-al0
I do some changes in your code. Try something like this, but you can improve:
<html>
<body>
<div id="app" class="demo">
<div>
<button v-on:click="toggle">
toggle
</button>
</div>
<div class="background">
<div class="container" ref="container">
<transition name="fade-outin" mode="out-in">
<red v-if="on"></red>
<blue v-else></blue>
</transition>
<transition name="fade-down">
<div v-if="!on">
<div style="height: 25px"></div>
<green></green>
</div>
</transition>
</div>
</div>
</div>
</body>
</html>
var red = {
template: "<div style='width:150px; height:150px; border:10px solid red;'></div>"
};
var blue = {
template: "<div style='width:150px; height:150px; border:10px solid blue;'></div>"
};
var green = {
template: "<div style='width:150px; height:150px; border:10px solid green;'></div>"
};
var app = new Vue({
el: '#app',
data: {
on: true
},
components: {
red,
blue,
green
},
methods: {
toggle() {
if (this.on) {
this.$refs.container.style['max-height'] = '500px';
} else {
this.$refs.container.style['max-height'] = '170px';
}
this.on = !this.on;
}
}
})
.container {
background-color: #abc;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 20px;
max-height: 170px;
transition: max-height 3s;
}

How to use copy to clipboard.js to dynamically target button to copy next textarea? (Multiple textarea on one page)

So, I have created one HTML page with several textarea and copy to clipboard buttons. I can't seem to get it to work without giving each textarea a unique ID...
I have looked all around, and tried to intigrate select all query, but still no go.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.10/clipboard.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/primer-tooltips#2.0.0/build/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/tooltipster#4.2.6/dist/js/tooltipster.bundle.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tooltipster#4.2.6/dist/css/tooltipster.bundle.min.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<style>
body {
background-color: white;
font-family: Arial, Helvetica, sans-serif;
margin: 0;
}
* {box-sizing: border-box;}
.input-container {
display: -ms-flexbox; /* IE10 */
display: flex;
width: 100%;
margin-bottom: 5px;
}
.icon {
padding: 10px;
background: #D5281E;
color: white;
min-width: 10px;
text-align: center;
}
.input-field {
width: 100%;
padding: 5px;
outline: none;
}
.input-field:focus {
border: 2px solid #D5281E;
}
.header {
background-color: #ffffff;
padding: 30px;
text-align: center;
}
#navbar {
margin: auto;
overflow: hidden;
background-color: #D5281E;
}
#navbar a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
#navbar a:hover {
background-color: #D5281E;
color: black;
}
#navbar a.active {
background-color: #4CAF50;
color: white;
}
.content {
padding: 16px;
}
.sticky {
position: fixed;
top: 0;
width: 100%;
}
.sticky + .content {
padding-top: 60px;
}
.logo {
text-align: center;
}
.main {
padding: 16px;
margin-top: 30px;
height: 1500px; /* Used in this example to enable scrolling */
}
/* End Fixed Top Menu */
/* Create two equal columns that floats next to each other */
.column {
float: left;
width: 50%;
padding: 10px;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 600px) {
.column {
width: 100%;
}
}
/* Begin Button to top of page */
#myBtn {
display: none; /* Hidden by default */
position: fixed; /* Fixed/sticky position */
bottom: 20px; /* Place the button at the bottom of the page */
right: 30px; /* Place the button 30px from the right */
z-index: 99; /* Make sure it does not overlap */
border: none; /* Remove borders */
outline: none; /* Remove outline */
background-color: #D5281E; /* Set a background color */
color: white; /* Text color */
cursor: pointer; /* Add a mouse pointer on hover */
padding: 15px; /* Some padding */
border-radius: 10px; /* Rounded corners */
font-size: 18px; /* Increase font size */
}
#myBtn:hover {
background-color: #F51509; /* Add a dark-grey background on hover */
}
/* End Button to top of page */
</style>
</head>
<body>
<div class="row"><div class="column"><strong> Preview:</strong>
HYPERLINK
<span class="input-container" style="max-width:500px;margin:auto"><button class="btn btn-primary" data-clipboard-action="copy" data-clipboard-target="#comment"><i class="fa fa-copy"></i></button>
<textarea class="input-field js-copytextarea" readonly="readonly" id="comment" onclick="this.focus();this.select()">
HYPERLINK
</textarea></span></div>
<div class="column"><strong> Preview:</strong>
HYPERLINK2
<span class="input-container" style="max-width:500px;margin:auto"><button class="btn btn-primary" data-clipboard-action="copy" data-clipboard-target="#comment2"><i class="fa fa-copy"></i></button>
<textarea class="input-field js-copytextarea" readonly="readonly" id="comment2" onclick="this.focus();this.select()">
HYPERLINK 2
</textarea></span></div></div>
<div class="row"><div class="column"><strong> Preview:</strong>
HYPERLINK 3
<span class="input-container" style="max-width:500px;margin:auto"><button class="btn btn-primary" data-clipboard-action="copy" data-clipboard-target="#comment3"><i class="fa fa-copy"></i></button>
<textarea class="input-field js-copytextarea" readonly="readonly" id="comment3" onclick="this.focus();this.select()">
HYPERLINK 3
</textarea></span></div>
<div class="column"><strong> Preview:</strong>
HYPERLINK 4
<span class="input-container" style="max-width:500px;margin:auto"><button class="btn btn-primary" data-clipboard-action="copy" data-clipboard-target="#comment4"><i class="fa fa-copy"></i></button>
<textarea class="input-field js-copytextarea" readonly="readonly" id="comment4" onclick="this.focus();this.select()">
HYPERLINK 4
</textarea></span></div></div>
<script>
// Tooltip
$('button').tooltip({
title: "Click to Copy",
trigger: "hover",
delay: {show: 100, hide: 500},
animation: true,
placement: 'right'
});
$('button').tooltip({
trigger: 'click',
animation: true,
placement: 'right'
});
function setTooltip(btn, message) {
$(btn).tooltip('hide')
.attr('data-original-title', message)
.tooltip('show');
}
function hideTooltip(btn) {
setTimeout(function() {
$(btn).tooltip('hide');
}, 1000);
}
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
// Clipboard
var clipboard = new Clipboard('button');
clipboard.on('success', function(e) {
setTooltip(e.trigger, 'Copied!');
hideTooltip(e.trigger);
});
clipboard.on('error', function(e) {
setTooltip(e.trigger, 'Failed!');
hideTooltip(e.trigger);
});
</script>
</body>
</html>
I would like to be able to remove the target ID from the page because I have over a hundred or more textarea's and trying to avoid having to add unique ID and target to each one.
So, I have over 400 textarea fields and copy buttons for each field on one page. Currently, using clipboard.js, all the textarea fields have the same id="comment", and each textarea has a button with data-clipboard-target="#comment" to target the textarea to copy. I would like to be able to not have to ID each textarea and data-clipboard-target each button.
Unless there is an easy way to give each textarea a unique id="comment" and button for that field the same data-clipboard-target?
Imagine having over 400 of the below, and having to change each one.

vue.js, vuetify scroll event not firing when using css scroll snap

UPDATE dropped this approach and went with vue-awesome-swiper script
I"m been stuck on this for days. Basically I want to use css scroll snap and I want to monitor scroll also.
In this basic example with just javascript it works fine scroll event fires and div snaps with css. The other pen below with vue.js does not and that is my problem. Losing hair about this... any help appreciated!
https://codepen.io/travis-pancakes/pen/pGYOZK?editors=0011
var i = 0;
function Onscrollfnction(event) { document.getElementById("demo").innerHTML = i;
i = i + 1;
};
/* setup */
html, body, .holster {
height: 100%;
}
.holster {
display: flex;
align-items: center;
justify-content: space-between;
flex-flow: column nowrap;
font-family: monospace;
}
.container {
display: flex;
overflow: auto;
outline: 1px dashed lightgray;
flex: none;
}
.container.x {
width: 100%;
height: 128px;
flex-flow: row nowrap;
}
.container.y {
width: 256px;
height: 256px;
flex-flow: column nowrap;
}
/* scroll-snap */
.x.mandatory-scroll-snapping {
scroll-snap-type: x mandatory;
}
.y.mandatory-scroll-snapping {
scroll-snap-type: y mandatory;
}
.x.proximity-scroll-snapping {
scroll-snap-type: x proximity;
}
.y.proximity-scroll-snapping {
scroll-snap-type: y proximity;
}
.container > div {
text-align: center;
scroll-snap-align: center;
flex: none;
}
.x.container > div {
line-height: 128px;
font-size: 64px;
width: 100%;
height: 128px;
}
.y.container > div {
line-height: 256px;
font-size: 128px;
width: 256px;
height: 256px;
}
/* appearance fixes */
.y.container > div:first-child {
line-height: 1.3;
font-size: 64px;
}
/* coloration */
.container > div:nth-child(even) {
background-color: #87EA87;
}
.container > div:nth-child(odd) {
background-color: #87CCEA;
}
<div><p>Scrolled <span id="demo">0</span> times.</p></div>
<div class="container y mandatory-scroll-snapping" onscroll="Onscrollfnction();" dir="ltr">
<div>Y Mand. LTR</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
The vue.js, vuetify version does not
https://codepen.io/travis-pancakes/pen/BMbqPq?editors=1111
new Vue({
el: '#app',
data: function(){
return {
i: 0
}
},
created () {
},
methods: {
Onscrollfnction (event) {
document.getElementById("demo").innerHTML = this.i;
this.i = this.i + 1;
console.log('i ', i)
}
}
});
/* setup */
html, body, .holster {
height: 100%;
}
.holster {
display: flex;
align-items: center;
justify-content: space-between;
flex-flow: column nowrap;
font-family: monospace;
}
.container {
display: flex;
overflow: auto;
outline: 1px dashed lightgray;
flex: none;
}
.container.x {
width: 100%;
height: 128px;
flex-flow: row nowrap;
}
.container.y {
width: 256px;
height: 256px;
flex-flow: column nowrap;
}
/* scroll-snap */
.x.mandatory-scroll-snapping {
scroll-snap-type: x mandatory;
}
.y.mandatory-scroll-snapping {
scroll-snap-type: y mandatory;
}
.x.proximity-scroll-snapping {
scroll-snap-type: x proximity;
}
.y.proximity-scroll-snapping {
scroll-snap-type: y proximity;
}
.container > div {
text-align: center;
scroll-snap-align: center;
flex: none;
}
.x.container > div {
line-height: 128px;
font-size: 64px;
width: 100%;
height: 128px;
}
.y.container > div {
line-height: 256px;
font-size: 128px;
width: 256px;
height: 256px;
}
/* appearance fixes */
.y.container > div:first-child {
line-height: 1.3;
font-size: 64px;
}
/* coloration */
.container > div:nth-child(even) {
background-color: #87EA87;
}
.container > div:nth-child(odd) {
background-color: #87CCEA;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<!-- could use v-scroll="Onscrollfnction" with vuetify" --->
<div class="container y mandatory-scroll-snapping"
v-on:scroll.native="Onscrollfnction" dir="ltr">
<div>Y Mand. LTR</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
</div>
<p>Scrolled <span id="demo">0</span> times.</p>
</div>
</div>
vue-awesome-swiper does the functionality I'm going for