@progress/kendo-charts 1.22.0 → 1.23.0-dev.202201170838
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/NOTICE.txt +119 -79
- package/dist/cdn/js/kendo-charts.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/common/keys.js +25 -0
- package/dist/es/common.js +1 -0
- package/dist/es/drawing-utils.js +27 -3
- package/dist/es/main.js +1 -0
- package/dist/es/map/attribution.js +158 -0
- package/dist/es/map/crs.js +277 -0
- package/dist/es/map/datums.js +16 -0
- package/dist/es/map/extent.js +129 -0
- package/dist/es/map/layers/bubble.js +185 -0
- package/dist/es/map/layers/layer.js +140 -0
- package/dist/es/map/layers/marker.js +347 -0
- package/dist/es/map/layers/shape.js +389 -0
- package/dist/es/map/layers/tile.js +491 -0
- package/dist/es/map/location.js +201 -0
- package/dist/es/map/map.js +945 -0
- package/dist/es/map/navigator.js +175 -0
- package/dist/es/map/scroller/draggable.js +454 -0
- package/dist/es/map/scroller/fx.js +119 -0
- package/dist/es/map/scroller/observable.js +175 -0
- package/dist/es/map/scroller/scroller.js +746 -0
- package/dist/es/map/scroller/user-events.js +713 -0
- package/dist/es/map/utils.js +450 -0
- package/dist/es/map/zoom.js +139 -0
- package/dist/es/map.js +1 -0
- package/dist/es/services/map-service.js +15 -0
- package/dist/es2015/common/keys.js +25 -0
- package/dist/es2015/common.js +1 -0
- package/dist/es2015/drawing-utils.js +43 -3
- package/dist/es2015/main.js +1 -0
- package/dist/es2015/map/attribution.js +148 -0
- package/dist/es2015/map/crs.js +233 -0
- package/dist/es2015/map/datums.js +16 -0
- package/dist/es2015/map/extent.js +115 -0
- package/dist/es2015/map/layers/bubble.js +167 -0
- package/dist/es2015/map/layers/layer.js +134 -0
- package/dist/es2015/map/layers/marker.js +327 -0
- package/dist/es2015/map/layers/shape.js +369 -0
- package/dist/es2015/map/layers/tile.js +465 -0
- package/dist/es2015/map/location.js +193 -0
- package/dist/es2015/map/map.js +915 -0
- package/dist/es2015/map/navigator.js +170 -0
- package/dist/es2015/map/scroller/draggable.js +418 -0
- package/dist/es2015/map/scroller/fx.js +112 -0
- package/dist/es2015/map/scroller/observable.js +165 -0
- package/dist/es2015/map/scroller/scroller.js +716 -0
- package/dist/es2015/map/scroller/user-events.js +695 -0
- package/dist/es2015/map/utils.js +450 -0
- package/dist/es2015/map/zoom.js +134 -0
- package/dist/es2015/map.js +1 -0
- package/dist/es2015/services/map-service.js +15 -0
- package/dist/npm/main.d.ts +1 -0
- package/dist/npm/main.js +6218 -342
- package/dist/npm/map.d.ts +4 -0
- package/dist/systemjs/kendo-charts.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,713 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Class,
|
|
3
|
+
grep
|
|
4
|
+
} from '../../common';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
proxy,
|
|
8
|
+
noop,
|
|
9
|
+
applyEventMap,
|
|
10
|
+
getEventMap,
|
|
11
|
+
on,
|
|
12
|
+
off,
|
|
13
|
+
now,
|
|
14
|
+
getSupportedFeatures
|
|
15
|
+
} from '../utils';
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
Observable
|
|
19
|
+
} from './observable';
|
|
20
|
+
|
|
21
|
+
var extend = Object.assign;
|
|
22
|
+
|
|
23
|
+
var preventDefault = function (e) {
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
var
|
|
28
|
+
DEFAULT_MIN_HOLD = 800,
|
|
29
|
+
CLICK_DELAY = 300,
|
|
30
|
+
// DEFAULT_THRESHOLD = support.browser.msie ? 5 : 0,
|
|
31
|
+
DEFAULT_THRESHOLD = 0,
|
|
32
|
+
PRESS = 'press',
|
|
33
|
+
HOLD = 'hold',
|
|
34
|
+
SELECT = 'select',
|
|
35
|
+
START = 'start',
|
|
36
|
+
MOVE = 'move',
|
|
37
|
+
END = 'end',
|
|
38
|
+
CANCEL = 'cancel',
|
|
39
|
+
TAP = 'tap',
|
|
40
|
+
DOUBLETAP = 'doubleTap',
|
|
41
|
+
RELEASE = 'release',
|
|
42
|
+
GESTURESTART = 'gesturestart',
|
|
43
|
+
GESTURECHANGE = 'gesturechange',
|
|
44
|
+
GESTUREEND = 'gestureend',
|
|
45
|
+
GESTURETAP = 'gesturetap';
|
|
46
|
+
|
|
47
|
+
var THRESHOLD = {
|
|
48
|
+
'api': 0,
|
|
49
|
+
'touch': 0,
|
|
50
|
+
'mouse': 9,
|
|
51
|
+
'pointer': 9
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
function touchDelta(touch1, touch2) {
|
|
55
|
+
var x1 = touch1.x.location,
|
|
56
|
+
y1 = touch1.y.location,
|
|
57
|
+
x2 = touch2.x.location,
|
|
58
|
+
y2 = touch2.y.location,
|
|
59
|
+
dx = x1 - x2,
|
|
60
|
+
dy = y1 - y2;
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
center: {
|
|
64
|
+
x: (x1 + x2) / 2,
|
|
65
|
+
y: (y1 + y2) / 2
|
|
66
|
+
},
|
|
67
|
+
distance: Math.sqrt(dx * dx + dy * dy)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function getTouches(e) {
|
|
72
|
+
var support = getSupportedFeatures();
|
|
73
|
+
var touches = [],
|
|
74
|
+
originalEvent = e.originalEvent || e,
|
|
75
|
+
currentTarget = e.currentTarget,
|
|
76
|
+
idx = 0,
|
|
77
|
+
length, changedTouches, touch;
|
|
78
|
+
|
|
79
|
+
if (e.api) {
|
|
80
|
+
touches.push({
|
|
81
|
+
id: 2,
|
|
82
|
+
event: e,
|
|
83
|
+
target: e.target,
|
|
84
|
+
currentTarget: e.target,
|
|
85
|
+
location: e,
|
|
86
|
+
type: 'api'
|
|
87
|
+
});
|
|
88
|
+
} else if (e.type.match(/touch/)) {
|
|
89
|
+
changedTouches = originalEvent ? originalEvent.changedTouches : [];
|
|
90
|
+
|
|
91
|
+
for (length = changedTouches.length; idx < length; idx++) {
|
|
92
|
+
touch = changedTouches[idx];
|
|
93
|
+
touches.push({
|
|
94
|
+
location: touch,
|
|
95
|
+
event: e,
|
|
96
|
+
target: touch.target,
|
|
97
|
+
currentTarget: currentTarget,
|
|
98
|
+
id: touch.identifier,
|
|
99
|
+
type: 'touch'
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
} else if (support.pointers || support.msPointers) {
|
|
103
|
+
touches.push({
|
|
104
|
+
location: originalEvent,
|
|
105
|
+
event: e,
|
|
106
|
+
target: e.target,
|
|
107
|
+
currentTarget: currentTarget,
|
|
108
|
+
id: originalEvent.pointerId,
|
|
109
|
+
type: 'pointer'
|
|
110
|
+
});
|
|
111
|
+
} else {
|
|
112
|
+
touches.push({
|
|
113
|
+
id: 1,
|
|
114
|
+
event: e,
|
|
115
|
+
target: e.target,
|
|
116
|
+
currentTarget: currentTarget,
|
|
117
|
+
location: e,
|
|
118
|
+
type: 'mouse'
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return touches;
|
|
123
|
+
}
|
|
124
|
+
export var TouchAxis = (function (Class) {
|
|
125
|
+
function TouchAxis(axis, location) {
|
|
126
|
+
Class.call(this);
|
|
127
|
+
var that = this;
|
|
128
|
+
|
|
129
|
+
that.support = getSupportedFeatures();
|
|
130
|
+
that.invalidZeroEvents = this.support.mobileOS && this.support.mobileOS.android;
|
|
131
|
+
that.axis = axis;
|
|
132
|
+
that._updateLocationData(location);
|
|
133
|
+
that.startLocation = that.location;
|
|
134
|
+
that.velocity = that.delta = 0;
|
|
135
|
+
that.timeStamp = now();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if ( Class ) TouchAxis.__proto__ = Class;
|
|
139
|
+
TouchAxis.prototype = Object.create( Class && Class.prototype );
|
|
140
|
+
TouchAxis.prototype.constructor = TouchAxis;
|
|
141
|
+
|
|
142
|
+
TouchAxis.prototype.move = function move (location) {
|
|
143
|
+
var that = this,
|
|
144
|
+
offset = location['page' + that.axis],
|
|
145
|
+
timeStamp = now(),
|
|
146
|
+
timeDelta = timeStamp - that.timeStamp || 1;
|
|
147
|
+
|
|
148
|
+
if (!offset && this.invalidZeroEvents) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
that.delta = offset - that.location;
|
|
153
|
+
that._updateLocationData(location);
|
|
154
|
+
that.initialDelta = offset - that.startLocation;
|
|
155
|
+
that.velocity = that.delta / timeDelta;
|
|
156
|
+
that.timeStamp = timeStamp;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
TouchAxis.prototype._updateLocationData = function _updateLocationData (location) {
|
|
160
|
+
var that = this,
|
|
161
|
+
axis = that.axis;
|
|
162
|
+
|
|
163
|
+
that.location = location['page' + axis];
|
|
164
|
+
that.client = location['client' + axis];
|
|
165
|
+
that.screen = location['screen' + axis];
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
return TouchAxis;
|
|
169
|
+
}(Class));
|
|
170
|
+
|
|
171
|
+
export var Touch = (function (Class) {
|
|
172
|
+
function Touch(userEvents, target, touchInfo) {
|
|
173
|
+
Class.call(this);
|
|
174
|
+
|
|
175
|
+
extend(this, {
|
|
176
|
+
x: new TouchAxis('X', touchInfo.location),
|
|
177
|
+
y: new TouchAxis('Y', touchInfo.location),
|
|
178
|
+
type: touchInfo.type,
|
|
179
|
+
useClickAsTap: userEvents.useClickAsTap,
|
|
180
|
+
threshold: userEvents.threshold || THRESHOLD[touchInfo.type],
|
|
181
|
+
userEvents: userEvents,
|
|
182
|
+
target: target,
|
|
183
|
+
currentTarget: touchInfo.currentTarget,
|
|
184
|
+
initialTouch: touchInfo.target,
|
|
185
|
+
id: touchInfo.id,
|
|
186
|
+
pressEvent: touchInfo,
|
|
187
|
+
_clicks: userEvents._clicks,
|
|
188
|
+
supportDoubleTap: userEvents.supportDoubleTap,
|
|
189
|
+
_moved: false,
|
|
190
|
+
_finished: false
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if ( Class ) Touch.__proto__ = Class;
|
|
195
|
+
Touch.prototype = Object.create( Class && Class.prototype );
|
|
196
|
+
Touch.prototype.constructor = Touch;
|
|
197
|
+
|
|
198
|
+
Touch.prototype.press = function press () {
|
|
199
|
+
// this._holdTimeout = setTimeout($.proxy(this, '_hold'), this.userEvents.minHold);
|
|
200
|
+
this._holdTimeout = setTimeout(proxy(this._hold, this), this.userEvents.minHold);
|
|
201
|
+
this._trigger(PRESS, this.pressEvent);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
Touch.prototype._tap = function _tap (touchInfo) {
|
|
205
|
+
var that = this;
|
|
206
|
+
|
|
207
|
+
that.userEvents._clicks++;
|
|
208
|
+
|
|
209
|
+
if (that.userEvents._clicks === 1) {
|
|
210
|
+
that._clickTimeout = setTimeout(function() {
|
|
211
|
+
if (that.userEvents._clicks === 1) {
|
|
212
|
+
that._trigger(TAP, touchInfo);
|
|
213
|
+
} else {
|
|
214
|
+
that._trigger(DOUBLETAP, touchInfo);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
that.userEvents._clicks = 0;
|
|
218
|
+
}, CLICK_DELAY);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
Touch.prototype._hold = function _hold () {
|
|
223
|
+
this._trigger(HOLD, this.pressEvent);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/* eslint-disable consistent-return */
|
|
227
|
+
Touch.prototype.move = function move (touchInfo) {
|
|
228
|
+
var that = this;
|
|
229
|
+
var preventMove = touchInfo.type !== 'api' && that.userEvents._shouldNotMove;
|
|
230
|
+
|
|
231
|
+
if (that._finished || preventMove) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
that.x.move(touchInfo.location);
|
|
236
|
+
that.y.move(touchInfo.location);
|
|
237
|
+
|
|
238
|
+
if (!that._moved) {
|
|
239
|
+
if (that._withinIgnoreThreshold()) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (!UserEvents.current || UserEvents.current === that.userEvents) {
|
|
244
|
+
that._start(touchInfo);
|
|
245
|
+
} else {
|
|
246
|
+
return that.dispose();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (!that._finished) {
|
|
251
|
+
that._trigger(MOVE, touchInfo);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
/* eslint-enable consistent-return */
|
|
255
|
+
|
|
256
|
+
Touch.prototype.end = function end (touchInfo) {
|
|
257
|
+
this.endTime = now();
|
|
258
|
+
|
|
259
|
+
if (this._finished) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
this._finished = true;
|
|
264
|
+
this._trigger(RELEASE, touchInfo);
|
|
265
|
+
|
|
266
|
+
if (this._moved) {
|
|
267
|
+
this._trigger(END, touchInfo);
|
|
268
|
+
} else {
|
|
269
|
+
if (!this.useClickAsTap) {
|
|
270
|
+
if (this.supportDoubleTap) {
|
|
271
|
+
this._tap(touchInfo);
|
|
272
|
+
} else {
|
|
273
|
+
this._trigger(TAP, touchInfo);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
clearTimeout(this._holdTimeout);
|
|
279
|
+
this.dispose();
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
Touch.prototype.dispose = function dispose () {
|
|
283
|
+
var userEvents = this.userEvents,
|
|
284
|
+
activeTouches = userEvents.touches || [];
|
|
285
|
+
|
|
286
|
+
this._finished = true;
|
|
287
|
+
this.pressEvent = null;
|
|
288
|
+
|
|
289
|
+
clearTimeout(this._holdTimeout);
|
|
290
|
+
// activeTouches.splice($.inArray(this, activeTouches), 1);
|
|
291
|
+
var activeTouchIndex = activeTouches.indexOf(this);
|
|
292
|
+
activeTouches.splice(activeTouchIndex, 1);
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
Touch.prototype.skip = function skip () {
|
|
296
|
+
this.dispose();
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
Touch.prototype.cancel = function cancel () {
|
|
300
|
+
this.dispose();
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
Touch.prototype.isMoved = function isMoved () {
|
|
304
|
+
return this._moved;
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
Touch.prototype._start = function _start (touchInfo) {
|
|
308
|
+
clearTimeout(this._holdTimeout);
|
|
309
|
+
this.startTime = now();
|
|
310
|
+
this._moved = true;
|
|
311
|
+
this._trigger(START, touchInfo);
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
Touch.prototype._trigger = function _trigger (name, touchInfo) {
|
|
315
|
+
var that = this,
|
|
316
|
+
jQueryEvent = touchInfo.event,
|
|
317
|
+
data = {
|
|
318
|
+
touch: that,
|
|
319
|
+
x: that.x,
|
|
320
|
+
y: that.y,
|
|
321
|
+
target: that.target,
|
|
322
|
+
event: jQueryEvent
|
|
323
|
+
};
|
|
324
|
+
if (that.userEvents.notify(name, data)) {
|
|
325
|
+
jQueryEvent.preventDefault();
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
Touch.prototype._withinIgnoreThreshold = function _withinIgnoreThreshold () {
|
|
330
|
+
var xDelta = this.x.initialDelta,
|
|
331
|
+
yDelta = this.y.initialDelta;
|
|
332
|
+
return Math.sqrt(xDelta * xDelta + yDelta * yDelta) <= this.threshold;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
return Touch;
|
|
336
|
+
}(Class));
|
|
337
|
+
|
|
338
|
+
function withEachUpEvent(callback) {
|
|
339
|
+
var eventMap = getEventMap(navigator.userAgent);
|
|
340
|
+
var downEvents = eventMap.up.split(' '),
|
|
341
|
+
idx = 0,
|
|
342
|
+
length = downEvents.length;
|
|
343
|
+
|
|
344
|
+
for (; idx < length; idx++) {
|
|
345
|
+
callback(downEvents[idx]);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export var UserEvents = (function (Observable) {
|
|
350
|
+
function UserEvents(element, options) {
|
|
351
|
+
Observable.call(this);
|
|
352
|
+
var that = this;
|
|
353
|
+
var filter;
|
|
354
|
+
|
|
355
|
+
var support = getSupportedFeatures();
|
|
356
|
+
this.support = support;
|
|
357
|
+
|
|
358
|
+
/* eslint-disable no-param-reassign */
|
|
359
|
+
options = options || {};
|
|
360
|
+
/* eslint-enable no-param-reassign */
|
|
361
|
+
this.options = options;
|
|
362
|
+
|
|
363
|
+
filter = that.filter = options.filter;
|
|
364
|
+
that.threshold = options.threshold || DEFAULT_THRESHOLD;
|
|
365
|
+
that.minHold = options.minHold || DEFAULT_MIN_HOLD;
|
|
366
|
+
that.touches = [];
|
|
367
|
+
that._maxTouches = options.multiTouch ? 2 : 1;
|
|
368
|
+
that.allowSelection = options.allowSelection;
|
|
369
|
+
that.captureUpIfMoved = options.captureUpIfMoved;
|
|
370
|
+
that.useClickAsTap = !options.fastTap && !support.delayedClick();
|
|
371
|
+
that._clicks = 0;
|
|
372
|
+
that.supportDoubleTap = options.supportDoubleTap;
|
|
373
|
+
|
|
374
|
+
var enableGlobalSurface = !support.touch || support.mouseAndTouchPresent;
|
|
375
|
+
|
|
376
|
+
extend(that, {
|
|
377
|
+
element: element,
|
|
378
|
+
surface: options.global && enableGlobalSurface ?
|
|
379
|
+
element.ownerDocument.documentElement :
|
|
380
|
+
options.surface || element,
|
|
381
|
+
stopPropagation: options.stopPropagation,
|
|
382
|
+
pressed: false
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
this._surfaceMoveHandler = proxy(this._move, this);
|
|
386
|
+
on(that.surface, applyEventMap('move'), this._surfaceMoveHandler);
|
|
387
|
+
|
|
388
|
+
this._surfaceEndHandler = proxy(this._end, this);
|
|
389
|
+
on(that.surface, applyEventMap('up cancel'), this._surfaceEndHandler);
|
|
390
|
+
|
|
391
|
+
this._elementStartHandler = proxy(this._start, this);
|
|
392
|
+
on(element, applyEventMap('down'), filter, this._elementStartHandler);
|
|
393
|
+
|
|
394
|
+
if (that.useClickAsTap) {
|
|
395
|
+
this._elementClickHandler = proxy(this._click, this);
|
|
396
|
+
on(element, applyEventMap('click'), filter, this._elementClickHandler);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if (support.pointers || support.msPointers) {
|
|
400
|
+
if (support.browser.version < 11) {
|
|
401
|
+
var defaultAction = 'pinch-zoom double-tap-zoom';
|
|
402
|
+
|
|
403
|
+
element.style['-ms-touch-action'] =
|
|
404
|
+
options.touchAction && options.touchAction !== 'none' ?
|
|
405
|
+
defaultAction + ' ' + options.touchAction :
|
|
406
|
+
defaultAction;
|
|
407
|
+
|
|
408
|
+
} else {
|
|
409
|
+
element.style['touch-action'] = options.touchAction || 'none';
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (options.preventDragEvent) {
|
|
413
|
+
this._elementDragStartHandler = preventDefault;
|
|
414
|
+
on(element, applyEventMap('dragstart'), this._elementDragStartHandler);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// element.on(kendo.applyEventMap('mousedown'), filter, {
|
|
418
|
+
// root: element
|
|
419
|
+
// } '_select');
|
|
420
|
+
|
|
421
|
+
// todo: use root
|
|
422
|
+
this._elementSelectHandler = proxy(this._select, this);
|
|
423
|
+
on(element, applyEventMap('mousedown'), filter, this._elementSelectHandler);
|
|
424
|
+
|
|
425
|
+
if (that.captureUpIfMoved && support.eventCapture) {
|
|
426
|
+
var surfaceElement = that.surface,
|
|
427
|
+
preventIfMovingProxy = proxy(that.preventIfMoving, that);
|
|
428
|
+
|
|
429
|
+
withEachUpEvent(function(eventName) {
|
|
430
|
+
surfaceElement.addEventListener(eventName, preventIfMovingProxy, true);
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
that.bind([
|
|
435
|
+
PRESS,
|
|
436
|
+
HOLD,
|
|
437
|
+
TAP,
|
|
438
|
+
DOUBLETAP,
|
|
439
|
+
START,
|
|
440
|
+
MOVE,
|
|
441
|
+
END,
|
|
442
|
+
RELEASE,
|
|
443
|
+
CANCEL,
|
|
444
|
+
GESTURESTART,
|
|
445
|
+
GESTURECHANGE,
|
|
446
|
+
GESTUREEND,
|
|
447
|
+
GESTURETAP,
|
|
448
|
+
SELECT
|
|
449
|
+
], options);
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
if ( Observable ) UserEvents.__proto__ = Observable;
|
|
453
|
+
UserEvents.prototype = Object.create( Observable && Observable.prototype );
|
|
454
|
+
UserEvents.prototype.constructor = UserEvents;
|
|
455
|
+
|
|
456
|
+
UserEvents.prototype.preventIfMoving = function preventIfMoving (e) {
|
|
457
|
+
if (this._isMoved()) {
|
|
458
|
+
e.preventDefault();
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
UserEvents.prototype.destroy = function destroy () {
|
|
463
|
+
var that = this;
|
|
464
|
+
var options = this.options;
|
|
465
|
+
var element = this.element;
|
|
466
|
+
|
|
467
|
+
if (that._destroyed) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
that._destroyed = true;
|
|
472
|
+
|
|
473
|
+
if (that.captureUpIfMoved && this.support.eventCapture) {
|
|
474
|
+
var surfaceElement = that.surface;
|
|
475
|
+
withEachUpEvent(function(eventName) {
|
|
476
|
+
surfaceElement.removeEventListener(eventName, that.preventIfMoving);
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
off(that.surface, applyEventMap('move'), this._surfaceMoveHandler);
|
|
481
|
+
off(that.surface, applyEventMap('up cancel'), this._surfaceEndHandler);
|
|
482
|
+
|
|
483
|
+
off(element, applyEventMap('down'), this._elementStartHandler);
|
|
484
|
+
|
|
485
|
+
if (that.useClickAsTap) {
|
|
486
|
+
off(element, applyEventMap('click'), this._elementClickHandler);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
if (options.preventDragEvent) {
|
|
490
|
+
off(element, applyEventMap('dragstart'), this._elementDragStartHandler);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
off(element, applyEventMap('mousedown'), this._elementSelectHandler);
|
|
494
|
+
|
|
495
|
+
that._disposeAll();
|
|
496
|
+
that.unbind();
|
|
497
|
+
|
|
498
|
+
delete that.surface;
|
|
499
|
+
delete that.element;
|
|
500
|
+
delete that.currentTarget;
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
UserEvents.prototype.capture = function capture () {
|
|
504
|
+
UserEvents.current = this;
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
UserEvents.prototype.cancel = function cancel () {
|
|
508
|
+
this._disposeAll();
|
|
509
|
+
this.trigger(CANCEL);
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
/* eslint-disable indent */
|
|
513
|
+
UserEvents.prototype.notify = function notify (event, data) {
|
|
514
|
+
var that = this,
|
|
515
|
+
touches = that.touches;
|
|
516
|
+
var eventName = event;
|
|
517
|
+
|
|
518
|
+
if (this._isMultiTouch()) {
|
|
519
|
+
switch (eventName) {
|
|
520
|
+
case MOVE:
|
|
521
|
+
eventName = GESTURECHANGE;
|
|
522
|
+
break;
|
|
523
|
+
case END:
|
|
524
|
+
eventName = GESTUREEND;
|
|
525
|
+
break;
|
|
526
|
+
case TAP:
|
|
527
|
+
eventName = GESTURETAP;
|
|
528
|
+
break;
|
|
529
|
+
default:
|
|
530
|
+
break;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
extend(data, {
|
|
534
|
+
touches: touches
|
|
535
|
+
}, touchDelta(touches[0], touches[1]));
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
return this.trigger(eventName, extend(data, {
|
|
539
|
+
type: eventName
|
|
540
|
+
}));
|
|
541
|
+
};
|
|
542
|
+
/* eslint-enable indent */
|
|
543
|
+
|
|
544
|
+
UserEvents.prototype.press = function press (x, y, target) {
|
|
545
|
+
this._apiCall('_start', x, y, target);
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
UserEvents.prototype.move = function move (x, y) {
|
|
549
|
+
this._apiCall('_move', x, y);
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
UserEvents.prototype.end = function end (x, y) {
|
|
553
|
+
this._apiCall('_end', x, y);
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
UserEvents.prototype._isMultiTouch = function _isMultiTouch () {
|
|
557
|
+
return this.touches.length > 1;
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
UserEvents.prototype._maxTouchesReached = function _maxTouchesReached () {
|
|
561
|
+
return this.touches.length >= this._maxTouches;
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
UserEvents.prototype._disposeAll = function _disposeAll () {
|
|
565
|
+
var touches = this.touches;
|
|
566
|
+
while (touches.length > 0) {
|
|
567
|
+
touches.pop().dispose();
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
UserEvents.prototype._isMoved = function _isMoved () {
|
|
572
|
+
return grep(this.touches, function(touch) {
|
|
573
|
+
return touch.isMoved();
|
|
574
|
+
}).length;
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
UserEvents.prototype._select = function _select (e) {
|
|
578
|
+
if (!this.allowSelection || this.trigger(SELECT, { event: e })) {
|
|
579
|
+
e.preventDefault();
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
UserEvents.prototype._start = function _start (e) {
|
|
584
|
+
var that = this,
|
|
585
|
+
idx = 0,
|
|
586
|
+
filter = that.filter,
|
|
587
|
+
target,
|
|
588
|
+
touches = getTouches(e),
|
|
589
|
+
length = touches.length,
|
|
590
|
+
touch,
|
|
591
|
+
which = e.which;
|
|
592
|
+
|
|
593
|
+
if (which && which > 1 || that._maxTouchesReached()) {
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
UserEvents.current = null;
|
|
598
|
+
that.currentTarget = e.currentTarget;
|
|
599
|
+
|
|
600
|
+
if (that.stopPropagation) {
|
|
601
|
+
e.stopPropagation();
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
for (; idx < length; idx++) {
|
|
605
|
+
if (that._maxTouchesReached()) {
|
|
606
|
+
break;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
touch = touches[idx];
|
|
610
|
+
|
|
611
|
+
if (filter) {
|
|
612
|
+
target = touch.currentTarget;
|
|
613
|
+
} else {
|
|
614
|
+
target = that.element;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
if (target && target.length === 0) {
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
touch = new Touch(that, target, touch);
|
|
622
|
+
that.touches.push(touch);
|
|
623
|
+
touch.press();
|
|
624
|
+
|
|
625
|
+
if (that._isMultiTouch()) {
|
|
626
|
+
that.notify('gesturestart', {});
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
UserEvents.prototype._move = function _move (e) {
|
|
632
|
+
this._eachTouch('move', e);
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
UserEvents.prototype._end = function _end (e) {
|
|
636
|
+
this._eachTouch('end', e);
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
UserEvents.prototype._click = function _click (e) {
|
|
640
|
+
var data = {
|
|
641
|
+
touch: {
|
|
642
|
+
initialTouch: e.target,
|
|
643
|
+
target: e.currentTarget,
|
|
644
|
+
endTime: now(),
|
|
645
|
+
x: {
|
|
646
|
+
location: e.pageX,
|
|
647
|
+
client: e.clientX
|
|
648
|
+
},
|
|
649
|
+
y: {
|
|
650
|
+
location: e.pageY,
|
|
651
|
+
client: e.clientY
|
|
652
|
+
}
|
|
653
|
+
},
|
|
654
|
+
x: e.pageX,
|
|
655
|
+
y: e.pageY,
|
|
656
|
+
target: e.currentTarget,
|
|
657
|
+
event: e,
|
|
658
|
+
type: 'tap'
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
if (this.trigger('tap', data)) {
|
|
662
|
+
e.preventDefault();
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
UserEvents.prototype._eachTouch = function _eachTouch (methodName, e) {
|
|
667
|
+
var that = this,
|
|
668
|
+
dict = {},
|
|
669
|
+
touches = getTouches(e),
|
|
670
|
+
activeTouches = that.touches,
|
|
671
|
+
idx,
|
|
672
|
+
touch,
|
|
673
|
+
touchInfo,
|
|
674
|
+
matchingTouch;
|
|
675
|
+
|
|
676
|
+
for (idx = 0; idx < activeTouches.length; idx++) {
|
|
677
|
+
touch = activeTouches[idx];
|
|
678
|
+
dict[touch.id] = touch;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
for (idx = 0; idx < touches.length; idx++) {
|
|
682
|
+
touchInfo = touches[idx];
|
|
683
|
+
matchingTouch = dict[touchInfo.id];
|
|
684
|
+
|
|
685
|
+
if (matchingTouch) {
|
|
686
|
+
matchingTouch[methodName](touchInfo);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
UserEvents.prototype._apiCall = function _apiCall (type, x, y, target) {
|
|
692
|
+
this[type]({
|
|
693
|
+
api: true,
|
|
694
|
+
pageX: x,
|
|
695
|
+
pageY: y,
|
|
696
|
+
clientX: x,
|
|
697
|
+
clientY: y,
|
|
698
|
+
target: target || this.element,
|
|
699
|
+
stopPropagation: noop,
|
|
700
|
+
preventDefault: noop
|
|
701
|
+
});
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
UserEvents.defaultThreshold = function defaultThreshold (value) {
|
|
705
|
+
DEFAULT_THRESHOLD = value;
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
UserEvents.minHold = function minHold (value) {
|
|
709
|
+
DEFAULT_MIN_HOLD = value;
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
return UserEvents;
|
|
713
|
+
}(Observable));
|