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

Commit 845f8f7

Browse files
authored
Make Vue-Agile Vue 3 compatible
In Vue 3 beforeDestroy is renamed to beforeUnmount. Tested with vue compat build, vue 3 and vue 2.
1 parent 3b0218c commit 845f8f7

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

src/Agile.vue

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,20 +211,31 @@
211211
this.reload()
212212
},
213213
214-
beforeDestroy () {
215-
window.removeEventListener('resize', this.getWidth)
216-
217-
this.$refs.track.removeEventListener('touchstart', this.handleMouseDown)
218-
this.$refs.track.removeEventListener('touchend', this.handleMouseUp)
219-
this.$refs.track.removeEventListener('touchmove', this.handleMouseMove)
220-
this.$refs.track.removeEventListener('mousedown', this.handleMouseDown)
221-
this.$refs.track.removeEventListener('mouseup', this.handleMouseUp)
222-
this.$refs.track.removeEventListener('mousemove', this.handleMouseMove)
214+
// Vue 3
215+
beforeUnmount() {
216+
this.destroy()
217+
},
223218
224-
this.disableAutoPlay()
219+
// Vue 2
220+
beforeDestroy() {
221+
this.destroy()
225222
},
226223
227224
methods: {
225+
226+
destroy(){
227+
window.removeEventListener('resize', this.getWidth)
228+
229+
this.$refs.track.removeEventListener('touchstart', this.handleMouseDown)
230+
this.$refs.track.removeEventListener('touchend', this.handleMouseUp)
231+
this.$refs.track.removeEventListener('touchmove', this.handleMouseMove)
232+
this.$refs.track.removeEventListener('mousedown', this.handleMouseDown)
233+
this.$refs.track.removeEventListener('mouseup', this.handleMouseUp)
234+
this.$refs.track.removeEventListener('mousemove', this.handleMouseMove)
235+
236+
this.disableAutoPlay()
237+
},
238+
228239
// Return current breakpoint
229240
getCurrentBreakpoint () {
230241
return this.currentBreakpoint

0 commit comments

Comments
 (0)