This repository was archived by the owner on Feb 24, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Handlers methods for mouse/touch events
3
+ */
4
+ const mixin = {
5
+ methods : {
6
+ handleMouseDown ( e ) {
7
+ if ( ! e . touches ) {
8
+ e . preventDefault ( )
9
+ }
10
+ this . mouseDown = true
11
+ this . dragStartX = ( 'ontouchstart' in window ) ? e . touches [ 0 ] . clientX : e . clientX
12
+ this . dragStartY = ( 'ontouchstart' in window ) ? e . touches [ 0 ] . clientY : e . clientY
13
+ } ,
14
+
15
+ handleMouseMove ( e ) {
16
+ let positionX = ( 'ontouchstart' in window ) ? e . touches [ 0 ] . clientX : e . clientX
17
+ let positionY = ( 'ontouchstart' in window ) ? e . touches [ 0 ] . clientY : e . clientY
18
+ let dragDistanceX = Math . abs ( positionX - this . dragStartX )
19
+ let dragDistanceY = Math . abs ( positionY - this . dragStartY )
20
+ if ( dragDistanceX > 3 * dragDistanceY ) {
21
+ this . disableScroll ( )
22
+ this . dragDistance = positionX - this . dragStartX
23
+ }
24
+ } ,
25
+
26
+ handleMouseUp ( ) {
27
+ this . mouseDown = false
28
+ this . enableScroll ( )
29
+ } ,
30
+
31
+ handleMouseOver ( element ) {
32
+ if ( this . settings . autoplay ) {
33
+ if ( ( element === 'dot' && this . settings . pauseOnDotsHover ) || ( element === 'track' && this . settings . pauseOnHover ) ) {
34
+ this . pauseAutoPlay = true
35
+ }
36
+ }
37
+ } ,
38
+
39
+ handleMouseOut ( element ) {
40
+ if ( this . settings . autoplay ) {
41
+ if ( ( element === 'dot' && this . settings . pauseOnDotsHover ) || ( element === 'track' && this . settings . pauseOnHover ) ) {
42
+ this . pauseAutoPlay = false
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ export default mixin
You can’t perform that action at this time.
0 commit comments