File tree 4 files changed +46
-8
lines changed
4 files changed +46
-8
lines changed Original file line number Diff line number Diff line change @@ -2935,6 +2935,7 @@ olx.interaction.ModifyOptions.prototype.wrapX;
2935
2935
2936
2936
/**
2937
2937
* @typedef {{duration: (number|undefined),
2938
+ * timeout: (number|undefined),
2938
2939
* useAnchor: (boolean|undefined)}}
2939
2940
*/
2940
2941
olx . interaction . MouseWheelZoomOptions ;
@@ -2948,6 +2949,14 @@ olx.interaction.MouseWheelZoomOptions;
2948
2949
olx . interaction . MouseWheelZoomOptions . prototype . duration ;
2949
2950
2950
2951
2952
+ /**
2953
+ * Mouse wheel timeout duration in milliseconds. Default is `80`.
2954
+ * @type {number|undefined }
2955
+ * @api
2956
+ */
2957
+ olx . interaction . MouseWheelZoomOptions . prototype . timeout ;
2958
+
2959
+
2951
2960
/**
2952
2961
* Enable zooming using the mouse's location as the anchor. Default is `true`.
2953
2962
* When set to false, zooming in and out will zoom to the center of the screen
Original file line number Diff line number Diff line change @@ -142,12 +142,6 @@ ol.MAX_ATLAS_SIZE = -1;
142
142
ol . MOUSEWHEELZOOM_MAXDELTA = 1 ;
143
143
144
144
145
- /**
146
- * @define {number} Mouse wheel timeout duration.
147
- */
148
- ol . MOUSEWHEELZOOM_TIMEOUT_DURATION = 80 ;
149
-
150
-
151
145
/**
152
146
* @define {number} Maximum width and/or height extent ratio that determines
153
147
* when the overview map should be zoomed out.
Original file line number Diff line number Diff line change @@ -36,6 +36,12 @@ ol.interaction.MouseWheelZoom = function(opt_options) {
36
36
*/
37
37
this . duration_ = options . duration !== undefined ? options . duration : 250 ;
38
38
39
+ /**
40
+ * @private
41
+ * @type {number }
42
+ */
43
+ this . timeout_ = options . timeout !== undefined ? options . timeout : 80 ;
44
+
39
45
/**
40
46
* @private
41
47
* @type {boolean }
@@ -109,8 +115,7 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
109
115
this . startTime_ = Date . now ( ) ;
110
116
}
111
117
112
- var duration = ol . MOUSEWHEELZOOM_TIMEOUT_DURATION ;
113
- var timeLeft = Math . max ( duration - ( Date . now ( ) - this . startTime_ ) , 0 ) ;
118
+ var timeLeft = Math . max ( this . timeout_ - ( Date . now ( ) - this . startTime_ ) , 0 ) ;
114
119
115
120
clearTimeout ( this . timeoutId_ ) ;
116
121
this . timeoutId_ = setTimeout (
Original file line number Diff line number Diff line change @@ -27,6 +27,36 @@ describe('ol.interaction.MouseWheelZoom', function() {
27
27
disposeMap ( map ) ;
28
28
} ) ;
29
29
30
+ describe ( 'timeout duration' , function ( ) {
31
+ var clock ;
32
+ beforeEach ( function ( ) {
33
+ clock = sinon . useFakeTimers ( ) ;
34
+ } ) ;
35
+
36
+ afterEach ( function ( ) {
37
+ clock . restore ( ) ;
38
+ } ) ;
39
+
40
+ it ( 'works with the defaut value' , function ( done ) {
41
+ var spy = sinon . spy ( ol . interaction . Interaction , 'zoomByDelta' ) ;
42
+ var event = new ol . MapBrowserEvent ( 'mousewheel' , map , {
43
+ type : 'mousewheel' ,
44
+ target : map . getViewport ( ) ,
45
+ preventDefault : ol . events . Event . prototype . preventDefault
46
+ } ) ;
47
+ map . handleMapBrowserEvent ( event ) ;
48
+ clock . tick ( 50 ) ;
49
+ // default timeout is 80 ms, not called yet
50
+ expect ( spy . called ) . to . be ( false ) ;
51
+ clock . tick ( 30 ) ;
52
+ expect ( spy . called ) . to . be ( true ) ;
53
+
54
+ ol . interaction . Interaction . zoomByDelta . restore ( ) ;
55
+ done ( ) ;
56
+ } ) ;
57
+
58
+ } ) ;
59
+
30
60
describe ( 'handleEvent()' , function ( ) {
31
61
it ( '[wheel] works on Firefox in DOM_DELTA_PIXEL mode' , function ( done ) {
32
62
var origHasFirefox = ol . has . FIREFOX ;
You can’t perform that action at this time.
0 commit comments