Giter Club home page Giter Club logo

vue-agile's Introduction

vue-agile

A carousel component for Vue.js inspired by Slick.
Powerful, responsive, touch-friendly, with Nuxt.js SSR support, without a jQuery dependency.

Demo & examples

More demos and examples coming soon in vue-agile CodePens collection.


If you like the component remember to star it ⭐️. If you appreciate my work you can also buy me a coffee ☕️ 😉


🔭 If you're looking for Vue 2 version, check legacy/vue-v2 branch.

Installation

npm install vue-agile

or

yarn add vue-agile

Styles

The component is delivered without styles for the appearance of the navigation elements (like dots color and shape, arrows position, etc.). I think most people use their own styles and default styles are completely redundant. If you want, feel free to use styles from CodePen demos.

Importing

Global

// main.js
import { createApp } from 'vue'
import App from './App.vue'
import VueAgile from 'vue-agile'

createApp(App)
  .use(VueAgile)

In component

// YourComponent.vue
import { VueAgile } from 'vue-agile'

export default {
  components: {
    agile: VueAgile
  }
}

Via <script>

<script src="https://unpkg.com/vue-agile"></script>
<link rel="stylesheet" href="https://unpkg.com/vue-agile/dist/VueAgile.css">

Usage

<template>
  <agile>
    <div class="slide">
      <h3>slide 1</h3>
    </div>

    ...

    <div class="slide">
      <h3>slide n</h3>
    </div>
  </agile>
</template>

Every first-level child of <agile> is a new slide. You also can group them inside <template v-slot:default>...</template> tags.

Options / Props

Parameter Type Default Description
asNavFor array [] Set the carousel to be the navigation of other carousels
autoplay boolean false Enable autoplay
autoplaySpeed integer (ms) 3000 Autoplay interval in milliseconds
centerMode boolean false Enable centered view when slidesToShow > 1
changeDelay integer (ms) 0 Insert a delay when switching slides. Useful for fade: true
dots boolean true Enable dot indicators/pagination
fade boolean false Enable fade effect
infinite boolean true Infinite loop sliding
initialSlide integer 0 Index of slide to start on
mobileFirst boolean true Enable mobile first calculation for responsive settings
navButtons boolean true Enable prev/next navigation buttons
options object null All settings as one object
pauseOnDotsHover boolean false Pause autoplay when a dot is hovered
pauseOnHover boolean true Pause autoplay when a slide is hovered
responsive object null Object containing breakpoints and settings objects
rtl boolean false Enable right-to-left mode
slidesToShow integer 1 Number of slides to show
speed integer (ms) 300 Slide animation speed in milliseconds
swipeDistance integer (px) 50 Distance to swipe the next slide
throttleDelay integer (ms) 500 Throttle delay for actions
timing string ease Transition timing function
(linear/ease/ease-in/ease-out/ease-in-out)
unagile boolean false Disable Agile carousel

Example

<agile :dots="false" :infinite="false" :autoplay-speed="5000">...</agile>

Important! If you use props inline, convert props names from camelCase to kebab-case.

Methods

Name Description
getCurrentBreakpoint() Returns current breakpoint (can returns 0 in mobile first for the smallest breakpoint and null for desktop first for the largest)
getCurrentSettings() Returns settings object for current breakpoint – useful for debugging
getCurrentSlide() Returns index of current slide
getInitialSettings() Returns full settings object with all options – useful for debugging
goTo() Navigates to a slide by index
goToNext() Navigates to next slide
goToPrev() Navigate to previous slide
reload() Reload carousel & slides settings, classes and inline styles

Example

<agile ref="carousel">...</agile>

<button @click="$refs.carousel.goToNext()">My custom button</button>

Events

Name Value Description
after-change { currentSlide } Fires after slide change
before-change { currentSlide, nextSlide } Fires before slide change
breakpoint { breakpoint } Fires after breakpoint change

Example

<agile @after-change="showCurrentSlide($event)">...</agile>
showCurrentSlide(event)
{
  console.log(event)
  // Shows for example: { currentSlide: 1 }
}

Responsive

To customize responsiveness, I recommend defining your desired breakpoints and passing settings object with your modification options inside options.

Example

<agile :options="myOptions">...</agile>
data()
{
  return {
    myOptions: {
      navButtons: false,
      responsive: [
        {
          breakpoint: 600,
          settings: {
            dots: false
          }
        },

        {
          breakpoint: 900,
          settings: {
            navButtons: true,
            dots: true,
            infinite: false
          }
        }
      ]
    }
  }
}

How does it work? Mobile first mode is used by default. It means, that navButtons: false option will be used on screens from 0 to 600 px width (+ all default carousel options). On screens from 600 to 900 px dots: false will be added to options from breakpoint before. And on screens over 900 px width navButtons and dots options will be overwritten and infinite: false will be added.

Custom arrows / nav buttons

From version 1.0 the component use slots for custom navigation buttons. It means you can put inside whatever you want – any HTML with text, image, icon etc.

Example

<agile>
... <!-- slides -->

<template slot="prevButton">prev</template>
<template slot="nextButton">next</template>
</agile>

Caption

To display a static caption or such like within the gallery, you can use the caption slot.

Example

<agile @after-change="e => currentSlide = e.currentSlide">
  ... <!-- slides -->

  <template slot="caption">{{ captions[currentSlide] }}</template>
</agile>

<script>
  export default {
    data () {
      return {
        currentSlide: 0,
        captions: [
          'This is slide 1',
          'This is the second slide',
          'This is a third and final slide',
        ]
      }
    }
  }
</script>

asNavFor

This option is useful for example for creating a photo gallery with two related slider – one big with only one slide in view and second for navigation with thumbnails.

Example

<agile ref="main" :fade="true">...</agile>

<agile ref="thumbnails" :as-nav-for="[$refs.main]" :slides-to-show="4" autoplay>...</agile>

Important! If you want to use the autoplay mode use it only in one of the related carousels.

v-if & v-show

If you have slides being dynamically loaded, use v-if to show the carousel after the slides are ready. Using v-if is also recommended in other situations if you want to hide/show the slideshow.

It is also possible to use v-show, but you have to use the reload() method.

Example

<button @click="isActive = !isActive">Toggle carousel</button>

<agile v-if="isActive">...</agile>

Nuxt.js && SSR Support

The component uses browser specific attributes (like window and document). However, you can try to render the first view on server side.

Example

// plugins/vue-agile.js

import Vue from 'vue'
import VueAgile from 'vue-agile'

Vue.use(VueAgile)
// nuxt.config.js

export default {
  plugins: ['~/plugins/vue-agile'],

  build: {
    transpile: ['vue-agile']
  }
}

To use component without SSR use the client-only component:

<client-only placeholder="Loading...">
  <agile>...</agile>
</client-only>

Important! Component rendered on server side has additional CSS class: agile--ssr, so you can use it to add some additional styles or manipulations. For example, I have limited options for setting the first appearance of the slides. By default, the server renders the view and styles, where only the first slide is visible.

.agile--ssr .agile__slides > * {
  overflow: hidden;
  width: 0
}

.agile--ssr .agile__slides > *:first-child {
  width: 100%
}

At this stage slides don't have agile__slide class yet, so I use > * instead of this.

If you would like to connect this with params slidesToShow or initialSlide you have to add some custom styles with nth-child param.

Example for :slidesToShow="2"

.agile--ssr
  .agile__slides
    > *:nth-child(1),
    > *:nth-child(2)
      width: 50%

Example for :initialSlide="1"

(Slides index starts at 0)

.agile--ssr
  .agile__slides
    > *:nth-child(1)
      width: 0

    > *:nth-child(2)
      width: 100%

You can also check nuxt-agile repository and check working demo of vue-agile with Nuxt and SSR.

FAQ

1. Using component with dynamic content

If content changes, you have to use reload or in some cases, you can use key property: <agile :key="mySlides.length">...</agile> (it'll rebuild the carousel after each change of mySlides length).

2. Support for IE11

Yes, the UMD bundle is built with support for IE11. If you build your app with vue-agile as a dependency yourself be sure you configured babel properly (read more in vue documentation or just use my config for babel).

vue-agile's People

Contributors

bcleverly avatar daniellampl avatar davestewart avatar dependabot[bot] avatar fmabid avatar frontendstudio avatar ilkeryilmaz avatar lukas-pierce avatar lukaszflorczak avatar mdunisch avatar mostafakarim avatar nathanbnm avatar nesuarg avatar nvitius avatar ordago avatar pranciskus avatar ryanaarongreen avatar tobiasschuerg avatar veceraj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-agile's Issues

Slick Methods

Are Slick Methods such as slickGoTo, slickAdd, slickRemove supported? Didn't see anything on the demo page in regards to the API for agile

Typescript configuration

For use with Typescript, here is a declaration file vue-agile.d.ts:

declare module 'vue-agile' {
    import Vue, {PluginObject} from 'vue';

    const VueAgile: PluginObject<{}>;
    export default VueAgile;
    export const Agile: Vue;
}

Works in development but not in production or after build?

Works in development during live-reload in NuxtJS but not after you build the project?

Problem: Image becomes stacked upon each other in production whereas the images are inside the carousel.

I run npm run build and run it on a local heroku cli and it shows slides are stacked upon each other.
In development through live reload, it doesn't have any problems of this sort.

Was wondering if there was some sort of production setting I had to turn on for this to work?

Thanks!

Feature - external arrows / bullet pagination

At the moment the arrows are only available inside the slider container .
If someone requires the common overlap of arrows with the borders or external bullet navigation it won't allow it as overflow is hidden.

Can you consider adding a way to add these items outside the container like other libraries ?

When using v-for inside agile everything is returned stacked together.

Hi,
I love the app as its easy to get into but i cant seem to get my v-for code to work.

When i use the code below i get only 1 dot and i cant use the arrows to change the slide.
<agile> <div v-for="book in books"> <h3>{{ book.title }}</h3> </div> </agile>

image

However, when i use v-for on agile aswell as the div. everything works (though i do get 5 of them).
<agile v-for="book in books"> <div v-for="book in books"> <h3>{{ book.title }}</h3> </div> </agile>

image

Now my question is there anyway to do this without looping through on agile and only on the div?

Any help is greatly appreciated. thanks 👍

full code:

<!-- Carousel / Start -->
<div class="simple-fw-slick-carousel dots-nav">
  <agile>
    <div v-for="book in books">
      <h3>{{ book.title }}</h3>
    </div>
  </agile>
</div>
<!-- Carousel / End -->

<script>

  import axios from 'axios'
  import Vue from 'vue'
  import VueAgile from 'vue-agile'

  Vue.use(VueAgile)

  export default {
    name: 'listingItems',
    data: function () {
      return {
        Header: '400+ MicroPulses i din lomme',
        Subheader: 'Hvilken bog bliver den næste du lærer?',
        books: []
      }
    },
    beforeCreate () {
      axios.get('http://localhost:3000/api/book')
        .then((resp) => {
          this.books = resp.data
          console.log(resp)
        })
        .catch((err) => {
          console.log(err)
        })
    },

    watch: {
      '$route': 'fetchData'
    },

    methods: {
      set () {
        console.log('run')
        this.showCarousel = true
      }
    }
  }

</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>

Inconsistant widths

Hi,

I really like this carousel but I am having an issue where upon loading it in the browser it sometimes displays it correctly and sometimes it doesn't and I cannot identify the cause. When correct, the first slide containing just text and the following two image slides are centred perfectly. When incorrect, they do not.

        <div class="row justify-content-center full-height">
            <div class="col-12 col-md-10">

                    <agile :arrows="true" 
                    :speed="1000" 
                    :timing="'linear'" 
                    :fade="true" 
                    :autoplay="false">


                    <div class="slide">
                        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
                    </div>

                    <div class="slide">
                        <img src="{{ asset('storage/images/castellain_sized.jpg') }}" alt="" >
                    </div>

                    <div class="slide">
                        <img src="{{ asset('storage/images/Castellain11.jpg') }}" alt="">
                    </div>

                </agile>
            </div>
        </div>
    </div>

When working correctly, Chrome shows the slide div element style width as 920px, but when incorrect as 1264px. But just reloading will switch between them. Interestingly, flicking on the device toolbar in Chrome tools will always revert it correctly even when reverting back out of device mode.

Also, when incorrect, the div class="agile__slides agile__slides--regular" is showing a width of 3792px but 2760px when correct.

My CSS

.slide {
  align-items: center;
  display: flex;
  justify-content: center;
  text-align: center;
}

.slide  p {
  color: #805649;
  font-size: 16px;
  font-weight: 300;
  margin-right: 5%;
  margin-left: 5%;
  display: flex;
  text-align: center;
  margin: auto;
}


  .slide img {
    width: 100%;
  }

Maybe I doing something incorrectly? Thank you

Image slides not appearing when using v-for

<agile v-if="(images.length > 0)" class="agile-carousel" :arrows="false" :dots="showDots" :infinite="false">
    <div class="slide" v-for="(item, index) in images" :key="index">
        <img :src="item" alt="">
    </div>
</agile>

When I upload new images to the images list, the slider is not getting updated. It is getting stacked on the first page itself.

mouse swipe

When I swipe to the next or previous slide with the mouse, vue-agile gets completely crazy when I move my mouse over the slides (maybe the mouseup has not been trapped).
(v0.3.3 from npm)

prevArrow and nextArrow options being ignored.

I'm new to Vue, so please forgive me if this isn't an issue with vue-agile and I'm just doing it wrong.

I have my markup setup like this:

<agile class="carousel" :prevArrow="leftArrow" :nextArrow="rightArrow" :dots="false" ref="carousel">
    <div class="carousel__slide">
        <img src="/assets/img/temp.png" alt=""/>
    </div>
    <div class="carousel__slide">
        <img src="/assets/img/temp.png" alt=""/>
    </div>
</agile>

And then my Javascript looks like this:

import VueAgile from 'vue-agile';

Vue.use(VueAgile);

new Vue({
    el: '#app',
    data() {
        return {
            menu: false,
            leftArrow: "<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50' viewBox='0 0 50 50'><g fill='none' fill-rule='evenodd'><circle cx='25' cy='25' r='25' fill='#292929' opacity='.6' transform='rotate(-90 25 25)'/><path fill='#FFF' d='M14.2906595,25.7004411 L28.3077323,39.7102545 C28.6952783,40.0965818 29.3226866,40.0965818 29.7092414,39.7102545 C30.0967874,39.321946 30.0967874,38.6949071 29.7092414,38.3085798 L16.3929231,25.0000991 L29.7092414,11.6916183 C30.0967874,11.3043005 30.0967874,10.6782521 29.7092414,10.2899436 C29.3226866,9.90361629 28.6952783,9.90361629 28.3077323,10.2899436 L14.2906595,24.299757 C13.9031135,24.6870749 13.9031135,25.3131232 14.2906595,25.7004411'/></g></svg>",
            rightArrow: "<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50' viewBox='0 0 50 50'><g fill='none' fill-rule='evenodd'><circle cx='25' cy='25' r='25' fill='#292929' opacity='.6' transform='rotate(-90 25 25)'/><path fill='#FFF' d='M14.2906595,25.7004411 L28.3077323,39.7102545 C28.6952783,40.0965818 29.3226866,40.0965818 29.7092414,39.7102545 C30.0967874,39.321946 30.0967874,38.6949071 29.7092414,38.3085798 L16.3929231,25.0000991 L29.7092414,11.6916183 C30.0967874,11.3043005 30.0967874,10.6782521 29.7092414,10.2899436 C29.3226866,9.90361629 28.6952783,9.90361629 28.3077323,10.2899436 L14.2906595,24.299757 C13.9031135,24.6870749 13.9031135,25.3131232 14.2906595,25.7004411'/></g></svg>",
        };
    },
    methods: {
        toggleMenu() {
            this.menu = !this.menu;
        },
    },
});

The leftArrow and rightArrow variables are being picked up from data() as when I view source on the rendered page they are there in the component declaration (see below), but they are being ignored and the two default arrows are what I can see on the page.

<div class="agile carousel" prevarrow="<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50' viewBox='0 0 50 50'>...</svg>" nextarrow="<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50' viewBox='0 0 50 50'>...</svg>">
   <div class="agile__list">
        <div class="agile__track" style="width: 3340px; transform: translate(-668px); transition: transform 0ms ease;">
...

I'm sure I'm just doing something wrong, so any guidance would really help, thanks.

async data in slider

Hi,

I like the slider. It's basic and simple to implement.
But I need the data to be loaded async into the slider.
I have tried beforeCreate() and created() but no luck.

This is my component where I init the slider

Slider.vue

<template>
    <div>
        <h1>New feature slider demo</h1>

        <agile :infinite="false" :arrow="''">
            <div class="slide" v-for="item in items">
                <div class="slider__image">
                    <img :src="item.image">
                </div>
                <div class="slider__body">
                    <h2>{{ item.header }}</h2>
                    <p>{{ item.content }}</p>
                </div>
            </div>
        </agile>

        <a class="skip">Skip</a>
    </div>
</template>

<script>
    export default {
        data: () => ({
            items: '',
        }),

        methods: {

        },

        beforeCreate() {
            this.$http['get']('/demo/slider')
                .then(response => {
                    if(response.status === 200) {
                        let sliderData = response.data;
                        if(sliderData.length > 0) {
                            this.items = sliderData;
                        }
                    }
                }).catch(error => {
                    console.log(response)
                });

        }
    };
</script>

demo.js (here i start the Vue instance)

import Vue from 'vue'
import VueAgile from 'vue-agile'
import Slider from '../../components/demo/Slider'

Vue.use(VueAgile)
new Vue({
    el: '#demo-wrapper',
    components: { Slider }
})

The data gets loaded but the slider does not work and gives this error Error in callback for watcher "width": "TypeError: Cannot read property 'classList' of undefined".

Can you help?

ps. i still learning VueJS so if i name stuff wrong i'm sorry :)

Agile not rendered on Nuxt production build

I would like to use vue-agile for my mobile slider here: https://oye.kolter.it/

Everything is rendered correctly, when I run the dev server, but after npm run build and with npm run start I get the following exceptions and the component is not rendered (search the source code for <agile>).

[nuxt.js] Cannot load components DOMException: Failed to execute 'appendChild' on 'Node': This node type does not support this method.
    at Object.je [as appendChild] (https://oye.kolter.it/_nuxt/vendor.bundle.51428f798a9e09b81298.js:21:19712)
    at f (https://oye.kolter.it/_nuxt/vendor.bundle.51428f798a9e09b81298.js:21:46250)
    at i (https://oye.kolter.it/_nuxt/vendor.bundle.51428f798a9e09b81298.js:21:45535)
    at l (https://oye.kolter.it/_nuxt/vendor.bundle.51428f798a9e09b81298.js:21:46333)
    at x (https://oye.kolter.it/_nuxt/vendor.bundle.51428f798a9e09b81298.js:21:49157)
    at a.__patch__ (https://oye.kolter.it/_nuxt/vendor.bundle.51428f798a9e09b81298.js:21:49728)
    at a.t._update (https://oye.kolter.it/_nuxt/vendor.bundle.51428f798a9e09b81298.js:21:38745)
    at a.r (https://oye.kolter.it/_nuxt/vendor.bundle.51428f798a9e09b81298.js:21:7322)
    at Nr.get (https://oye.kolter.it/_nuxt/vendor.bundle.51428f798a9e09b81298.js:21:35110)
    at new Nr (https://oye.kolter.it/_nuxt/vendor.bundle.51428f798a9e09b81298.js:21:34932)
(anonymous) @ nuxt.bundle.3ebab7d5bbfe02586b27.js:6
vendor.bundle.51428f798a9e09b81298.js:21 TypeError: Cannot read property '$options' of undefined
    at ct (vendor.bundle.51428f798a9e09b81298.js:21)
    at prepatch (vendor.bundle.51428f798a9e09b81298.js:21)
    at b (vendor.bundle.51428f798a9e09b81298.js:21)
    at _ (vendor.bundle.51428f798a9e09b81298.js:21)
    at b (vendor.bundle.51428f798a9e09b81298.js:21)
    at a.__patch__ (vendor.bundle.51428f798a9e09b81298.js:21)
    at a.t._update (vendor.bundle.51428f798a9e09b81298.js:21)
    at a.r (vendor.bundle.51428f798a9e09b81298.js:21)
    at Nr.get (vendor.bundle.51428f798a9e09b81298.js:21)
    at Nr.run (vendor.bundle.51428f798a9e09b81298.js:21)
i @ vendor.bundle.51428f798a9e09b81298.js:21

Pause on hover seems to reset timer?

It seems pauseOnHover doesnt work quite as expected...
I've set the autoplaySpeed to 10 secs, and if I then hover the slider after 5 secs, it should pause, then i mouse out from the slider - After 2 seconds, i hover it again, and then mouse out again..
Then I would expect it to pickup/resume where I left, but it seems like it just restarts the timer, and i have to wait 10 seconds again, when in reality I would expect it to change after ex: 3 seconds, and i did a mouseover after 5 seconds and 2 seconds, so should be 3 seconds left of the interval...

Make this slider SSR compatible

Currently the are many window.addEventListeners in the code, which makes this code not work in a node environment. Maybe they should all be conditioned so that they do not get applied on the server.

Defensive changes we had to make to get 2.8.2 working:

I don't know if this will be useful feedback so feel free to close this issue if not!

The current master branch is not working for us unfortunately -- we are using VueJS, and tiny-slider is not getting torn down precisely when .destroy is called, which is leaving our shadow DOM out of sync with the real DOM and causing problems (at least this is my best diagnosis).

In 2.8.2 everything is pretty much working, with the one exception of controls not having the hidden attribute reset correctly, which is easy enough for us to fix manually. I had to make the following three additional changes to get 2.8.2 working for our purposes (I think these all can get called on timers, and if the elements are destroyed before the timer goes off they throw errors):

Sanity check that el exists in isVisible:

function isVisible(el) {
  return el && el.offsetWidth > 0 && el.offsetHeight > 0;
}

Sanity check that el exists in resetDuration:

function resetDuration (el, str) {
  if (el && RANSITIONDURATION) { el.style[TRANSITIONDURATION] = str; }
}

Sanity check that container exists in doContainerTransform:

function doContainerTransform (val) {
  if (val == null) { val = getContainerTransformValue(); }
  if(container) {
    container.style[transformAttr] = transformPrefix + val + transformPostfix;
  }
}

component parameters

Hi, im using this awesome component but have a little problem. I'm using this componente by vue-agile.min.js downloaded from here. The component works perfectly but if i config a :autoplaySpeed, pauseonHover or other parameter, these parameters its not updated. I dont know if maybe is an issue or im doing something wrong

Thx a lot.

Slides don't render with v-show

It looks like the carousel doesn't render slides correctly if behind a v-show. So:

<template>
  <button 
     v-on:click.prevent="toggleShowCarousel">Click to toggle the carousel</button>
   <div  v-show="showCarousel">
      <agile>
        <div class="slide slide--1"><h3>slide 1</h3></div>
        <div class="slide slide--2"><h3>slide 2</h3></div>
        <div class="slide slide--3"><h3>slide 3</h3></div> 
      </agile>
    </div>
</template>
<script>

export default {
 data() {
  return { showCarousel: false }
 },
methods: {
  toggleShowCarousel() {
      this.showCarousel = !this.showCarousel;
    }
  }
}
</script>

....

I used the styling for the slides as #1 demo. ... has the same behaviour. It seems to work when using a v-if instead of a v-show.

Nuxt.js

Prepare component for as good Nuxt.js support as possible.

Question

Does this component support the following?

  1. Image thumbnails in place of dots.
  2. Clicking image for fullscreen view.

Thanks.

Events & methods

Hi, everyone!

Events

Version 0.4.0 will receive support for events. At this moment I've added two major events:

  • beforeChange
  • afterChange.

The first one returns: {currentSlide: ..., nextSlide: ...} when the slide change is initialized, and the second returns: {currentSlide: ...} after change (animation time is not taken into account).

Methods

I added also methods:

  • goTo(slideNumber)
  • goToNext()
  • goToPrev()
  • getCurrentSlide() – returns integer

Please let me know what other data in events you want to be returned (for example slide change method: autoplay, arrow, dot, swipe) or what other events and methods should I add. Please also explain in few words how the new event, method or returned data could be used – this will make it easier to implement.


PS. You can also check README file from develop branch for more info and examples.

Nuxt 1.0.0-rc11 instructions are wrong

Everything is correct apart from the plugin declaration.

Apparently it only works with

import Vue from 'vue'
import VueAgile from 'vue-agile'

Vue.use(VueAgile)

Standalone version

Hi,

Is it possible to use Vue Agile as a standalone component (i.e. as an external script). I'm using a PHP backend with VUE and Bootstrap VUE as external scripts included in head. Can i do the same with Vue Agile? If that's not the case, do you mind share the unminified version of agile js so I can make it standalone? :-)

Thanks in advance.

Exception on mousedown

When the mouse is used to switch slides by dragging, this error is logged to the console. The carousel still works as expected, though.

[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See <URL>

image

vue-agile: 0.3.7
Google Chrome: Version 68.0.3440.106 (Official Build) (64-bit)

error in beforeDestroy hook

[Vue warn]: Error in beforeDestroy hook: "TypeError: Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only 1 present."

found in
---> <Agile> at ..\..\webapp-test\node_modules\vue-agile\src\Agile.vue

All slides in the same carousel - nuxt.js

I am trying to use vue-agile with nuxt.js however, all of my items are visible on the first slide. here is my code.

<template>
  <div class="container">
    <MenuNavigator />
    <div class="about-flex">
      <no-ssr placeholder="Loading...">
        <agile :prevArrow="left" :nextArrow="right" :options='agileOptions'>
           <div class="slide slide--1"><h3>slide 1</h3></div>
            <div class="slide slide--2"><h3>slide 2</h3></div>
            <div class="slide slide--3"><h3>slide 3</h3></div>
            <div class="slide slide--4"><h3>slide 4</h3></div>
            <div class="slide slide--5"><h3>slide 5</h3></div>
            <div class="slide slide--6"><h3>slide 6</h3></div>
        </agile>
      </no-ssr>
      <div class="img-container">
        <img class="img" src="../static/boo.svg">
      </div>
      </div>
    </div>
  </div>
</template>

Feature: events

It would be good to have some events emitted from the carousel, e.g. a 'slide-changed' event could be emitted with the value of the current slide as

this.$emit('slide-changed', this.currentSlide)

0.4.0 alpha: Styles / Slider broken under Samsung Browser (Android 7 & 8)

Hi,

the "official" 0.3.7 release of the vue agile slider works just fine in the Samsung Browser under Android 7 and 8.

But since 0.4.0 (alpha), it seems to be broken. The slider is completly messed up and has no styling anymore.

Which is bad, I really need the latest methods and events :-D

issue with autoplay

Hi,
I noticed that autoplay is not stopped when the component is destroyed. This may lead to some invalid DOM access ( startAutoplay() -> setTimeout() -> nextSlide() -> setSlide() -> this.el.slides[i] may be null).

Responsive breakpoints & settings

Hi everyone!

I just published 0.3.0-alpha.1 version with support for options (all settings in one object), responsive and mobileFirst attributes.

You can find descriptions of available options and responsive example here.

Because responsive support is a very important step for further functionality (like slidesToShow etc.) It would be great if someone would like to test it out and share a feedback.


To install dev version use a command:

yarn add vue-agile@dev

server-side rendering support

It seems that vue-agile is not compatible with SSR.

When the server is rendering the page, I get the following error:

ReferenceError: window is not defined
    at ...\node_modules\vue-agile\dist\vue-agile.min.js:1:1

v-for reInit issue with vue-slick

Hello I am considering using vue-agile instead of vue-slick. I had issues with using v-for to create subcomponents within a Slick component. They were rendered outside of the slick track.

Would I run into this issue? Any thoughts on comparisons between these two vue carousel libraries?

The following is a reference to the problem I'm describing staskjs/vue-slick#26

Thanks!

Can't write in input

Hello,

I'm trying to insert an input into a slide of the carousel.
The input is displayed, but I can't write into it.
I search in css, i didn't find anything !

Slider sesitivity on mobile devices.

It would be great if you could make it less sensitive on mobile devices. At this point it's easy to change slides by mistake. For example, when you're scrolling a page and touch slider area it's almost sure that it will move.
The solution may be to increase number of pixels you need to move to change slide.

Except that it works great.
Thanks for this wonderful component!

Using v-for to populate slides?

Is it possible to use a v-for loop on the slide div to dynamically control the number of slides?
Something similar to this?
<agile :infinite='false'> <div v-for="each_item in list" class="slide slide--1" v-bind:style="{ backgroundImage: each_item.path }"></div> </agile>

Help in checking Readme file

Hi everyone!

Because English is not my native language I will be very grateful for any help with vue-agile documentation. If you are an English native speaker or you know English very well, please take a moment to review the Readme file in dev branch. If you find a typo or any langauge mistake do a commit and a pull request or just write me about it here please.

Thank you very much in advance!

Feature - Customizable arrows

I'd like to put my svg instead of the hardcoded one in the component.

Is there a hacky way to do it for now and would you consider this feature?

Buttons type

Hi,

I think you should add type="button" to

In my case it's treated like submit button and everytime it fires form. It's not that big of an issue for me, but in some cases it could be.

Cheers

Throttle

Throttle function for goTo() method

Can't handle empty passed template

Similar to: #25

The recommendation is to use v-if and v-show to hide the component until the inner content is loaded. If this isn't used in an example like the following and items is loaded asynchronously (or is undefined until loaded):

<agile>
    <div v-for="item in items">
        <img :src="item.src">
    </div>
</agile>

...then the following (similar) error is given:

screen shot 2018-03-13 at 11 30 16 am

It would be much nicer to not require this v-if in <agile> as it's one more thing to add and remember. If vue-agile can handle this, why not include it as default functionality. v-for already acts this way as passing v-for an undefined items will create no error and no iterations, which is nice, though maybe not expected until fully familiar with Vue. But if Vue is doing it, wouldn't it make more sense to align with the expectations of their ecosystem? Just not sure if it's possible.

Add events

Hi,

Could you add the ability to emit some events? I need to detect when the user move between slides and get the slide number.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.