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

Commit 97e8254

Browse files
author
Łukasz Florczak
committed
Short remove event listeners
1 parent 600acbb commit 97e8254

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/Agile.vue

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,9 @@
158158
beforeDestroy () {
159159
window.removeEventListener('resize', this.getWidth)
160160
161-
if ('ontouchstart' in window) {
162-
this.$refs.track.removeEventListener('touchstart', this.handleMouseDown)
163-
this.$refs.track.removeEventListener('touchend', this.handleMouseUp)
164-
this.$refs.track.removeEventListener('touchmove', this.handleMouseMove)
165-
} else {
166-
this.$refs.track.removeEventListener('mousedown', this.handleMouseDown)
167-
this.$refs.track.removeEventListener('mouseup', this.handleMouseUp)
168-
this.$refs.track.removeEventListener('mousemove', this.handleMouseMove)
169-
}
161+
this.$refs.track.removeEventListener(('ontouchstart' in window) ? 'touchstart' : 'mousedown', this.handleMouseDown)
162+
this.$refs.track.removeEventListener(('ontouchstart' in window) ? 'touchend' : 'mouseup', this.handleMouseUp)
163+
this.$refs.track.removeEventListener(('ontouchstart' in window) ? 'touchmove' : 'mousemove', this.handleMouseMove)
170164
171165
this.disableAutoPlay()
172166
},

0 commit comments

Comments
 (0)