File tree 2 files changed +16
-5
lines changed
2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -108,8 +108,9 @@ var options = {
108
108
hoverDelay: 0 ,
109
109
// An optional number that determines how long to wait before
110
110
// showing the ZoomPane because of a `touchstart` event.
111
- // It's unlikely that you would want to use this option, since
112
- // "tap and hold" is much more intentional than a hover event.
111
+ // Setting this to a reasonable amount will allow users to execute
112
+ // scroll-gestures events on touch-enabled devices with the image as
113
+ // a starting point
113
114
touchDelay: 0 ,
114
115
// If true, a bounding box will show the area currently being previewed
115
116
// during mouse hover
Original file line number Diff line number Diff line change @@ -61,6 +61,16 @@ export default class Trigger {
61
61
event . preventDefault ( ) ;
62
62
}
63
63
64
+ _preventDefaultAllowTouchScroll ( event ) {
65
+ if ( ! this . settings . touchDelay || ! this . _isTouchEvent ( event ) || this . isShowing ) {
66
+ event . preventDefault ( ) ;
67
+ }
68
+ }
69
+
70
+ _isTouchEvent ( event ) {
71
+ return ! ! event . touches ;
72
+ }
73
+
64
74
_bindEvents ( ) {
65
75
this . settings . el . addEventListener ( "mouseenter" , this . _handleEntry , false ) ;
66
76
this . settings . el . addEventListener ( "mouseleave" , this . _hide , false ) ;
@@ -94,7 +104,7 @@ export default class Trigger {
94
104
}
95
105
96
106
_handleEntry ( e ) {
97
- e . preventDefault ( ) ;
107
+ this . _preventDefaultAllowTouchScroll ( e ) ;
98
108
this . _lastMovement = e ;
99
109
100
110
if ( e . type == "mouseenter" && this . settings . hoverDelay ) {
@@ -134,7 +144,7 @@ export default class Trigger {
134
144
135
145
_hide ( e ) {
136
146
if ( e ) {
137
- e . preventDefault ( ) ;
147
+ this . _preventDefaultAllowTouchScroll ( e ) ;
138
148
}
139
149
140
150
this . _lastMovement = null ;
@@ -157,7 +167,7 @@ export default class Trigger {
157
167
158
168
_handleMovement ( e ) {
159
169
if ( e ) {
160
- e . preventDefault ( ) ;
170
+ this . _preventDefaultAllowTouchScroll ( e ) ;
161
171
this . _lastMovement = e ;
162
172
} else if ( this . _lastMovement ) {
163
173
e = this . _lastMovement ;
You can’t perform that action at this time.
0 commit comments