Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Commit faa1984

Browse files
authored
Merge pull request #238 from rDr4g0n/feature/vue-events
Bind swiper events to vuejs events
2 parents f9ec14f + a841809 commit faa1984

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

dist/vue-awesome-swiper.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/swiper.vue

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,36 @@
4040
configurable: true
4141
})
4242
}
43+
// as of swiper 4.0.7
44+
// http://idangero.us/swiper/api/#events
45+
const DEFAULT_EVENTS = [
46+
'beforeDestroy',
47+
'slideChange',
48+
'slideChangeTransitionStart',
49+
'slideChangeTransitionEnd',
50+
'slideNextTransitionStart',
51+
'slideNextTransitionEnd',
52+
'slidePrevTransitionStart',
53+
'slidePrevTransitionEnd',
54+
'transitionStart',
55+
'transitionEnd',
56+
'touchStart',
57+
'touchMove',
58+
'touchMoveOpposite',
59+
'sliderMove',
60+
'touchEnd',
61+
'click',
62+
'tap',
63+
'doubleTap',
64+
'imagesReady',
65+
'progress',
66+
'reachBeginning',
67+
'reachEnd',
68+
'fromEdge',
69+
'setTranslate',
70+
'setTransition',
71+
'resize'
72+
]
4373
4474
// export
4575
export default {
@@ -64,6 +94,16 @@
6494
mountInstance() {
6595
const swiperOptions = Object.assign({}, this.globalOptions, this.options)
6696
this.swiper = new Swiper(this.$el, swiperOptions)
97+
this.bindEvents()
98+
},
99+
bindEvents() {
100+
const vm = this
101+
DEFAULT_EVENTS.forEach(eventName => {
102+
this.swiper.on(eventName, function() {
103+
// NOTE - `this` is the swiper instance
104+
vm.$emit(eventName, this, ...arguments)
105+
})
106+
})
67107
}
68108
},
69109
data() {

0 commit comments

Comments
 (0)