@talex-touch/tuffex-wc 0.0.0-stage → 0.1.0
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 +373 -0
- package/README.md +47 -2
- package/dist/chunks/TxImageGeneration.js +28478 -0
- package/dist/chunks/base-a.js +1223 -0
- package/dist/chunks/base-b.js +1648 -0
- package/dist/chunks/core.esm.js +2327 -0
- package/dist/chunks/glyphs-ai-1.js +33 -0
- package/dist/chunks/glyphs-ai-2.js +55 -0
- package/dist/chunks/glyphs-brand-1.js +23 -0
- package/dist/chunks/glyphs-brand-2.js +33 -0
- package/dist/chunks/glyphs-brand-3.js +40 -0
- package/dist/chunks/glyphs-icon-1.js +144 -0
- package/dist/chunks/glyphs-icon-2.js +124 -0
- package/dist/chunks/pinyin.js +4 -0
- package/dist/chunks/pull-down.esm.js +336 -0
- package/dist/chunks/pull-up.esm.js +234 -0
- package/dist/chunks/scroll-bar.esm.js +768 -0
- package/dist/chunks/tier-a.js +426 -0
- package/dist/chunks/tier-b.js +897 -0
- package/dist/chunks/tier-c.js +72 -0
- package/dist/chunks/tuffex-data.js +9757 -0
- package/dist/chunks/tuffex-extras.js +11692 -0
- package/dist/chunks/tuffex-media.js +13475 -0
- package/dist/chunks/tuffex-shared.js +17671 -0
- package/dist/chunks/vue-export-helper.js +10 -0
- package/dist/chunks/wc-runtime.js +922 -0
- package/dist/elements/base-a.d.ts +145 -0
- package/dist/elements/base-b.d.ts +129 -0
- package/dist/elements/index.d.ts +22 -0
- package/dist/elements/tier-a.d.ts +55 -0
- package/dist/elements/tier-b.d.ts +58 -0
- package/dist/elements/tier-c.d.ts +7 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +320 -0
- package/dist/manifest.d.ts +19 -0
- package/dist/manifest.js +1377 -0
- package/dist/runtime/coerce.d.ts +38 -0
- package/dist/runtime/events.d.ts +17 -0
- package/dist/runtime/factory.d.ts +129 -0
- package/dist/runtime/styles.d.ts +20 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +1861 -0
- package/package.json +75 -3
|
@@ -0,0 +1,2327 @@
|
|
|
1
|
+
var extendStatics = function(d, b) {
|
|
2
|
+
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
3
|
+
d2.__proto__ = b2;
|
|
4
|
+
} || function(d2, b2) {
|
|
5
|
+
for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
|
|
6
|
+
};
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
function __extends(d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() {
|
|
12
|
+
this.constructor = d;
|
|
13
|
+
}
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
}
|
|
16
|
+
var __assign = function() {
|
|
17
|
+
__assign = Object.assign || function __assign2(t) {
|
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
+
s = arguments[i];
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
function __spreadArrays() {
|
|
27
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
28
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
29
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
30
|
+
r[k] = a[j];
|
|
31
|
+
return r;
|
|
32
|
+
}
|
|
33
|
+
var propertiesConfig = [
|
|
34
|
+
{
|
|
35
|
+
sourceKey: "scroller.scrollBehaviorX.currentPos",
|
|
36
|
+
key: "x"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
sourceKey: "scroller.scrollBehaviorY.currentPos",
|
|
40
|
+
key: "y"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
sourceKey: "scroller.scrollBehaviorX.hasScroll",
|
|
44
|
+
key: "hasHorizontalScroll"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
sourceKey: "scroller.scrollBehaviorY.hasScroll",
|
|
48
|
+
key: "hasVerticalScroll"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
sourceKey: "scroller.scrollBehaviorX.contentSize",
|
|
52
|
+
key: "scrollerWidth"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
sourceKey: "scroller.scrollBehaviorY.contentSize",
|
|
56
|
+
key: "scrollerHeight"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
sourceKey: "scroller.scrollBehaviorX.maxScrollPos",
|
|
60
|
+
key: "maxScrollX"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
sourceKey: "scroller.scrollBehaviorY.maxScrollPos",
|
|
64
|
+
key: "maxScrollY"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
sourceKey: "scroller.scrollBehaviorX.minScrollPos",
|
|
68
|
+
key: "minScrollX"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
sourceKey: "scroller.scrollBehaviorY.minScrollPos",
|
|
72
|
+
key: "minScrollY"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
sourceKey: "scroller.scrollBehaviorX.movingDirection",
|
|
76
|
+
key: "movingDirectionX"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
sourceKey: "scroller.scrollBehaviorY.movingDirection",
|
|
80
|
+
key: "movingDirectionY"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
sourceKey: "scroller.scrollBehaviorX.direction",
|
|
84
|
+
key: "directionX"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
sourceKey: "scroller.scrollBehaviorY.direction",
|
|
88
|
+
key: "directionY"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
sourceKey: "scroller.actions.enabled",
|
|
92
|
+
key: "enabled"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
sourceKey: "scroller.animater.pending",
|
|
96
|
+
key: "pending"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
sourceKey: "scroller.animater.stop",
|
|
100
|
+
key: "stop"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
sourceKey: "scroller.scrollTo",
|
|
104
|
+
key: "scrollTo"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
sourceKey: "scroller.scrollBy",
|
|
108
|
+
key: "scrollBy"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
sourceKey: "scroller.scrollToElement",
|
|
112
|
+
key: "scrollToElement"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
sourceKey: "scroller.resetPosition",
|
|
116
|
+
key: "resetPosition"
|
|
117
|
+
}
|
|
118
|
+
];
|
|
119
|
+
function warn(msg) {
|
|
120
|
+
console.error("[BScroll warn]: " + msg);
|
|
121
|
+
}
|
|
122
|
+
var inBrowser = typeof window !== "undefined";
|
|
123
|
+
var ua = inBrowser && navigator.userAgent.toLowerCase();
|
|
124
|
+
var isWeChatDevTools = !!(ua && /wechatdevtools/.test(ua));
|
|
125
|
+
var isAndroid = ua && ua.indexOf("android") > 0;
|
|
126
|
+
var isIOSBadVersion = (function() {
|
|
127
|
+
if (typeof ua === "string") {
|
|
128
|
+
var regex = /os (\d\d?_\d(_\d)?)/;
|
|
129
|
+
var matches = regex.exec(ua);
|
|
130
|
+
if (!matches)
|
|
131
|
+
return false;
|
|
132
|
+
var parts = matches[1].split("_").map(function(item) {
|
|
133
|
+
return parseInt(item, 10);
|
|
134
|
+
});
|
|
135
|
+
return !!(parts[0] === 13 && parts[1] >= 4);
|
|
136
|
+
}
|
|
137
|
+
return false;
|
|
138
|
+
})();
|
|
139
|
+
var supportsPassive = false;
|
|
140
|
+
if (inBrowser) {
|
|
141
|
+
var EventName = "test-passive";
|
|
142
|
+
try {
|
|
143
|
+
var opts = {};
|
|
144
|
+
Object.defineProperty(opts, "passive", {
|
|
145
|
+
get: function() {
|
|
146
|
+
supportsPassive = true;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
window.addEventListener(EventName, function() {
|
|
150
|
+
}, opts);
|
|
151
|
+
} catch (e) {
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function getNow() {
|
|
155
|
+
return window.performance && window.performance.now && window.performance.timing ? window.performance.now() + window.performance.timing.navigationStart : +/* @__PURE__ */ new Date();
|
|
156
|
+
}
|
|
157
|
+
var extend = function(target, source) {
|
|
158
|
+
for (var key in source) {
|
|
159
|
+
target[key] = source[key];
|
|
160
|
+
}
|
|
161
|
+
return target;
|
|
162
|
+
};
|
|
163
|
+
function isUndef(v) {
|
|
164
|
+
return v === void 0 || v === null;
|
|
165
|
+
}
|
|
166
|
+
function between(x, min, max) {
|
|
167
|
+
if (x < min) {
|
|
168
|
+
return min;
|
|
169
|
+
}
|
|
170
|
+
if (x > max) {
|
|
171
|
+
return max;
|
|
172
|
+
}
|
|
173
|
+
return x;
|
|
174
|
+
}
|
|
175
|
+
var elementStyle = inBrowser && document.createElement("div").style;
|
|
176
|
+
var vendor = (function() {
|
|
177
|
+
if (!inBrowser) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
var transformNames = [
|
|
181
|
+
{
|
|
182
|
+
key: "standard",
|
|
183
|
+
value: "transform"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
key: "webkit",
|
|
187
|
+
value: "webkitTransform"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
key: "Moz",
|
|
191
|
+
value: "MozTransform"
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
key: "O",
|
|
195
|
+
value: "OTransform"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
key: "ms",
|
|
199
|
+
value: "msTransform"
|
|
200
|
+
}
|
|
201
|
+
];
|
|
202
|
+
for (var _i = 0, transformNames_1 = transformNames; _i < transformNames_1.length; _i++) {
|
|
203
|
+
var obj = transformNames_1[_i];
|
|
204
|
+
if (elementStyle[obj.value] !== void 0) {
|
|
205
|
+
return obj.key;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return false;
|
|
209
|
+
})();
|
|
210
|
+
function prefixStyle(style2) {
|
|
211
|
+
if (vendor === false) {
|
|
212
|
+
return style2;
|
|
213
|
+
}
|
|
214
|
+
if (vendor === "standard") {
|
|
215
|
+
if (style2 === "transitionEnd") {
|
|
216
|
+
return "transitionend";
|
|
217
|
+
}
|
|
218
|
+
return style2;
|
|
219
|
+
}
|
|
220
|
+
return vendor + style2.charAt(0).toUpperCase() + style2.substr(1);
|
|
221
|
+
}
|
|
222
|
+
function getElement(el) {
|
|
223
|
+
return typeof el === "string" ? document.querySelector(el) : el;
|
|
224
|
+
}
|
|
225
|
+
function addEvent(el, type, fn, capture) {
|
|
226
|
+
var useCapture = supportsPassive ? {
|
|
227
|
+
passive: false,
|
|
228
|
+
capture: !!capture
|
|
229
|
+
} : !!capture;
|
|
230
|
+
el.addEventListener(type, fn, useCapture);
|
|
231
|
+
}
|
|
232
|
+
function removeEvent(el, type, fn, capture) {
|
|
233
|
+
el.removeEventListener(type, fn, {
|
|
234
|
+
capture: !!capture
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function maybePrevent(e) {
|
|
238
|
+
if (e.cancelable) {
|
|
239
|
+
e.preventDefault();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function offset(el) {
|
|
243
|
+
var left = 0;
|
|
244
|
+
var top = 0;
|
|
245
|
+
while (el) {
|
|
246
|
+
left -= el.offsetLeft;
|
|
247
|
+
top -= el.offsetTop;
|
|
248
|
+
el = el.offsetParent;
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
left,
|
|
252
|
+
top
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
vendor && vendor !== "standard" ? "-" + vendor.toLowerCase() + "-" : "";
|
|
256
|
+
var transform = prefixStyle("transform");
|
|
257
|
+
var transition = prefixStyle("transition");
|
|
258
|
+
var hasPerspective = inBrowser && prefixStyle("perspective") in elementStyle;
|
|
259
|
+
var hasTouch = inBrowser && ("ontouchstart" in window || isWeChatDevTools);
|
|
260
|
+
var hasTransition = inBrowser && transition in elementStyle;
|
|
261
|
+
var style = {
|
|
262
|
+
transform,
|
|
263
|
+
transitionTimingFunction: prefixStyle("transitionTimingFunction"),
|
|
264
|
+
transitionDuration: prefixStyle("transitionDuration"),
|
|
265
|
+
transitionDelay: prefixStyle("transitionDelay"),
|
|
266
|
+
transformOrigin: prefixStyle("transformOrigin"),
|
|
267
|
+
transitionEnd: prefixStyle("transitionEnd"),
|
|
268
|
+
transitionProperty: prefixStyle("transitionProperty")
|
|
269
|
+
};
|
|
270
|
+
var eventTypeMap = {
|
|
271
|
+
touchstart: 1,
|
|
272
|
+
touchmove: 1,
|
|
273
|
+
touchend: 1,
|
|
274
|
+
touchcancel: 1,
|
|
275
|
+
mousedown: 2,
|
|
276
|
+
mousemove: 2,
|
|
277
|
+
mouseup: 2
|
|
278
|
+
};
|
|
279
|
+
function getRect(el) {
|
|
280
|
+
if (el instanceof window.SVGElement) {
|
|
281
|
+
var rect = el.getBoundingClientRect();
|
|
282
|
+
return {
|
|
283
|
+
top: rect.top,
|
|
284
|
+
left: rect.left,
|
|
285
|
+
width: rect.width,
|
|
286
|
+
height: rect.height
|
|
287
|
+
};
|
|
288
|
+
} else {
|
|
289
|
+
return {
|
|
290
|
+
top: el.offsetTop,
|
|
291
|
+
left: el.offsetLeft,
|
|
292
|
+
width: el.offsetWidth,
|
|
293
|
+
height: el.offsetHeight
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
function preventDefaultExceptionFn(el, exceptions) {
|
|
298
|
+
for (var i in exceptions) {
|
|
299
|
+
if (exceptions[i].test(el[i])) {
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
var tagExceptionFn = preventDefaultExceptionFn;
|
|
306
|
+
function tap(e, eventName) {
|
|
307
|
+
var ev = document.createEvent("Event");
|
|
308
|
+
ev.initEvent(eventName, true, true);
|
|
309
|
+
ev.pageX = e.pageX;
|
|
310
|
+
ev.pageY = e.pageY;
|
|
311
|
+
e.target.dispatchEvent(ev);
|
|
312
|
+
}
|
|
313
|
+
function click(e, event) {
|
|
314
|
+
if (event === void 0) {
|
|
315
|
+
event = "click";
|
|
316
|
+
}
|
|
317
|
+
var eventSource;
|
|
318
|
+
if (e.type === "mouseup") {
|
|
319
|
+
eventSource = e;
|
|
320
|
+
} else if (e.type === "touchend" || e.type === "touchcancel") {
|
|
321
|
+
eventSource = e.changedTouches[0];
|
|
322
|
+
}
|
|
323
|
+
var posSrc = {};
|
|
324
|
+
if (eventSource) {
|
|
325
|
+
posSrc.screenX = eventSource.screenX || 0;
|
|
326
|
+
posSrc.screenY = eventSource.screenY || 0;
|
|
327
|
+
posSrc.clientX = eventSource.clientX || 0;
|
|
328
|
+
posSrc.clientY = eventSource.clientY || 0;
|
|
329
|
+
}
|
|
330
|
+
var ev;
|
|
331
|
+
var bubbles = true;
|
|
332
|
+
var cancelable = true;
|
|
333
|
+
var ctrlKey = e.ctrlKey, shiftKey = e.shiftKey, altKey = e.altKey, metaKey = e.metaKey;
|
|
334
|
+
var pressedKeysMap = {
|
|
335
|
+
ctrlKey,
|
|
336
|
+
shiftKey,
|
|
337
|
+
altKey,
|
|
338
|
+
metaKey
|
|
339
|
+
};
|
|
340
|
+
if (typeof MouseEvent !== "undefined") {
|
|
341
|
+
try {
|
|
342
|
+
ev = new MouseEvent(event, extend(__assign({
|
|
343
|
+
bubbles,
|
|
344
|
+
cancelable
|
|
345
|
+
}, pressedKeysMap), posSrc));
|
|
346
|
+
} catch (e2) {
|
|
347
|
+
createEvent();
|
|
348
|
+
}
|
|
349
|
+
} else {
|
|
350
|
+
createEvent();
|
|
351
|
+
}
|
|
352
|
+
function createEvent() {
|
|
353
|
+
ev = document.createEvent("Event");
|
|
354
|
+
ev.initEvent(event, bubbles, cancelable);
|
|
355
|
+
extend(ev, posSrc);
|
|
356
|
+
}
|
|
357
|
+
ev.forwardedTouchEvent = true;
|
|
358
|
+
ev._constructed = true;
|
|
359
|
+
e.target.dispatchEvent(ev);
|
|
360
|
+
}
|
|
361
|
+
function dblclick(e) {
|
|
362
|
+
click(e, "dblclick");
|
|
363
|
+
}
|
|
364
|
+
var ease = {
|
|
365
|
+
// easeOutQuard
|
|
366
|
+
swipeBounce: {
|
|
367
|
+
style: "cubic-bezier(0.25, 0.46, 0.45, 0.94)",
|
|
368
|
+
fn: function(t) {
|
|
369
|
+
return t * (2 - t);
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
// easeOutQuart
|
|
373
|
+
bounce: {
|
|
374
|
+
style: "cubic-bezier(0.165, 0.84, 0.44, 1)",
|
|
375
|
+
fn: function(t) {
|
|
376
|
+
return 1 - --t * t * t * t;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
var DEFAULT_INTERVAL = 1e3 / 60;
|
|
381
|
+
var windowCompat = inBrowser && window;
|
|
382
|
+
function noop$1() {
|
|
383
|
+
}
|
|
384
|
+
var requestAnimationFrame = (function() {
|
|
385
|
+
if (!inBrowser) {
|
|
386
|
+
return noop$1;
|
|
387
|
+
}
|
|
388
|
+
return windowCompat.requestAnimationFrame || windowCompat.webkitRequestAnimationFrame || windowCompat.mozRequestAnimationFrame || windowCompat.oRequestAnimationFrame || // if all else fails, use setTimeout
|
|
389
|
+
function(callback) {
|
|
390
|
+
return window.setTimeout(callback, callback.interval || DEFAULT_INTERVAL);
|
|
391
|
+
};
|
|
392
|
+
})();
|
|
393
|
+
var cancelAnimationFrame = (function() {
|
|
394
|
+
if (!inBrowser) {
|
|
395
|
+
return noop$1;
|
|
396
|
+
}
|
|
397
|
+
return windowCompat.cancelAnimationFrame || windowCompat.webkitCancelAnimationFrame || windowCompat.mozCancelAnimationFrame || windowCompat.oCancelAnimationFrame || function(id) {
|
|
398
|
+
window.clearTimeout(id);
|
|
399
|
+
};
|
|
400
|
+
})();
|
|
401
|
+
var noop = function(val) {
|
|
402
|
+
};
|
|
403
|
+
var sharedPropertyDefinition = {
|
|
404
|
+
enumerable: true,
|
|
405
|
+
configurable: true,
|
|
406
|
+
get: noop,
|
|
407
|
+
set: noop
|
|
408
|
+
};
|
|
409
|
+
var getProperty = function(obj, key) {
|
|
410
|
+
var keys = key.split(".");
|
|
411
|
+
for (var i = 0; i < keys.length - 1; i++) {
|
|
412
|
+
obj = obj[keys[i]];
|
|
413
|
+
if (typeof obj !== "object" || !obj)
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
var lastKey = keys.pop();
|
|
417
|
+
if (typeof obj[lastKey] === "function") {
|
|
418
|
+
return function() {
|
|
419
|
+
return obj[lastKey].apply(obj, arguments);
|
|
420
|
+
};
|
|
421
|
+
} else {
|
|
422
|
+
return obj[lastKey];
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
var setProperty = function(obj, key, value) {
|
|
426
|
+
var keys = key.split(".");
|
|
427
|
+
var temp;
|
|
428
|
+
for (var i = 0; i < keys.length - 1; i++) {
|
|
429
|
+
temp = keys[i];
|
|
430
|
+
if (!obj[temp])
|
|
431
|
+
obj[temp] = {};
|
|
432
|
+
obj = obj[temp];
|
|
433
|
+
}
|
|
434
|
+
obj[keys.pop()] = value;
|
|
435
|
+
};
|
|
436
|
+
function propertiesProxy(target, sourceKey, key) {
|
|
437
|
+
sharedPropertyDefinition.get = function proxyGetter() {
|
|
438
|
+
return getProperty(this, sourceKey);
|
|
439
|
+
};
|
|
440
|
+
sharedPropertyDefinition.set = function proxySetter(val) {
|
|
441
|
+
setProperty(this, sourceKey, val);
|
|
442
|
+
};
|
|
443
|
+
Object.defineProperty(target, key, sharedPropertyDefinition);
|
|
444
|
+
}
|
|
445
|
+
var EventEmitter = (
|
|
446
|
+
/** @class */
|
|
447
|
+
(function() {
|
|
448
|
+
function EventEmitter2(names) {
|
|
449
|
+
this.events = {};
|
|
450
|
+
this.eventTypes = {};
|
|
451
|
+
this.registerType(names);
|
|
452
|
+
}
|
|
453
|
+
EventEmitter2.prototype.on = function(type, fn, context) {
|
|
454
|
+
if (context === void 0) {
|
|
455
|
+
context = this;
|
|
456
|
+
}
|
|
457
|
+
this.hasType(type);
|
|
458
|
+
if (!this.events[type]) {
|
|
459
|
+
this.events[type] = [];
|
|
460
|
+
}
|
|
461
|
+
this.events[type].push([fn, context]);
|
|
462
|
+
return this;
|
|
463
|
+
};
|
|
464
|
+
EventEmitter2.prototype.once = function(type, fn, context) {
|
|
465
|
+
var _this = this;
|
|
466
|
+
if (context === void 0) {
|
|
467
|
+
context = this;
|
|
468
|
+
}
|
|
469
|
+
this.hasType(type);
|
|
470
|
+
var magic = function() {
|
|
471
|
+
var args = [];
|
|
472
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
473
|
+
args[_i] = arguments[_i];
|
|
474
|
+
}
|
|
475
|
+
_this.off(type, magic);
|
|
476
|
+
var ret = fn.apply(context, args);
|
|
477
|
+
if (ret === true) {
|
|
478
|
+
return ret;
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
magic.fn = fn;
|
|
482
|
+
this.on(type, magic);
|
|
483
|
+
return this;
|
|
484
|
+
};
|
|
485
|
+
EventEmitter2.prototype.off = function(type, fn) {
|
|
486
|
+
if (!type && !fn) {
|
|
487
|
+
this.events = {};
|
|
488
|
+
return this;
|
|
489
|
+
}
|
|
490
|
+
if (type) {
|
|
491
|
+
this.hasType(type);
|
|
492
|
+
if (!fn) {
|
|
493
|
+
this.events[type] = [];
|
|
494
|
+
return this;
|
|
495
|
+
}
|
|
496
|
+
var events = this.events[type];
|
|
497
|
+
if (!events) {
|
|
498
|
+
return this;
|
|
499
|
+
}
|
|
500
|
+
var count = events.length;
|
|
501
|
+
while (count--) {
|
|
502
|
+
if (events[count][0] === fn || events[count][0] && events[count][0].fn === fn) {
|
|
503
|
+
events.splice(count, 1);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return this;
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
EventEmitter2.prototype.trigger = function(type) {
|
|
510
|
+
var args = [];
|
|
511
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
512
|
+
args[_i - 1] = arguments[_i];
|
|
513
|
+
}
|
|
514
|
+
this.hasType(type);
|
|
515
|
+
var events = this.events[type];
|
|
516
|
+
if (!events) {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
var len = events.length;
|
|
520
|
+
var eventsCopy = __spreadArrays(events);
|
|
521
|
+
var ret;
|
|
522
|
+
for (var i = 0; i < len; i++) {
|
|
523
|
+
var event_1 = eventsCopy[i];
|
|
524
|
+
var fn = event_1[0], context = event_1[1];
|
|
525
|
+
if (fn) {
|
|
526
|
+
ret = fn.apply(context, args);
|
|
527
|
+
if (ret === true) {
|
|
528
|
+
return ret;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
EventEmitter2.prototype.registerType = function(names) {
|
|
534
|
+
var _this = this;
|
|
535
|
+
names.forEach(function(type) {
|
|
536
|
+
_this.eventTypes[type] = type;
|
|
537
|
+
});
|
|
538
|
+
};
|
|
539
|
+
EventEmitter2.prototype.destroy = function() {
|
|
540
|
+
this.events = {};
|
|
541
|
+
this.eventTypes = {};
|
|
542
|
+
};
|
|
543
|
+
EventEmitter2.prototype.hasType = function(type) {
|
|
544
|
+
var types = this.eventTypes;
|
|
545
|
+
var isType = types[type] === type;
|
|
546
|
+
if (!isType) {
|
|
547
|
+
warn('EventEmitter has used unknown event type: "' + type + '", should be oneof [' + ("" + Object.keys(types).map(function(_) {
|
|
548
|
+
return JSON.stringify(_);
|
|
549
|
+
})) + "]");
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
return EventEmitter2;
|
|
553
|
+
})()
|
|
554
|
+
);
|
|
555
|
+
var EventRegister = (
|
|
556
|
+
/** @class */
|
|
557
|
+
(function() {
|
|
558
|
+
function EventRegister2(wrapper, events) {
|
|
559
|
+
this.wrapper = wrapper;
|
|
560
|
+
this.events = events;
|
|
561
|
+
this.addDOMEvents();
|
|
562
|
+
}
|
|
563
|
+
EventRegister2.prototype.destroy = function() {
|
|
564
|
+
this.removeDOMEvents();
|
|
565
|
+
this.events = [];
|
|
566
|
+
};
|
|
567
|
+
EventRegister2.prototype.addDOMEvents = function() {
|
|
568
|
+
this.handleDOMEvents(addEvent);
|
|
569
|
+
};
|
|
570
|
+
EventRegister2.prototype.removeDOMEvents = function() {
|
|
571
|
+
this.handleDOMEvents(removeEvent);
|
|
572
|
+
};
|
|
573
|
+
EventRegister2.prototype.handleDOMEvents = function(eventOperation) {
|
|
574
|
+
var _this = this;
|
|
575
|
+
var wrapper = this.wrapper;
|
|
576
|
+
this.events.forEach(function(event) {
|
|
577
|
+
eventOperation(wrapper, event.name, _this, !!event.capture);
|
|
578
|
+
});
|
|
579
|
+
};
|
|
580
|
+
EventRegister2.prototype.handleEvent = function(e) {
|
|
581
|
+
var eventType = e.type;
|
|
582
|
+
this.events.some(function(event) {
|
|
583
|
+
if (event.name === eventType) {
|
|
584
|
+
event.handler(e);
|
|
585
|
+
return true;
|
|
586
|
+
}
|
|
587
|
+
return false;
|
|
588
|
+
});
|
|
589
|
+
};
|
|
590
|
+
return EventRegister2;
|
|
591
|
+
})()
|
|
592
|
+
);
|
|
593
|
+
var CustomOptions = (
|
|
594
|
+
/** @class */
|
|
595
|
+
/* @__PURE__ */ (function() {
|
|
596
|
+
function CustomOptions2() {
|
|
597
|
+
}
|
|
598
|
+
return CustomOptions2;
|
|
599
|
+
})()
|
|
600
|
+
);
|
|
601
|
+
var OptionsConstructor = (
|
|
602
|
+
/** @class */
|
|
603
|
+
(function(_super) {
|
|
604
|
+
__extends(OptionsConstructor2, _super);
|
|
605
|
+
function OptionsConstructor2() {
|
|
606
|
+
var _this = _super.call(this) || this;
|
|
607
|
+
_this.startX = 0;
|
|
608
|
+
_this.startY = 0;
|
|
609
|
+
_this.scrollX = false;
|
|
610
|
+
_this.scrollY = true;
|
|
611
|
+
_this.freeScroll = false;
|
|
612
|
+
_this.directionLockThreshold = 0;
|
|
613
|
+
_this.eventPassthrough = "";
|
|
614
|
+
_this.click = false;
|
|
615
|
+
_this.dblclick = false;
|
|
616
|
+
_this.tap = "";
|
|
617
|
+
_this.bounce = {
|
|
618
|
+
top: true,
|
|
619
|
+
bottom: true,
|
|
620
|
+
left: true,
|
|
621
|
+
right: true
|
|
622
|
+
};
|
|
623
|
+
_this.bounceTime = 800;
|
|
624
|
+
_this.momentum = true;
|
|
625
|
+
_this.momentumLimitTime = 300;
|
|
626
|
+
_this.momentumLimitDistance = 15;
|
|
627
|
+
_this.swipeTime = 2500;
|
|
628
|
+
_this.swipeBounceTime = 500;
|
|
629
|
+
_this.deceleration = 15e-4;
|
|
630
|
+
_this.flickLimitTime = 200;
|
|
631
|
+
_this.flickLimitDistance = 100;
|
|
632
|
+
_this.resizePolling = 60;
|
|
633
|
+
_this.probeType = 0;
|
|
634
|
+
_this.stopPropagation = false;
|
|
635
|
+
_this.preventDefault = true;
|
|
636
|
+
_this.preventDefaultException = {
|
|
637
|
+
tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT|AUDIO)$/
|
|
638
|
+
};
|
|
639
|
+
_this.tagException = {
|
|
640
|
+
tagName: /^TEXTAREA$/
|
|
641
|
+
};
|
|
642
|
+
_this.HWCompositing = true;
|
|
643
|
+
_this.useTransition = true;
|
|
644
|
+
_this.bindToWrapper = false;
|
|
645
|
+
_this.bindToTarget = false;
|
|
646
|
+
_this.disableMouse = hasTouch;
|
|
647
|
+
_this.disableTouch = !hasTouch;
|
|
648
|
+
_this.autoBlur = true;
|
|
649
|
+
_this.autoEndDistance = 5;
|
|
650
|
+
_this.outOfBoundaryDampingFactor = 1 / 3;
|
|
651
|
+
_this.specifiedIndexAsContent = 0;
|
|
652
|
+
_this.quadrant = 1;
|
|
653
|
+
return _this;
|
|
654
|
+
}
|
|
655
|
+
OptionsConstructor2.prototype.merge = function(options) {
|
|
656
|
+
if (!options)
|
|
657
|
+
return this;
|
|
658
|
+
for (var key in options) {
|
|
659
|
+
if (key === "bounce") {
|
|
660
|
+
this.bounce = this.resolveBounce(options[key]);
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
this[key] = options[key];
|
|
664
|
+
}
|
|
665
|
+
return this;
|
|
666
|
+
};
|
|
667
|
+
OptionsConstructor2.prototype.process = function() {
|
|
668
|
+
this.translateZ = this.HWCompositing && hasPerspective ? " translateZ(1px)" : "";
|
|
669
|
+
this.useTransition = this.useTransition && hasTransition;
|
|
670
|
+
this.preventDefault = !this.eventPassthrough && this.preventDefault;
|
|
671
|
+
this.scrollX = this.eventPassthrough === "horizontal" ? false : this.scrollX;
|
|
672
|
+
this.scrollY = this.eventPassthrough === "vertical" ? false : this.scrollY;
|
|
673
|
+
this.freeScroll = this.freeScroll && !this.eventPassthrough;
|
|
674
|
+
this.scrollX = this.freeScroll ? true : this.scrollX;
|
|
675
|
+
this.scrollY = this.freeScroll ? true : this.scrollY;
|
|
676
|
+
this.directionLockThreshold = this.eventPassthrough ? 0 : this.directionLockThreshold;
|
|
677
|
+
return this;
|
|
678
|
+
};
|
|
679
|
+
OptionsConstructor2.prototype.resolveBounce = function(bounceOptions) {
|
|
680
|
+
var DEFAULT_BOUNCE = {
|
|
681
|
+
top: true,
|
|
682
|
+
right: true,
|
|
683
|
+
bottom: true,
|
|
684
|
+
left: true
|
|
685
|
+
};
|
|
686
|
+
var NEGATED_BOUNCE = {
|
|
687
|
+
top: false,
|
|
688
|
+
right: false,
|
|
689
|
+
bottom: false,
|
|
690
|
+
left: false
|
|
691
|
+
};
|
|
692
|
+
var ret;
|
|
693
|
+
if (typeof bounceOptions === "object") {
|
|
694
|
+
ret = extend(DEFAULT_BOUNCE, bounceOptions);
|
|
695
|
+
} else {
|
|
696
|
+
ret = bounceOptions ? DEFAULT_BOUNCE : NEGATED_BOUNCE;
|
|
697
|
+
}
|
|
698
|
+
return ret;
|
|
699
|
+
};
|
|
700
|
+
return OptionsConstructor2;
|
|
701
|
+
})(CustomOptions)
|
|
702
|
+
);
|
|
703
|
+
var ActionsHandler = (
|
|
704
|
+
/** @class */
|
|
705
|
+
(function() {
|
|
706
|
+
function ActionsHandler2(wrapper, options) {
|
|
707
|
+
this.wrapper = wrapper;
|
|
708
|
+
this.options = options;
|
|
709
|
+
this.hooks = new EventEmitter([
|
|
710
|
+
"beforeStart",
|
|
711
|
+
"start",
|
|
712
|
+
"move",
|
|
713
|
+
"end",
|
|
714
|
+
"click"
|
|
715
|
+
]);
|
|
716
|
+
this.handleDOMEvents();
|
|
717
|
+
}
|
|
718
|
+
ActionsHandler2.prototype.handleDOMEvents = function() {
|
|
719
|
+
var _a2 = this.options, bindToWrapper = _a2.bindToWrapper, disableMouse = _a2.disableMouse, disableTouch = _a2.disableTouch, click2 = _a2.click;
|
|
720
|
+
var wrapper = this.wrapper;
|
|
721
|
+
var target = bindToWrapper ? wrapper : window;
|
|
722
|
+
var wrapperEvents = [];
|
|
723
|
+
var targetEvents = [];
|
|
724
|
+
var shouldRegisterTouch = !disableTouch;
|
|
725
|
+
var shouldRegisterMouse = !disableMouse;
|
|
726
|
+
if (click2) {
|
|
727
|
+
wrapperEvents.push({
|
|
728
|
+
name: "click",
|
|
729
|
+
handler: this.click.bind(this),
|
|
730
|
+
capture: true
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
if (shouldRegisterTouch) {
|
|
734
|
+
wrapperEvents.push({
|
|
735
|
+
name: "touchstart",
|
|
736
|
+
handler: this.start.bind(this)
|
|
737
|
+
});
|
|
738
|
+
targetEvents.push({
|
|
739
|
+
name: "touchmove",
|
|
740
|
+
handler: this.move.bind(this)
|
|
741
|
+
}, {
|
|
742
|
+
name: "touchend",
|
|
743
|
+
handler: this.end.bind(this)
|
|
744
|
+
}, {
|
|
745
|
+
name: "touchcancel",
|
|
746
|
+
handler: this.end.bind(this)
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
if (shouldRegisterMouse) {
|
|
750
|
+
wrapperEvents.push({
|
|
751
|
+
name: "mousedown",
|
|
752
|
+
handler: this.start.bind(this)
|
|
753
|
+
});
|
|
754
|
+
targetEvents.push({
|
|
755
|
+
name: "mousemove",
|
|
756
|
+
handler: this.move.bind(this)
|
|
757
|
+
}, {
|
|
758
|
+
name: "mouseup",
|
|
759
|
+
handler: this.end.bind(this)
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
this.wrapperEventRegister = new EventRegister(wrapper, wrapperEvents);
|
|
763
|
+
this.targetEventRegister = new EventRegister(target, targetEvents);
|
|
764
|
+
};
|
|
765
|
+
ActionsHandler2.prototype.beforeHandler = function(e, type) {
|
|
766
|
+
var _a2 = this.options, preventDefault = _a2.preventDefault, stopPropagation = _a2.stopPropagation, preventDefaultException = _a2.preventDefaultException;
|
|
767
|
+
var preventDefaultConditions = {
|
|
768
|
+
start: function() {
|
|
769
|
+
return preventDefault && !preventDefaultExceptionFn(e.target, preventDefaultException);
|
|
770
|
+
},
|
|
771
|
+
end: function() {
|
|
772
|
+
return preventDefault && !preventDefaultExceptionFn(e.target, preventDefaultException);
|
|
773
|
+
},
|
|
774
|
+
move: function() {
|
|
775
|
+
return preventDefault;
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
if (preventDefaultConditions[type]()) {
|
|
779
|
+
e.preventDefault();
|
|
780
|
+
}
|
|
781
|
+
if (stopPropagation) {
|
|
782
|
+
e.stopPropagation();
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
ActionsHandler2.prototype.setInitiated = function(type) {
|
|
786
|
+
if (type === void 0) {
|
|
787
|
+
type = 0;
|
|
788
|
+
}
|
|
789
|
+
this.initiated = type;
|
|
790
|
+
};
|
|
791
|
+
ActionsHandler2.prototype.start = function(e) {
|
|
792
|
+
var _eventType = eventTypeMap[e.type];
|
|
793
|
+
if (this.initiated && this.initiated !== _eventType) {
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
this.setInitiated(_eventType);
|
|
797
|
+
if (tagExceptionFn(e.target, this.options.tagException)) {
|
|
798
|
+
this.setInitiated();
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
if (_eventType === 2 && e.button !== 0)
|
|
802
|
+
return;
|
|
803
|
+
if (this.hooks.trigger(this.hooks.eventTypes.beforeStart, e)) {
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
this.beforeHandler(e, "start");
|
|
807
|
+
var point = e.touches ? e.touches[0] : e;
|
|
808
|
+
this.pointX = point.pageX;
|
|
809
|
+
this.pointY = point.pageY;
|
|
810
|
+
this.hooks.trigger(this.hooks.eventTypes.start, e);
|
|
811
|
+
};
|
|
812
|
+
ActionsHandler2.prototype.move = function(e) {
|
|
813
|
+
if (eventTypeMap[e.type] !== this.initiated) {
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
this.beforeHandler(e, "move");
|
|
817
|
+
var point = e.touches ? e.touches[0] : e;
|
|
818
|
+
var deltaX = point.pageX - this.pointX;
|
|
819
|
+
var deltaY = point.pageY - this.pointY;
|
|
820
|
+
this.pointX = point.pageX;
|
|
821
|
+
this.pointY = point.pageY;
|
|
822
|
+
if (this.hooks.trigger(this.hooks.eventTypes.move, {
|
|
823
|
+
deltaX,
|
|
824
|
+
deltaY,
|
|
825
|
+
e
|
|
826
|
+
})) {
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
var scrollLeft = document.documentElement.scrollLeft || window.pageXOffset || document.body.scrollLeft;
|
|
830
|
+
var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
|
|
831
|
+
var pX = this.pointX - scrollLeft;
|
|
832
|
+
var pY = this.pointY - scrollTop;
|
|
833
|
+
var autoEndDistance = this.options.autoEndDistance;
|
|
834
|
+
if (pX > document.documentElement.clientWidth - autoEndDistance || pY > document.documentElement.clientHeight - autoEndDistance || pX < autoEndDistance || pY < autoEndDistance) {
|
|
835
|
+
this.end(e);
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
ActionsHandler2.prototype.end = function(e) {
|
|
839
|
+
if (eventTypeMap[e.type] !== this.initiated) {
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
this.setInitiated();
|
|
843
|
+
this.beforeHandler(e, "end");
|
|
844
|
+
this.hooks.trigger(this.hooks.eventTypes.end, e);
|
|
845
|
+
};
|
|
846
|
+
ActionsHandler2.prototype.click = function(e) {
|
|
847
|
+
this.hooks.trigger(this.hooks.eventTypes.click, e);
|
|
848
|
+
};
|
|
849
|
+
ActionsHandler2.prototype.setContent = function(content) {
|
|
850
|
+
if (content !== this.wrapper) {
|
|
851
|
+
this.wrapper = content;
|
|
852
|
+
this.rebindDOMEvents();
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
ActionsHandler2.prototype.rebindDOMEvents = function() {
|
|
856
|
+
this.wrapperEventRegister.destroy();
|
|
857
|
+
this.targetEventRegister.destroy();
|
|
858
|
+
this.handleDOMEvents();
|
|
859
|
+
};
|
|
860
|
+
ActionsHandler2.prototype.destroy = function() {
|
|
861
|
+
this.wrapperEventRegister.destroy();
|
|
862
|
+
this.targetEventRegister.destroy();
|
|
863
|
+
this.hooks.destroy();
|
|
864
|
+
};
|
|
865
|
+
return ActionsHandler2;
|
|
866
|
+
})()
|
|
867
|
+
);
|
|
868
|
+
var translaterMetaData = {
|
|
869
|
+
x: ["translateX", "px"],
|
|
870
|
+
y: ["translateY", "px"]
|
|
871
|
+
};
|
|
872
|
+
var Translater = (
|
|
873
|
+
/** @class */
|
|
874
|
+
(function() {
|
|
875
|
+
function Translater2(content) {
|
|
876
|
+
this.setContent(content);
|
|
877
|
+
this.hooks = new EventEmitter(["beforeTranslate", "translate"]);
|
|
878
|
+
}
|
|
879
|
+
Translater2.prototype.getComputedPosition = function() {
|
|
880
|
+
var cssStyle = window.getComputedStyle(this.content, null);
|
|
881
|
+
var matrix = cssStyle[style.transform].split(")")[0].split(", ");
|
|
882
|
+
var x = +(matrix[12] || matrix[4]) || 0;
|
|
883
|
+
var y = +(matrix[13] || matrix[5]) || 0;
|
|
884
|
+
return {
|
|
885
|
+
x,
|
|
886
|
+
y
|
|
887
|
+
};
|
|
888
|
+
};
|
|
889
|
+
Translater2.prototype.translate = function(point) {
|
|
890
|
+
var transformStyle = [];
|
|
891
|
+
Object.keys(point).forEach(function(key) {
|
|
892
|
+
if (!translaterMetaData[key]) {
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
var transformFnName = translaterMetaData[key][0];
|
|
896
|
+
if (transformFnName) {
|
|
897
|
+
var transformFnArgUnit = translaterMetaData[key][1];
|
|
898
|
+
var transformFnArg = point[key];
|
|
899
|
+
transformStyle.push(transformFnName + "(" + transformFnArg + transformFnArgUnit + ")");
|
|
900
|
+
}
|
|
901
|
+
});
|
|
902
|
+
this.hooks.trigger(this.hooks.eventTypes.beforeTranslate, transformStyle, point);
|
|
903
|
+
this.style[style.transform] = transformStyle.join(" ");
|
|
904
|
+
this.hooks.trigger(this.hooks.eventTypes.translate, point);
|
|
905
|
+
};
|
|
906
|
+
Translater2.prototype.setContent = function(content) {
|
|
907
|
+
if (this.content !== content) {
|
|
908
|
+
this.content = content;
|
|
909
|
+
this.style = content.style;
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
Translater2.prototype.destroy = function() {
|
|
913
|
+
this.hooks.destroy();
|
|
914
|
+
};
|
|
915
|
+
return Translater2;
|
|
916
|
+
})()
|
|
917
|
+
);
|
|
918
|
+
var Base = (
|
|
919
|
+
/** @class */
|
|
920
|
+
(function() {
|
|
921
|
+
function Base2(content, translater, options) {
|
|
922
|
+
this.translater = translater;
|
|
923
|
+
this.options = options;
|
|
924
|
+
this.timer = 0;
|
|
925
|
+
this.hooks = new EventEmitter([
|
|
926
|
+
"move",
|
|
927
|
+
"end",
|
|
928
|
+
"beforeForceStop",
|
|
929
|
+
"forceStop",
|
|
930
|
+
"callStop",
|
|
931
|
+
"time",
|
|
932
|
+
"timeFunction"
|
|
933
|
+
]);
|
|
934
|
+
this.setContent(content);
|
|
935
|
+
}
|
|
936
|
+
Base2.prototype.translate = function(endPoint) {
|
|
937
|
+
this.translater.translate(endPoint);
|
|
938
|
+
};
|
|
939
|
+
Base2.prototype.setPending = function(pending) {
|
|
940
|
+
this.pending = pending;
|
|
941
|
+
};
|
|
942
|
+
Base2.prototype.setForceStopped = function(forceStopped) {
|
|
943
|
+
this.forceStopped = forceStopped;
|
|
944
|
+
};
|
|
945
|
+
Base2.prototype.setCallStop = function(called) {
|
|
946
|
+
this.callStopWhenPending = called;
|
|
947
|
+
};
|
|
948
|
+
Base2.prototype.setContent = function(content) {
|
|
949
|
+
if (this.content !== content) {
|
|
950
|
+
this.content = content;
|
|
951
|
+
this.style = content.style;
|
|
952
|
+
this.stop();
|
|
953
|
+
}
|
|
954
|
+
};
|
|
955
|
+
Base2.prototype.clearTimer = function() {
|
|
956
|
+
if (this.timer) {
|
|
957
|
+
cancelAnimationFrame(this.timer);
|
|
958
|
+
this.timer = 0;
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
Base2.prototype.destroy = function() {
|
|
962
|
+
this.hooks.destroy();
|
|
963
|
+
cancelAnimationFrame(this.timer);
|
|
964
|
+
};
|
|
965
|
+
return Base2;
|
|
966
|
+
})()
|
|
967
|
+
);
|
|
968
|
+
var isValidPostion = function(startPoint, endPoint, currentPos, prePos) {
|
|
969
|
+
var computeDirection = function(endValue, startValue) {
|
|
970
|
+
var delta = endValue - startValue;
|
|
971
|
+
var direction = delta > 0 ? -1 : delta < 0 ? 1 : 0;
|
|
972
|
+
return direction;
|
|
973
|
+
};
|
|
974
|
+
var directionX = computeDirection(endPoint.x, startPoint.x);
|
|
975
|
+
var directionY = computeDirection(endPoint.y, startPoint.y);
|
|
976
|
+
var deltaX = currentPos.x - prePos.x;
|
|
977
|
+
var deltaY = currentPos.y - prePos.y;
|
|
978
|
+
return directionX * deltaX <= 0 && directionY * deltaY <= 0;
|
|
979
|
+
};
|
|
980
|
+
var Transition = (
|
|
981
|
+
/** @class */
|
|
982
|
+
(function(_super) {
|
|
983
|
+
__extends(Transition2, _super);
|
|
984
|
+
function Transition2() {
|
|
985
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
986
|
+
}
|
|
987
|
+
Transition2.prototype.startProbe = function(startPoint, endPoint) {
|
|
988
|
+
var _this = this;
|
|
989
|
+
var prePos = startPoint;
|
|
990
|
+
var probe = function() {
|
|
991
|
+
var pos = _this.translater.getComputedPosition();
|
|
992
|
+
if (isValidPostion(startPoint, endPoint, pos, prePos)) {
|
|
993
|
+
_this.hooks.trigger(_this.hooks.eventTypes.move, pos);
|
|
994
|
+
}
|
|
995
|
+
if (!_this.pending) {
|
|
996
|
+
if (_this.callStopWhenPending) {
|
|
997
|
+
_this.callStopWhenPending = false;
|
|
998
|
+
} else {
|
|
999
|
+
_this.hooks.trigger(_this.hooks.eventTypes.end, pos);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
prePos = pos;
|
|
1003
|
+
if (_this.pending) {
|
|
1004
|
+
_this.timer = requestAnimationFrame(probe);
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
1007
|
+
if (this.callStopWhenPending) {
|
|
1008
|
+
this.setCallStop(false);
|
|
1009
|
+
}
|
|
1010
|
+
cancelAnimationFrame(this.timer);
|
|
1011
|
+
probe();
|
|
1012
|
+
};
|
|
1013
|
+
Transition2.prototype.transitionTime = function(time) {
|
|
1014
|
+
if (time === void 0) {
|
|
1015
|
+
time = 0;
|
|
1016
|
+
}
|
|
1017
|
+
this.style[style.transitionDuration] = time + "ms";
|
|
1018
|
+
this.hooks.trigger(this.hooks.eventTypes.time, time);
|
|
1019
|
+
};
|
|
1020
|
+
Transition2.prototype.transitionTimingFunction = function(easing) {
|
|
1021
|
+
this.style[style.transitionTimingFunction] = easing;
|
|
1022
|
+
this.hooks.trigger(this.hooks.eventTypes.timeFunction, easing);
|
|
1023
|
+
};
|
|
1024
|
+
Transition2.prototype.transitionProperty = function() {
|
|
1025
|
+
this.style[style.transitionProperty] = style.transform;
|
|
1026
|
+
};
|
|
1027
|
+
Transition2.prototype.move = function(startPoint, endPoint, time, easingFn) {
|
|
1028
|
+
this.setPending(time > 0);
|
|
1029
|
+
this.transitionTimingFunction(easingFn);
|
|
1030
|
+
this.transitionProperty();
|
|
1031
|
+
this.transitionTime(time);
|
|
1032
|
+
this.translate(endPoint);
|
|
1033
|
+
var isRealtimeProbeType = this.options.probeType === 3;
|
|
1034
|
+
if (time && isRealtimeProbeType) {
|
|
1035
|
+
this.startProbe(startPoint, endPoint);
|
|
1036
|
+
}
|
|
1037
|
+
if (!time) {
|
|
1038
|
+
this._reflow = this.content.offsetHeight;
|
|
1039
|
+
if (isRealtimeProbeType) {
|
|
1040
|
+
this.hooks.trigger(this.hooks.eventTypes.move, endPoint);
|
|
1041
|
+
}
|
|
1042
|
+
this.hooks.trigger(this.hooks.eventTypes.end, endPoint);
|
|
1043
|
+
}
|
|
1044
|
+
};
|
|
1045
|
+
Transition2.prototype.doStop = function() {
|
|
1046
|
+
var pending = this.pending;
|
|
1047
|
+
this.setForceStopped(false);
|
|
1048
|
+
this.setCallStop(false);
|
|
1049
|
+
if (pending) {
|
|
1050
|
+
this.setPending(false);
|
|
1051
|
+
cancelAnimationFrame(this.timer);
|
|
1052
|
+
var _a2 = this.translater.getComputedPosition(), x = _a2.x, y = _a2.y;
|
|
1053
|
+
this.transitionTime();
|
|
1054
|
+
this.translate({ x, y });
|
|
1055
|
+
this.setForceStopped(true);
|
|
1056
|
+
this.setCallStop(true);
|
|
1057
|
+
this.hooks.trigger(this.hooks.eventTypes.forceStop, { x, y });
|
|
1058
|
+
}
|
|
1059
|
+
return pending;
|
|
1060
|
+
};
|
|
1061
|
+
Transition2.prototype.stop = function() {
|
|
1062
|
+
var stopFromTransition = this.doStop();
|
|
1063
|
+
if (stopFromTransition) {
|
|
1064
|
+
this.hooks.trigger(this.hooks.eventTypes.callStop);
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
return Transition2;
|
|
1068
|
+
})(Base)
|
|
1069
|
+
);
|
|
1070
|
+
var Animation = (
|
|
1071
|
+
/** @class */
|
|
1072
|
+
(function(_super) {
|
|
1073
|
+
__extends(Animation2, _super);
|
|
1074
|
+
function Animation2() {
|
|
1075
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
1076
|
+
}
|
|
1077
|
+
Animation2.prototype.move = function(startPoint, endPoint, time, easingFn) {
|
|
1078
|
+
if (!time) {
|
|
1079
|
+
this.translate(endPoint);
|
|
1080
|
+
if (this.options.probeType === 3) {
|
|
1081
|
+
this.hooks.trigger(this.hooks.eventTypes.move, endPoint);
|
|
1082
|
+
}
|
|
1083
|
+
this.hooks.trigger(this.hooks.eventTypes.end, endPoint);
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
this.animate(startPoint, endPoint, time, easingFn);
|
|
1087
|
+
};
|
|
1088
|
+
Animation2.prototype.animate = function(startPoint, endPoint, duration, easingFn) {
|
|
1089
|
+
var _this = this;
|
|
1090
|
+
var startTime = getNow();
|
|
1091
|
+
var destTime = startTime + duration;
|
|
1092
|
+
var isRealtimeProbeType = this.options.probeType === 3;
|
|
1093
|
+
var step = function() {
|
|
1094
|
+
var now = getNow();
|
|
1095
|
+
if (now >= destTime) {
|
|
1096
|
+
_this.translate(endPoint);
|
|
1097
|
+
if (isRealtimeProbeType) {
|
|
1098
|
+
_this.hooks.trigger(_this.hooks.eventTypes.move, endPoint);
|
|
1099
|
+
}
|
|
1100
|
+
_this.hooks.trigger(_this.hooks.eventTypes.end, endPoint);
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
now = (now - startTime) / duration;
|
|
1104
|
+
var easing = easingFn(now);
|
|
1105
|
+
var newPoint = {};
|
|
1106
|
+
Object.keys(endPoint).forEach(function(key) {
|
|
1107
|
+
var startValue = startPoint[key];
|
|
1108
|
+
var endValue = endPoint[key];
|
|
1109
|
+
newPoint[key] = (endValue - startValue) * easing + startValue;
|
|
1110
|
+
});
|
|
1111
|
+
_this.translate(newPoint);
|
|
1112
|
+
if (isRealtimeProbeType) {
|
|
1113
|
+
_this.hooks.trigger(_this.hooks.eventTypes.move, newPoint);
|
|
1114
|
+
}
|
|
1115
|
+
if (_this.pending) {
|
|
1116
|
+
_this.timer = requestAnimationFrame(step);
|
|
1117
|
+
}
|
|
1118
|
+
if (!_this.pending) {
|
|
1119
|
+
if (_this.callStopWhenPending) {
|
|
1120
|
+
_this.callStopWhenPending = false;
|
|
1121
|
+
} else {
|
|
1122
|
+
_this.hooks.trigger(_this.hooks.eventTypes.end, endPoint);
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
};
|
|
1126
|
+
this.setPending(true);
|
|
1127
|
+
if (this.callStopWhenPending) {
|
|
1128
|
+
this.setCallStop(false);
|
|
1129
|
+
}
|
|
1130
|
+
cancelAnimationFrame(this.timer);
|
|
1131
|
+
step();
|
|
1132
|
+
};
|
|
1133
|
+
Animation2.prototype.doStop = function() {
|
|
1134
|
+
var pending = this.pending;
|
|
1135
|
+
this.setForceStopped(false);
|
|
1136
|
+
this.setCallStop(false);
|
|
1137
|
+
if (pending) {
|
|
1138
|
+
this.setPending(false);
|
|
1139
|
+
cancelAnimationFrame(this.timer);
|
|
1140
|
+
var pos = this.translater.getComputedPosition();
|
|
1141
|
+
this.setForceStopped(true);
|
|
1142
|
+
this.setCallStop(true);
|
|
1143
|
+
this.hooks.trigger(this.hooks.eventTypes.forceStop, pos);
|
|
1144
|
+
}
|
|
1145
|
+
return pending;
|
|
1146
|
+
};
|
|
1147
|
+
Animation2.prototype.stop = function() {
|
|
1148
|
+
var stopFromAnimation = this.doStop();
|
|
1149
|
+
if (stopFromAnimation) {
|
|
1150
|
+
this.hooks.trigger(this.hooks.eventTypes.callStop);
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
return Animation2;
|
|
1154
|
+
})(Base)
|
|
1155
|
+
);
|
|
1156
|
+
function createAnimater(element, translater, options) {
|
|
1157
|
+
var useTransition = options.useTransition;
|
|
1158
|
+
var animaterOptions = {};
|
|
1159
|
+
Object.defineProperty(animaterOptions, "probeType", {
|
|
1160
|
+
enumerable: true,
|
|
1161
|
+
configurable: false,
|
|
1162
|
+
get: function() {
|
|
1163
|
+
return options.probeType;
|
|
1164
|
+
}
|
|
1165
|
+
});
|
|
1166
|
+
if (useTransition) {
|
|
1167
|
+
return new Transition(element, translater, animaterOptions);
|
|
1168
|
+
} else {
|
|
1169
|
+
return new Animation(element, translater, animaterOptions);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
var Behavior = (
|
|
1173
|
+
/** @class */
|
|
1174
|
+
(function() {
|
|
1175
|
+
function Behavior2(wrapper, content, options) {
|
|
1176
|
+
this.wrapper = wrapper;
|
|
1177
|
+
this.options = options;
|
|
1178
|
+
this.hooks = new EventEmitter([
|
|
1179
|
+
"beforeComputeBoundary",
|
|
1180
|
+
"computeBoundary",
|
|
1181
|
+
"momentum",
|
|
1182
|
+
"end",
|
|
1183
|
+
"ignoreHasScroll"
|
|
1184
|
+
]);
|
|
1185
|
+
this.refresh(content);
|
|
1186
|
+
}
|
|
1187
|
+
Behavior2.prototype.start = function() {
|
|
1188
|
+
this.dist = 0;
|
|
1189
|
+
this.setMovingDirection(
|
|
1190
|
+
0
|
|
1191
|
+
/* Default */
|
|
1192
|
+
);
|
|
1193
|
+
this.setDirection(
|
|
1194
|
+
0
|
|
1195
|
+
/* Default */
|
|
1196
|
+
);
|
|
1197
|
+
};
|
|
1198
|
+
Behavior2.prototype.move = function(delta) {
|
|
1199
|
+
delta = this.hasScroll ? delta : 0;
|
|
1200
|
+
this.setMovingDirection(delta);
|
|
1201
|
+
return this.performDampingAlgorithm(delta, this.options.outOfBoundaryDampingFactor);
|
|
1202
|
+
};
|
|
1203
|
+
Behavior2.prototype.setMovingDirection = function(delta) {
|
|
1204
|
+
this.movingDirection = delta > 0 ? -1 : delta < 0 ? 1 : 0;
|
|
1205
|
+
};
|
|
1206
|
+
Behavior2.prototype.setDirection = function(delta) {
|
|
1207
|
+
this.direction = delta > 0 ? -1 : delta < 0 ? 1 : 0;
|
|
1208
|
+
};
|
|
1209
|
+
Behavior2.prototype.performDampingAlgorithm = function(delta, dampingFactor) {
|
|
1210
|
+
var newPos = this.currentPos + delta;
|
|
1211
|
+
if (newPos > this.minScrollPos || newPos < this.maxScrollPos) {
|
|
1212
|
+
if (newPos > this.minScrollPos && this.options.bounces[0] || newPos < this.maxScrollPos && this.options.bounces[1]) {
|
|
1213
|
+
newPos = this.currentPos + delta * dampingFactor;
|
|
1214
|
+
} else {
|
|
1215
|
+
newPos = newPos > this.minScrollPos ? this.minScrollPos : this.maxScrollPos;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
return newPos;
|
|
1219
|
+
};
|
|
1220
|
+
Behavior2.prototype.end = function(duration) {
|
|
1221
|
+
var momentumInfo = {
|
|
1222
|
+
duration: 0
|
|
1223
|
+
};
|
|
1224
|
+
var absDist = Math.abs(this.currentPos - this.startPos);
|
|
1225
|
+
if (this.options.momentum && duration < this.options.momentumLimitTime && absDist > this.options.momentumLimitDistance) {
|
|
1226
|
+
var wrapperSize = this.direction === -1 && this.options.bounces[0] || this.direction === 1 && this.options.bounces[1] ? this.wrapperSize : 0;
|
|
1227
|
+
momentumInfo = this.hasScroll ? this.momentum(this.currentPos, this.startPos, duration, this.maxScrollPos, this.minScrollPos, wrapperSize, this.options) : { destination: this.currentPos, duration: 0 };
|
|
1228
|
+
} else {
|
|
1229
|
+
this.hooks.trigger(this.hooks.eventTypes.end, momentumInfo);
|
|
1230
|
+
}
|
|
1231
|
+
return momentumInfo;
|
|
1232
|
+
};
|
|
1233
|
+
Behavior2.prototype.momentum = function(current, start, time, lowerMargin, upperMargin, wrapperSize, options) {
|
|
1234
|
+
if (options === void 0) {
|
|
1235
|
+
options = this.options;
|
|
1236
|
+
}
|
|
1237
|
+
var distance = current - start;
|
|
1238
|
+
var speed = Math.abs(distance) / time;
|
|
1239
|
+
var deceleration = options.deceleration, swipeBounceTime = options.swipeBounceTime, swipeTime = options.swipeTime;
|
|
1240
|
+
var duration = Math.min(swipeTime, speed * 2 / deceleration);
|
|
1241
|
+
var momentumData = {
|
|
1242
|
+
destination: current + speed * speed / deceleration * (distance < 0 ? -1 : 1),
|
|
1243
|
+
duration,
|
|
1244
|
+
rate: 15
|
|
1245
|
+
};
|
|
1246
|
+
this.hooks.trigger(this.hooks.eventTypes.momentum, momentumData, distance);
|
|
1247
|
+
if (momentumData.destination < lowerMargin) {
|
|
1248
|
+
momentumData.destination = wrapperSize ? Math.max(lowerMargin - wrapperSize / 4, lowerMargin - wrapperSize / momentumData.rate * speed) : lowerMargin;
|
|
1249
|
+
momentumData.duration = swipeBounceTime;
|
|
1250
|
+
} else if (momentumData.destination > upperMargin) {
|
|
1251
|
+
momentumData.destination = wrapperSize ? Math.min(upperMargin + wrapperSize / 4, upperMargin + wrapperSize / momentumData.rate * speed) : upperMargin;
|
|
1252
|
+
momentumData.duration = swipeBounceTime;
|
|
1253
|
+
}
|
|
1254
|
+
momentumData.destination = Math.round(momentumData.destination);
|
|
1255
|
+
return momentumData;
|
|
1256
|
+
};
|
|
1257
|
+
Behavior2.prototype.updateDirection = function() {
|
|
1258
|
+
var absDist = this.currentPos - this.absStartPos;
|
|
1259
|
+
this.setDirection(absDist);
|
|
1260
|
+
};
|
|
1261
|
+
Behavior2.prototype.refresh = function(content) {
|
|
1262
|
+
var _a2 = this.options.rect, size = _a2.size, position = _a2.position;
|
|
1263
|
+
var isWrapperStatic = window.getComputedStyle(this.wrapper, null).position === "static";
|
|
1264
|
+
var wrapperRect = getRect(this.wrapper);
|
|
1265
|
+
this.wrapperSize = this.wrapper[size === "width" ? "clientWidth" : "clientHeight"];
|
|
1266
|
+
this.setContent(content);
|
|
1267
|
+
var contentRect = getRect(this.content);
|
|
1268
|
+
this.contentSize = contentRect[size];
|
|
1269
|
+
this.relativeOffset = contentRect[position];
|
|
1270
|
+
if (isWrapperStatic) {
|
|
1271
|
+
this.relativeOffset -= wrapperRect[position];
|
|
1272
|
+
}
|
|
1273
|
+
this.computeBoundary();
|
|
1274
|
+
this.setDirection(
|
|
1275
|
+
0
|
|
1276
|
+
/* Default */
|
|
1277
|
+
);
|
|
1278
|
+
};
|
|
1279
|
+
Behavior2.prototype.setContent = function(content) {
|
|
1280
|
+
if (content !== this.content) {
|
|
1281
|
+
this.content = content;
|
|
1282
|
+
this.resetState();
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
Behavior2.prototype.resetState = function() {
|
|
1286
|
+
this.currentPos = 0;
|
|
1287
|
+
this.startPos = 0;
|
|
1288
|
+
this.dist = 0;
|
|
1289
|
+
this.setDirection(
|
|
1290
|
+
0
|
|
1291
|
+
/* Default */
|
|
1292
|
+
);
|
|
1293
|
+
this.setMovingDirection(
|
|
1294
|
+
0
|
|
1295
|
+
/* Default */
|
|
1296
|
+
);
|
|
1297
|
+
this.resetStartPos();
|
|
1298
|
+
};
|
|
1299
|
+
Behavior2.prototype.computeBoundary = function() {
|
|
1300
|
+
this.hooks.trigger(this.hooks.eventTypes.beforeComputeBoundary);
|
|
1301
|
+
var boundary = {
|
|
1302
|
+
minScrollPos: 0,
|
|
1303
|
+
maxScrollPos: this.wrapperSize - this.contentSize
|
|
1304
|
+
};
|
|
1305
|
+
if (boundary.maxScrollPos < 0) {
|
|
1306
|
+
boundary.maxScrollPos -= this.relativeOffset;
|
|
1307
|
+
if (this.options.specifiedIndexAsContent === 0) {
|
|
1308
|
+
boundary.minScrollPos = -this.relativeOffset;
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
this.hooks.trigger(this.hooks.eventTypes.computeBoundary, boundary);
|
|
1312
|
+
this.minScrollPos = boundary.minScrollPos;
|
|
1313
|
+
this.maxScrollPos = boundary.maxScrollPos;
|
|
1314
|
+
this.hasScroll = this.options.scrollable && this.maxScrollPos < this.minScrollPos;
|
|
1315
|
+
if (!this.hasScroll && this.minScrollPos < this.maxScrollPos) {
|
|
1316
|
+
this.maxScrollPos = this.minScrollPos;
|
|
1317
|
+
this.contentSize = this.wrapperSize;
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
Behavior2.prototype.updatePosition = function(pos) {
|
|
1321
|
+
this.currentPos = pos;
|
|
1322
|
+
};
|
|
1323
|
+
Behavior2.prototype.getCurrentPos = function() {
|
|
1324
|
+
return this.currentPos;
|
|
1325
|
+
};
|
|
1326
|
+
Behavior2.prototype.checkInBoundary = function() {
|
|
1327
|
+
var position = this.adjustPosition(this.currentPos);
|
|
1328
|
+
var inBoundary = position === this.getCurrentPos();
|
|
1329
|
+
return {
|
|
1330
|
+
position,
|
|
1331
|
+
inBoundary
|
|
1332
|
+
};
|
|
1333
|
+
};
|
|
1334
|
+
Behavior2.prototype.adjustPosition = function(pos) {
|
|
1335
|
+
if (!this.hasScroll && !this.hooks.trigger(this.hooks.eventTypes.ignoreHasScroll)) {
|
|
1336
|
+
pos = this.minScrollPos;
|
|
1337
|
+
} else if (pos > this.minScrollPos) {
|
|
1338
|
+
pos = this.minScrollPos;
|
|
1339
|
+
} else if (pos < this.maxScrollPos) {
|
|
1340
|
+
pos = this.maxScrollPos;
|
|
1341
|
+
}
|
|
1342
|
+
return pos;
|
|
1343
|
+
};
|
|
1344
|
+
Behavior2.prototype.updateStartPos = function() {
|
|
1345
|
+
this.startPos = this.currentPos;
|
|
1346
|
+
};
|
|
1347
|
+
Behavior2.prototype.updateAbsStartPos = function() {
|
|
1348
|
+
this.absStartPos = this.currentPos;
|
|
1349
|
+
};
|
|
1350
|
+
Behavior2.prototype.resetStartPos = function() {
|
|
1351
|
+
this.updateStartPos();
|
|
1352
|
+
this.updateAbsStartPos();
|
|
1353
|
+
};
|
|
1354
|
+
Behavior2.prototype.getAbsDist = function(delta) {
|
|
1355
|
+
this.dist += delta;
|
|
1356
|
+
return Math.abs(this.dist);
|
|
1357
|
+
};
|
|
1358
|
+
Behavior2.prototype.destroy = function() {
|
|
1359
|
+
this.hooks.destroy();
|
|
1360
|
+
};
|
|
1361
|
+
return Behavior2;
|
|
1362
|
+
})()
|
|
1363
|
+
);
|
|
1364
|
+
var _a, _b, _c, _d;
|
|
1365
|
+
var PassthroughHandlers = (_a = {}, _a[
|
|
1366
|
+
"yes"
|
|
1367
|
+
/* Yes */
|
|
1368
|
+
] = function(e) {
|
|
1369
|
+
return true;
|
|
1370
|
+
}, _a[
|
|
1371
|
+
"no"
|
|
1372
|
+
/* No */
|
|
1373
|
+
] = function(e) {
|
|
1374
|
+
maybePrevent(e);
|
|
1375
|
+
return false;
|
|
1376
|
+
}, _a);
|
|
1377
|
+
var DirectionMap = (_b = {}, _b[
|
|
1378
|
+
"horizontal"
|
|
1379
|
+
/* Horizontal */
|
|
1380
|
+
] = (_c = {}, _c[
|
|
1381
|
+
"yes"
|
|
1382
|
+
/* Yes */
|
|
1383
|
+
] = "horizontal", _c[
|
|
1384
|
+
"no"
|
|
1385
|
+
/* No */
|
|
1386
|
+
] = "vertical", _c), _b[
|
|
1387
|
+
"vertical"
|
|
1388
|
+
/* Vertical */
|
|
1389
|
+
] = (_d = {}, _d[
|
|
1390
|
+
"yes"
|
|
1391
|
+
/* Yes */
|
|
1392
|
+
] = "vertical", _d[
|
|
1393
|
+
"no"
|
|
1394
|
+
/* No */
|
|
1395
|
+
] = "horizontal", _d), _b);
|
|
1396
|
+
var DirectionLockAction = (
|
|
1397
|
+
/** @class */
|
|
1398
|
+
(function() {
|
|
1399
|
+
function DirectionLockAction2(directionLockThreshold, freeScroll, eventPassthrough) {
|
|
1400
|
+
this.directionLockThreshold = directionLockThreshold;
|
|
1401
|
+
this.freeScroll = freeScroll;
|
|
1402
|
+
this.eventPassthrough = eventPassthrough;
|
|
1403
|
+
this.reset();
|
|
1404
|
+
}
|
|
1405
|
+
DirectionLockAction2.prototype.reset = function() {
|
|
1406
|
+
this.directionLocked = "";
|
|
1407
|
+
};
|
|
1408
|
+
DirectionLockAction2.prototype.checkMovingDirection = function(absDistX, absDistY, e) {
|
|
1409
|
+
this.computeDirectionLock(absDistX, absDistY);
|
|
1410
|
+
return this.handleEventPassthrough(e);
|
|
1411
|
+
};
|
|
1412
|
+
DirectionLockAction2.prototype.adjustDelta = function(deltaX, deltaY) {
|
|
1413
|
+
if (this.directionLocked === "horizontal") {
|
|
1414
|
+
deltaY = 0;
|
|
1415
|
+
} else if (this.directionLocked === "vertical") {
|
|
1416
|
+
deltaX = 0;
|
|
1417
|
+
}
|
|
1418
|
+
return {
|
|
1419
|
+
deltaX,
|
|
1420
|
+
deltaY
|
|
1421
|
+
};
|
|
1422
|
+
};
|
|
1423
|
+
DirectionLockAction2.prototype.computeDirectionLock = function(absDistX, absDistY) {
|
|
1424
|
+
if (this.directionLocked === "" && !this.freeScroll) {
|
|
1425
|
+
if (absDistX > absDistY + this.directionLockThreshold) {
|
|
1426
|
+
this.directionLocked = "horizontal";
|
|
1427
|
+
} else if (absDistY >= absDistX + this.directionLockThreshold) {
|
|
1428
|
+
this.directionLocked = "vertical";
|
|
1429
|
+
} else {
|
|
1430
|
+
this.directionLocked = "none";
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
};
|
|
1434
|
+
DirectionLockAction2.prototype.handleEventPassthrough = function(e) {
|
|
1435
|
+
var handleMap = DirectionMap[this.directionLocked];
|
|
1436
|
+
if (handleMap) {
|
|
1437
|
+
if (this.eventPassthrough === handleMap[
|
|
1438
|
+
"yes"
|
|
1439
|
+
/* Yes */
|
|
1440
|
+
]) {
|
|
1441
|
+
return PassthroughHandlers[
|
|
1442
|
+
"yes"
|
|
1443
|
+
/* Yes */
|
|
1444
|
+
](e);
|
|
1445
|
+
} else if (this.eventPassthrough === handleMap[
|
|
1446
|
+
"no"
|
|
1447
|
+
/* No */
|
|
1448
|
+
]) {
|
|
1449
|
+
return PassthroughHandlers[
|
|
1450
|
+
"no"
|
|
1451
|
+
/* No */
|
|
1452
|
+
](e);
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
return false;
|
|
1456
|
+
};
|
|
1457
|
+
return DirectionLockAction2;
|
|
1458
|
+
})()
|
|
1459
|
+
);
|
|
1460
|
+
var applyQuadrantTransformation = function(deltaX, deltaY, quadrant) {
|
|
1461
|
+
if (quadrant === 2) {
|
|
1462
|
+
return [deltaY, -deltaX];
|
|
1463
|
+
} else if (quadrant === 3) {
|
|
1464
|
+
return [-deltaX, -deltaY];
|
|
1465
|
+
} else if (quadrant === 4) {
|
|
1466
|
+
return [-deltaY, deltaX];
|
|
1467
|
+
} else {
|
|
1468
|
+
return [deltaX, deltaY];
|
|
1469
|
+
}
|
|
1470
|
+
};
|
|
1471
|
+
var ScrollerActions = (
|
|
1472
|
+
/** @class */
|
|
1473
|
+
(function() {
|
|
1474
|
+
function ScrollerActions2(scrollBehaviorX, scrollBehaviorY, actionsHandler, animater, options) {
|
|
1475
|
+
this.hooks = new EventEmitter([
|
|
1476
|
+
"start",
|
|
1477
|
+
"beforeMove",
|
|
1478
|
+
"scrollStart",
|
|
1479
|
+
"scroll",
|
|
1480
|
+
"beforeEnd",
|
|
1481
|
+
"end",
|
|
1482
|
+
"scrollEnd",
|
|
1483
|
+
"contentNotMoved",
|
|
1484
|
+
"detectMovingDirection",
|
|
1485
|
+
"coordinateTransformation"
|
|
1486
|
+
]);
|
|
1487
|
+
this.scrollBehaviorX = scrollBehaviorX;
|
|
1488
|
+
this.scrollBehaviorY = scrollBehaviorY;
|
|
1489
|
+
this.actionsHandler = actionsHandler;
|
|
1490
|
+
this.animater = animater;
|
|
1491
|
+
this.options = options;
|
|
1492
|
+
this.directionLockAction = new DirectionLockAction(options.directionLockThreshold, options.freeScroll, options.eventPassthrough);
|
|
1493
|
+
this.enabled = true;
|
|
1494
|
+
this.bindActionsHandler();
|
|
1495
|
+
}
|
|
1496
|
+
ScrollerActions2.prototype.bindActionsHandler = function() {
|
|
1497
|
+
var _this = this;
|
|
1498
|
+
this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.start, function(e) {
|
|
1499
|
+
if (!_this.enabled)
|
|
1500
|
+
return true;
|
|
1501
|
+
return _this.handleStart(e);
|
|
1502
|
+
});
|
|
1503
|
+
this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.move, function(_a2) {
|
|
1504
|
+
var deltaX = _a2.deltaX, deltaY = _a2.deltaY, e = _a2.e;
|
|
1505
|
+
if (!_this.enabled)
|
|
1506
|
+
return true;
|
|
1507
|
+
var _b2 = applyQuadrantTransformation(deltaX, deltaY, _this.options.quadrant), transformateDeltaX = _b2[0], transformateDeltaY = _b2[1];
|
|
1508
|
+
var transformateDeltaData = {
|
|
1509
|
+
deltaX: transformateDeltaX,
|
|
1510
|
+
deltaY: transformateDeltaY
|
|
1511
|
+
};
|
|
1512
|
+
_this.hooks.trigger(_this.hooks.eventTypes.coordinateTransformation, transformateDeltaData);
|
|
1513
|
+
return _this.handleMove(transformateDeltaData.deltaX, transformateDeltaData.deltaY, e);
|
|
1514
|
+
});
|
|
1515
|
+
this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.end, function(e) {
|
|
1516
|
+
if (!_this.enabled)
|
|
1517
|
+
return true;
|
|
1518
|
+
return _this.handleEnd(e);
|
|
1519
|
+
});
|
|
1520
|
+
this.actionsHandler.hooks.on(this.actionsHandler.hooks.eventTypes.click, function(e) {
|
|
1521
|
+
if (_this.enabled && !e._constructed) {
|
|
1522
|
+
_this.handleClick(e);
|
|
1523
|
+
}
|
|
1524
|
+
});
|
|
1525
|
+
};
|
|
1526
|
+
ScrollerActions2.prototype.handleStart = function(e) {
|
|
1527
|
+
var timestamp = getNow();
|
|
1528
|
+
this.fingerMoved = false;
|
|
1529
|
+
this.contentMoved = false;
|
|
1530
|
+
this.startTime = timestamp;
|
|
1531
|
+
this.directionLockAction.reset();
|
|
1532
|
+
this.scrollBehaviorX.start();
|
|
1533
|
+
this.scrollBehaviorY.start();
|
|
1534
|
+
this.animater.doStop();
|
|
1535
|
+
this.scrollBehaviorX.resetStartPos();
|
|
1536
|
+
this.scrollBehaviorY.resetStartPos();
|
|
1537
|
+
this.hooks.trigger(this.hooks.eventTypes.start, e);
|
|
1538
|
+
};
|
|
1539
|
+
ScrollerActions2.prototype.handleMove = function(deltaX, deltaY, e) {
|
|
1540
|
+
if (this.hooks.trigger(this.hooks.eventTypes.beforeMove, e)) {
|
|
1541
|
+
return;
|
|
1542
|
+
}
|
|
1543
|
+
var absDistX = this.scrollBehaviorX.getAbsDist(deltaX);
|
|
1544
|
+
var absDistY = this.scrollBehaviorY.getAbsDist(deltaY);
|
|
1545
|
+
var timestamp = getNow();
|
|
1546
|
+
if (this.checkMomentum(absDistX, absDistY, timestamp)) {
|
|
1547
|
+
return true;
|
|
1548
|
+
}
|
|
1549
|
+
if (this.directionLockAction.checkMovingDirection(absDistX, absDistY, e)) {
|
|
1550
|
+
this.actionsHandler.setInitiated();
|
|
1551
|
+
return true;
|
|
1552
|
+
}
|
|
1553
|
+
var delta = this.directionLockAction.adjustDelta(deltaX, deltaY);
|
|
1554
|
+
var prevX = this.scrollBehaviorX.getCurrentPos();
|
|
1555
|
+
var newX = this.scrollBehaviorX.move(delta.deltaX);
|
|
1556
|
+
var prevY = this.scrollBehaviorY.getCurrentPos();
|
|
1557
|
+
var newY = this.scrollBehaviorY.move(delta.deltaY);
|
|
1558
|
+
if (this.hooks.trigger(this.hooks.eventTypes.detectMovingDirection)) {
|
|
1559
|
+
return;
|
|
1560
|
+
}
|
|
1561
|
+
if (!this.fingerMoved) {
|
|
1562
|
+
this.fingerMoved = true;
|
|
1563
|
+
}
|
|
1564
|
+
var positionChanged = newX !== prevX || newY !== prevY;
|
|
1565
|
+
if (!this.contentMoved && !positionChanged) {
|
|
1566
|
+
this.hooks.trigger(this.hooks.eventTypes.contentNotMoved);
|
|
1567
|
+
}
|
|
1568
|
+
if (!this.contentMoved && positionChanged) {
|
|
1569
|
+
this.contentMoved = true;
|
|
1570
|
+
this.hooks.trigger(this.hooks.eventTypes.scrollStart);
|
|
1571
|
+
}
|
|
1572
|
+
if (this.contentMoved && positionChanged) {
|
|
1573
|
+
this.animater.translate({
|
|
1574
|
+
x: newX,
|
|
1575
|
+
y: newY
|
|
1576
|
+
});
|
|
1577
|
+
this.dispatchScroll(timestamp);
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
ScrollerActions2.prototype.dispatchScroll = function(timestamp) {
|
|
1581
|
+
if (timestamp - this.startTime > this.options.momentumLimitTime) {
|
|
1582
|
+
this.startTime = timestamp;
|
|
1583
|
+
this.scrollBehaviorX.updateStartPos();
|
|
1584
|
+
this.scrollBehaviorY.updateStartPos();
|
|
1585
|
+
if (this.options.probeType === 1) {
|
|
1586
|
+
this.hooks.trigger(this.hooks.eventTypes.scroll, this.getCurrentPos());
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
if (this.options.probeType > 1) {
|
|
1590
|
+
this.hooks.trigger(this.hooks.eventTypes.scroll, this.getCurrentPos());
|
|
1591
|
+
}
|
|
1592
|
+
};
|
|
1593
|
+
ScrollerActions2.prototype.checkMomentum = function(absDistX, absDistY, timestamp) {
|
|
1594
|
+
return timestamp - this.endTime > this.options.momentumLimitTime && absDistY < this.options.momentumLimitDistance && absDistX < this.options.momentumLimitDistance;
|
|
1595
|
+
};
|
|
1596
|
+
ScrollerActions2.prototype.handleEnd = function(e) {
|
|
1597
|
+
if (this.hooks.trigger(this.hooks.eventTypes.beforeEnd, e)) {
|
|
1598
|
+
return;
|
|
1599
|
+
}
|
|
1600
|
+
var currentPos = this.getCurrentPos();
|
|
1601
|
+
this.scrollBehaviorX.updateDirection();
|
|
1602
|
+
this.scrollBehaviorY.updateDirection();
|
|
1603
|
+
if (this.hooks.trigger(this.hooks.eventTypes.end, e, currentPos)) {
|
|
1604
|
+
return true;
|
|
1605
|
+
}
|
|
1606
|
+
currentPos = this.ensureIntegerPos(currentPos);
|
|
1607
|
+
this.animater.translate(currentPos);
|
|
1608
|
+
this.endTime = getNow();
|
|
1609
|
+
var duration = this.endTime - this.startTime;
|
|
1610
|
+
this.hooks.trigger(this.hooks.eventTypes.scrollEnd, currentPos, duration);
|
|
1611
|
+
};
|
|
1612
|
+
ScrollerActions2.prototype.ensureIntegerPos = function(currentPos) {
|
|
1613
|
+
this.ensuringInteger = true;
|
|
1614
|
+
var x = currentPos.x, y = currentPos.y;
|
|
1615
|
+
var _a2 = this.scrollBehaviorX, minScrollPosX = _a2.minScrollPos, maxScrollPosX = _a2.maxScrollPos;
|
|
1616
|
+
var _b2 = this.scrollBehaviorY, minScrollPosY = _b2.minScrollPos, maxScrollPosY = _b2.maxScrollPos;
|
|
1617
|
+
x = x > 0 ? Math.ceil(x) : Math.floor(x);
|
|
1618
|
+
y = y > 0 ? Math.ceil(y) : Math.floor(y);
|
|
1619
|
+
x = between(x, maxScrollPosX, minScrollPosX);
|
|
1620
|
+
y = between(y, maxScrollPosY, minScrollPosY);
|
|
1621
|
+
return { x, y };
|
|
1622
|
+
};
|
|
1623
|
+
ScrollerActions2.prototype.handleClick = function(e) {
|
|
1624
|
+
if (!preventDefaultExceptionFn(e.target, this.options.preventDefaultException)) {
|
|
1625
|
+
maybePrevent(e);
|
|
1626
|
+
e.stopPropagation();
|
|
1627
|
+
}
|
|
1628
|
+
};
|
|
1629
|
+
ScrollerActions2.prototype.getCurrentPos = function() {
|
|
1630
|
+
return {
|
|
1631
|
+
x: this.scrollBehaviorX.getCurrentPos(),
|
|
1632
|
+
y: this.scrollBehaviorY.getCurrentPos()
|
|
1633
|
+
};
|
|
1634
|
+
};
|
|
1635
|
+
ScrollerActions2.prototype.refresh = function() {
|
|
1636
|
+
this.endTime = 0;
|
|
1637
|
+
};
|
|
1638
|
+
ScrollerActions2.prototype.destroy = function() {
|
|
1639
|
+
this.hooks.destroy();
|
|
1640
|
+
};
|
|
1641
|
+
return ScrollerActions2;
|
|
1642
|
+
})()
|
|
1643
|
+
);
|
|
1644
|
+
function createActionsHandlerOptions(bsOptions) {
|
|
1645
|
+
var options = [
|
|
1646
|
+
"click",
|
|
1647
|
+
"bindToWrapper",
|
|
1648
|
+
"disableMouse",
|
|
1649
|
+
"disableTouch",
|
|
1650
|
+
"preventDefault",
|
|
1651
|
+
"stopPropagation",
|
|
1652
|
+
"tagException",
|
|
1653
|
+
"preventDefaultException",
|
|
1654
|
+
"autoEndDistance"
|
|
1655
|
+
].reduce(function(prev, cur) {
|
|
1656
|
+
prev[cur] = bsOptions[cur];
|
|
1657
|
+
return prev;
|
|
1658
|
+
}, {});
|
|
1659
|
+
return options;
|
|
1660
|
+
}
|
|
1661
|
+
function createBehaviorOptions(bsOptions, extraProp, bounces, rect) {
|
|
1662
|
+
var options = [
|
|
1663
|
+
"momentum",
|
|
1664
|
+
"momentumLimitTime",
|
|
1665
|
+
"momentumLimitDistance",
|
|
1666
|
+
"deceleration",
|
|
1667
|
+
"swipeBounceTime",
|
|
1668
|
+
"swipeTime",
|
|
1669
|
+
"outOfBoundaryDampingFactor",
|
|
1670
|
+
"specifiedIndexAsContent"
|
|
1671
|
+
].reduce(function(prev, cur) {
|
|
1672
|
+
prev[cur] = bsOptions[cur];
|
|
1673
|
+
return prev;
|
|
1674
|
+
}, {});
|
|
1675
|
+
options.scrollable = !!bsOptions[extraProp];
|
|
1676
|
+
options.bounces = bounces;
|
|
1677
|
+
options.rect = rect;
|
|
1678
|
+
return options;
|
|
1679
|
+
}
|
|
1680
|
+
function bubbling(source, target, events) {
|
|
1681
|
+
events.forEach(function(event) {
|
|
1682
|
+
var sourceEvent;
|
|
1683
|
+
var targetEvent;
|
|
1684
|
+
if (typeof event === "string") {
|
|
1685
|
+
sourceEvent = targetEvent = event;
|
|
1686
|
+
} else {
|
|
1687
|
+
sourceEvent = event.source;
|
|
1688
|
+
targetEvent = event.target;
|
|
1689
|
+
}
|
|
1690
|
+
source.on(sourceEvent, function() {
|
|
1691
|
+
var args = [];
|
|
1692
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1693
|
+
args[_i] = arguments[_i];
|
|
1694
|
+
}
|
|
1695
|
+
return target.trigger.apply(target, __spreadArrays([targetEvent], args));
|
|
1696
|
+
});
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1699
|
+
function isSamePoint(startPoint, endPoint) {
|
|
1700
|
+
var keys = Object.keys(startPoint);
|
|
1701
|
+
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
1702
|
+
var key = keys_1[_i];
|
|
1703
|
+
if (startPoint[key] !== endPoint[key])
|
|
1704
|
+
return false;
|
|
1705
|
+
}
|
|
1706
|
+
return true;
|
|
1707
|
+
}
|
|
1708
|
+
var MIN_SCROLL_DISTANCE = 1;
|
|
1709
|
+
var Scroller = (
|
|
1710
|
+
/** @class */
|
|
1711
|
+
(function() {
|
|
1712
|
+
function Scroller2(wrapper, content, options) {
|
|
1713
|
+
this.wrapper = wrapper;
|
|
1714
|
+
this.content = content;
|
|
1715
|
+
this.resizeTimeout = 0;
|
|
1716
|
+
this.hooks = new EventEmitter([
|
|
1717
|
+
"beforeStart",
|
|
1718
|
+
"beforeMove",
|
|
1719
|
+
"beforeScrollStart",
|
|
1720
|
+
"scrollStart",
|
|
1721
|
+
"scroll",
|
|
1722
|
+
"beforeEnd",
|
|
1723
|
+
"scrollEnd",
|
|
1724
|
+
"resize",
|
|
1725
|
+
"touchEnd",
|
|
1726
|
+
"end",
|
|
1727
|
+
"flick",
|
|
1728
|
+
"scrollCancel",
|
|
1729
|
+
"momentum",
|
|
1730
|
+
"scrollTo",
|
|
1731
|
+
"minDistanceScroll",
|
|
1732
|
+
"scrollToElement",
|
|
1733
|
+
"beforeRefresh"
|
|
1734
|
+
]);
|
|
1735
|
+
this.options = options;
|
|
1736
|
+
var _a2 = this.options.bounce, left = _a2.left, right = _a2.right, top = _a2.top, bottom = _a2.bottom;
|
|
1737
|
+
this.scrollBehaviorX = new Behavior(wrapper, content, createBehaviorOptions(options, "scrollX", [left, right], {
|
|
1738
|
+
size: "width",
|
|
1739
|
+
position: "left"
|
|
1740
|
+
}));
|
|
1741
|
+
this.scrollBehaviorY = new Behavior(wrapper, content, createBehaviorOptions(options, "scrollY", [top, bottom], {
|
|
1742
|
+
size: "height",
|
|
1743
|
+
position: "top"
|
|
1744
|
+
}));
|
|
1745
|
+
this.translater = new Translater(this.content);
|
|
1746
|
+
this.animater = createAnimater(this.content, this.translater, this.options);
|
|
1747
|
+
this.actionsHandler = new ActionsHandler(this.options.bindToTarget ? this.content : wrapper, createActionsHandlerOptions(this.options));
|
|
1748
|
+
this.actions = new ScrollerActions(this.scrollBehaviorX, this.scrollBehaviorY, this.actionsHandler, this.animater, this.options);
|
|
1749
|
+
var resizeHandler = this.resize.bind(this);
|
|
1750
|
+
this.resizeRegister = new EventRegister(window, [
|
|
1751
|
+
{
|
|
1752
|
+
name: "orientationchange",
|
|
1753
|
+
handler: resizeHandler
|
|
1754
|
+
},
|
|
1755
|
+
{
|
|
1756
|
+
name: "resize",
|
|
1757
|
+
handler: resizeHandler
|
|
1758
|
+
}
|
|
1759
|
+
]);
|
|
1760
|
+
this.registerTransitionEnd();
|
|
1761
|
+
this.init();
|
|
1762
|
+
}
|
|
1763
|
+
Scroller2.prototype.init = function() {
|
|
1764
|
+
var _this = this;
|
|
1765
|
+
this.bindTranslater();
|
|
1766
|
+
this.bindAnimater();
|
|
1767
|
+
this.bindActions();
|
|
1768
|
+
this.hooks.on(this.hooks.eventTypes.scrollEnd, function() {
|
|
1769
|
+
_this.togglePointerEvents(true);
|
|
1770
|
+
});
|
|
1771
|
+
};
|
|
1772
|
+
Scroller2.prototype.registerTransitionEnd = function() {
|
|
1773
|
+
this.transitionEndRegister = new EventRegister(this.content, [
|
|
1774
|
+
{
|
|
1775
|
+
name: style.transitionEnd,
|
|
1776
|
+
handler: this.transitionEnd.bind(this)
|
|
1777
|
+
}
|
|
1778
|
+
]);
|
|
1779
|
+
};
|
|
1780
|
+
Scroller2.prototype.bindTranslater = function() {
|
|
1781
|
+
var _this = this;
|
|
1782
|
+
var hooks = this.translater.hooks;
|
|
1783
|
+
hooks.on(hooks.eventTypes.beforeTranslate, function(transformStyle) {
|
|
1784
|
+
if (_this.options.translateZ) {
|
|
1785
|
+
transformStyle.push(_this.options.translateZ);
|
|
1786
|
+
}
|
|
1787
|
+
});
|
|
1788
|
+
hooks.on(hooks.eventTypes.translate, function(pos) {
|
|
1789
|
+
var prevPos = _this.getCurrentPos();
|
|
1790
|
+
_this.updatePositions(pos);
|
|
1791
|
+
if (_this.actions.ensuringInteger === true) {
|
|
1792
|
+
_this.actions.ensuringInteger = false;
|
|
1793
|
+
return;
|
|
1794
|
+
}
|
|
1795
|
+
if (pos.x !== prevPos.x || pos.y !== prevPos.y) {
|
|
1796
|
+
_this.togglePointerEvents(false);
|
|
1797
|
+
}
|
|
1798
|
+
});
|
|
1799
|
+
};
|
|
1800
|
+
Scroller2.prototype.bindAnimater = function() {
|
|
1801
|
+
var _this = this;
|
|
1802
|
+
this.animater.hooks.on(this.animater.hooks.eventTypes.end, function(pos) {
|
|
1803
|
+
if (!_this.resetPosition(_this.options.bounceTime)) {
|
|
1804
|
+
_this.animater.setPending(false);
|
|
1805
|
+
_this.hooks.trigger(_this.hooks.eventTypes.scrollEnd, pos);
|
|
1806
|
+
}
|
|
1807
|
+
});
|
|
1808
|
+
bubbling(this.animater.hooks, this.hooks, [
|
|
1809
|
+
{
|
|
1810
|
+
source: this.animater.hooks.eventTypes.move,
|
|
1811
|
+
target: this.hooks.eventTypes.scroll
|
|
1812
|
+
},
|
|
1813
|
+
{
|
|
1814
|
+
source: this.animater.hooks.eventTypes.forceStop,
|
|
1815
|
+
target: this.hooks.eventTypes.scrollEnd
|
|
1816
|
+
}
|
|
1817
|
+
]);
|
|
1818
|
+
};
|
|
1819
|
+
Scroller2.prototype.bindActions = function() {
|
|
1820
|
+
var _this = this;
|
|
1821
|
+
var actions = this.actions;
|
|
1822
|
+
bubbling(actions.hooks, this.hooks, [
|
|
1823
|
+
{
|
|
1824
|
+
source: actions.hooks.eventTypes.start,
|
|
1825
|
+
target: this.hooks.eventTypes.beforeStart
|
|
1826
|
+
},
|
|
1827
|
+
{
|
|
1828
|
+
source: actions.hooks.eventTypes.start,
|
|
1829
|
+
target: this.hooks.eventTypes.beforeScrollStart
|
|
1830
|
+
},
|
|
1831
|
+
{
|
|
1832
|
+
source: actions.hooks.eventTypes.beforeMove,
|
|
1833
|
+
target: this.hooks.eventTypes.beforeMove
|
|
1834
|
+
},
|
|
1835
|
+
{
|
|
1836
|
+
source: actions.hooks.eventTypes.scrollStart,
|
|
1837
|
+
target: this.hooks.eventTypes.scrollStart
|
|
1838
|
+
},
|
|
1839
|
+
{
|
|
1840
|
+
source: actions.hooks.eventTypes.scroll,
|
|
1841
|
+
target: this.hooks.eventTypes.scroll
|
|
1842
|
+
},
|
|
1843
|
+
{
|
|
1844
|
+
source: actions.hooks.eventTypes.beforeEnd,
|
|
1845
|
+
target: this.hooks.eventTypes.beforeEnd
|
|
1846
|
+
}
|
|
1847
|
+
]);
|
|
1848
|
+
actions.hooks.on(actions.hooks.eventTypes.end, function(e, pos) {
|
|
1849
|
+
_this.hooks.trigger(_this.hooks.eventTypes.touchEnd, pos);
|
|
1850
|
+
if (_this.hooks.trigger(_this.hooks.eventTypes.end, pos)) {
|
|
1851
|
+
return true;
|
|
1852
|
+
}
|
|
1853
|
+
if (!actions.fingerMoved) {
|
|
1854
|
+
_this.hooks.trigger(_this.hooks.eventTypes.scrollCancel);
|
|
1855
|
+
if (_this.checkClick(e)) {
|
|
1856
|
+
return true;
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
if (_this.resetPosition(_this.options.bounceTime, ease.bounce)) {
|
|
1860
|
+
_this.animater.setForceStopped(false);
|
|
1861
|
+
return true;
|
|
1862
|
+
}
|
|
1863
|
+
});
|
|
1864
|
+
actions.hooks.on(actions.hooks.eventTypes.scrollEnd, function(pos, duration) {
|
|
1865
|
+
var deltaX = Math.abs(pos.x - _this.scrollBehaviorX.startPos);
|
|
1866
|
+
var deltaY = Math.abs(pos.y - _this.scrollBehaviorY.startPos);
|
|
1867
|
+
if (_this.checkFlick(duration, deltaX, deltaY)) {
|
|
1868
|
+
_this.animater.setForceStopped(false);
|
|
1869
|
+
_this.hooks.trigger(_this.hooks.eventTypes.flick);
|
|
1870
|
+
return;
|
|
1871
|
+
}
|
|
1872
|
+
if (_this.momentum(pos, duration)) {
|
|
1873
|
+
_this.animater.setForceStopped(false);
|
|
1874
|
+
return;
|
|
1875
|
+
}
|
|
1876
|
+
if (actions.contentMoved) {
|
|
1877
|
+
_this.hooks.trigger(_this.hooks.eventTypes.scrollEnd, pos);
|
|
1878
|
+
}
|
|
1879
|
+
if (_this.animater.forceStopped) {
|
|
1880
|
+
_this.animater.setForceStopped(false);
|
|
1881
|
+
}
|
|
1882
|
+
});
|
|
1883
|
+
};
|
|
1884
|
+
Scroller2.prototype.checkFlick = function(duration, deltaX, deltaY) {
|
|
1885
|
+
var flickMinMovingDistance = 1;
|
|
1886
|
+
if (this.hooks.events.flick.length > 1 && duration < this.options.flickLimitTime && deltaX < this.options.flickLimitDistance && deltaY < this.options.flickLimitDistance && (deltaY > flickMinMovingDistance || deltaX > flickMinMovingDistance)) {
|
|
1887
|
+
return true;
|
|
1888
|
+
}
|
|
1889
|
+
};
|
|
1890
|
+
Scroller2.prototype.momentum = function(pos, duration) {
|
|
1891
|
+
var meta = {
|
|
1892
|
+
time: 0,
|
|
1893
|
+
easing: ease.swiper,
|
|
1894
|
+
newX: pos.x,
|
|
1895
|
+
newY: pos.y
|
|
1896
|
+
};
|
|
1897
|
+
var momentumX = this.scrollBehaviorX.end(duration);
|
|
1898
|
+
var momentumY = this.scrollBehaviorY.end(duration);
|
|
1899
|
+
meta.newX = isUndef(momentumX.destination) ? meta.newX : momentumX.destination;
|
|
1900
|
+
meta.newY = isUndef(momentumY.destination) ? meta.newY : momentumY.destination;
|
|
1901
|
+
meta.time = Math.max(momentumX.duration, momentumY.duration);
|
|
1902
|
+
this.hooks.trigger(this.hooks.eventTypes.momentum, meta, this);
|
|
1903
|
+
if (meta.newX !== pos.x || meta.newY !== pos.y) {
|
|
1904
|
+
if (meta.newX > this.scrollBehaviorX.minScrollPos || meta.newX < this.scrollBehaviorX.maxScrollPos || meta.newY > this.scrollBehaviorY.minScrollPos || meta.newY < this.scrollBehaviorY.maxScrollPos) {
|
|
1905
|
+
meta.easing = ease.swipeBounce;
|
|
1906
|
+
}
|
|
1907
|
+
this.scrollTo(meta.newX, meta.newY, meta.time, meta.easing);
|
|
1908
|
+
return true;
|
|
1909
|
+
}
|
|
1910
|
+
};
|
|
1911
|
+
Scroller2.prototype.checkClick = function(e) {
|
|
1912
|
+
var cancelable = {
|
|
1913
|
+
preventClick: this.animater.forceStopped
|
|
1914
|
+
};
|
|
1915
|
+
if (this.hooks.trigger(this.hooks.eventTypes.checkClick)) {
|
|
1916
|
+
this.animater.setForceStopped(false);
|
|
1917
|
+
return true;
|
|
1918
|
+
}
|
|
1919
|
+
if (!cancelable.preventClick) {
|
|
1920
|
+
var _dblclick = this.options.dblclick;
|
|
1921
|
+
var dblclickTrigged = false;
|
|
1922
|
+
if (_dblclick && this.lastClickTime) {
|
|
1923
|
+
var _a2 = _dblclick.delay, delay = _a2 === void 0 ? 300 : _a2;
|
|
1924
|
+
if (getNow() - this.lastClickTime < delay) {
|
|
1925
|
+
dblclickTrigged = true;
|
|
1926
|
+
dblclick(e);
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
if (this.options.tap) {
|
|
1930
|
+
tap(e, this.options.tap);
|
|
1931
|
+
}
|
|
1932
|
+
if (this.options.click && !preventDefaultExceptionFn(e.target, this.options.preventDefaultException)) {
|
|
1933
|
+
click(e);
|
|
1934
|
+
}
|
|
1935
|
+
this.lastClickTime = dblclickTrigged ? null : getNow();
|
|
1936
|
+
return true;
|
|
1937
|
+
}
|
|
1938
|
+
return false;
|
|
1939
|
+
};
|
|
1940
|
+
Scroller2.prototype.resize = function() {
|
|
1941
|
+
var _this = this;
|
|
1942
|
+
if (!this.actions.enabled) {
|
|
1943
|
+
return;
|
|
1944
|
+
}
|
|
1945
|
+
if (isAndroid) {
|
|
1946
|
+
this.wrapper.scrollTop = 0;
|
|
1947
|
+
}
|
|
1948
|
+
clearTimeout(this.resizeTimeout);
|
|
1949
|
+
this.resizeTimeout = window.setTimeout(function() {
|
|
1950
|
+
_this.hooks.trigger(_this.hooks.eventTypes.resize);
|
|
1951
|
+
}, this.options.resizePolling);
|
|
1952
|
+
};
|
|
1953
|
+
Scroller2.prototype.transitionEnd = function(e) {
|
|
1954
|
+
if (e.target !== this.content || !this.animater.pending) {
|
|
1955
|
+
return;
|
|
1956
|
+
}
|
|
1957
|
+
var animater = this.animater;
|
|
1958
|
+
animater.transitionTime();
|
|
1959
|
+
if (!this.resetPosition(this.options.bounceTime, ease.bounce)) {
|
|
1960
|
+
this.animater.setPending(false);
|
|
1961
|
+
if (this.options.probeType !== 3) {
|
|
1962
|
+
this.hooks.trigger(this.hooks.eventTypes.scrollEnd, this.getCurrentPos());
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
};
|
|
1966
|
+
Scroller2.prototype.togglePointerEvents = function(enabled) {
|
|
1967
|
+
if (enabled === void 0) {
|
|
1968
|
+
enabled = true;
|
|
1969
|
+
}
|
|
1970
|
+
var el = this.content.children.length ? this.content.children : [this.content];
|
|
1971
|
+
var pointerEvents = enabled ? "auto" : "none";
|
|
1972
|
+
for (var i = 0; i < el.length; i++) {
|
|
1973
|
+
var node = el[i];
|
|
1974
|
+
if (node.isBScrollContainer) {
|
|
1975
|
+
continue;
|
|
1976
|
+
}
|
|
1977
|
+
node.style.pointerEvents = pointerEvents;
|
|
1978
|
+
}
|
|
1979
|
+
};
|
|
1980
|
+
Scroller2.prototype.refresh = function(content) {
|
|
1981
|
+
var contentChanged = this.setContent(content);
|
|
1982
|
+
this.hooks.trigger(this.hooks.eventTypes.beforeRefresh);
|
|
1983
|
+
this.scrollBehaviorX.refresh(content);
|
|
1984
|
+
this.scrollBehaviorY.refresh(content);
|
|
1985
|
+
if (contentChanged) {
|
|
1986
|
+
this.translater.setContent(content);
|
|
1987
|
+
this.animater.setContent(content);
|
|
1988
|
+
this.transitionEndRegister.destroy();
|
|
1989
|
+
this.registerTransitionEnd();
|
|
1990
|
+
if (this.options.bindToTarget) {
|
|
1991
|
+
this.actionsHandler.setContent(content);
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
this.actions.refresh();
|
|
1995
|
+
this.wrapperOffset = offset(this.wrapper);
|
|
1996
|
+
};
|
|
1997
|
+
Scroller2.prototype.setContent = function(content) {
|
|
1998
|
+
var contentChanged = content !== this.content;
|
|
1999
|
+
if (contentChanged) {
|
|
2000
|
+
this.content = content;
|
|
2001
|
+
}
|
|
2002
|
+
return contentChanged;
|
|
2003
|
+
};
|
|
2004
|
+
Scroller2.prototype.scrollBy = function(deltaX, deltaY, time, easing) {
|
|
2005
|
+
if (time === void 0) {
|
|
2006
|
+
time = 0;
|
|
2007
|
+
}
|
|
2008
|
+
var _a2 = this.getCurrentPos(), x = _a2.x, y = _a2.y;
|
|
2009
|
+
easing = !easing ? ease.bounce : easing;
|
|
2010
|
+
deltaX += x;
|
|
2011
|
+
deltaY += y;
|
|
2012
|
+
this.scrollTo(deltaX, deltaY, time, easing);
|
|
2013
|
+
};
|
|
2014
|
+
Scroller2.prototype.scrollTo = function(x, y, time, easing, extraTransform) {
|
|
2015
|
+
if (time === void 0) {
|
|
2016
|
+
time = 0;
|
|
2017
|
+
}
|
|
2018
|
+
if (easing === void 0) {
|
|
2019
|
+
easing = ease.bounce;
|
|
2020
|
+
}
|
|
2021
|
+
if (extraTransform === void 0) {
|
|
2022
|
+
extraTransform = {
|
|
2023
|
+
start: {},
|
|
2024
|
+
end: {}
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
var easingFn = this.options.useTransition ? easing.style : easing.fn;
|
|
2028
|
+
var currentPos = this.getCurrentPos();
|
|
2029
|
+
var startPoint = __assign({ x: currentPos.x, y: currentPos.y }, extraTransform.start);
|
|
2030
|
+
var endPoint = __assign({
|
|
2031
|
+
x,
|
|
2032
|
+
y
|
|
2033
|
+
}, extraTransform.end);
|
|
2034
|
+
this.hooks.trigger(this.hooks.eventTypes.scrollTo, endPoint);
|
|
2035
|
+
if (isSamePoint(startPoint, endPoint))
|
|
2036
|
+
return;
|
|
2037
|
+
var deltaX = Math.abs(endPoint.x - startPoint.x);
|
|
2038
|
+
var deltaY = Math.abs(endPoint.y - startPoint.y);
|
|
2039
|
+
if (deltaX < MIN_SCROLL_DISTANCE && deltaY < MIN_SCROLL_DISTANCE) {
|
|
2040
|
+
time = 0;
|
|
2041
|
+
this.hooks.trigger(this.hooks.eventTypes.minDistanceScroll);
|
|
2042
|
+
}
|
|
2043
|
+
this.animater.move(startPoint, endPoint, time, easingFn);
|
|
2044
|
+
};
|
|
2045
|
+
Scroller2.prototype.scrollToElement = function(el, time, offsetX, offsetY, easing) {
|
|
2046
|
+
var targetEle = getElement(el);
|
|
2047
|
+
var pos = offset(targetEle);
|
|
2048
|
+
var getOffset = function(offset2, size, wrapperSize) {
|
|
2049
|
+
if (typeof offset2 === "number") {
|
|
2050
|
+
return offset2;
|
|
2051
|
+
}
|
|
2052
|
+
return offset2 ? Math.round(size / 2 - wrapperSize / 2) : 0;
|
|
2053
|
+
};
|
|
2054
|
+
offsetX = getOffset(offsetX, targetEle.offsetWidth, this.wrapper.offsetWidth);
|
|
2055
|
+
offsetY = getOffset(offsetY, targetEle.offsetHeight, this.wrapper.offsetHeight);
|
|
2056
|
+
var getPos = function(pos2, wrapperPos, offset2, scrollBehavior) {
|
|
2057
|
+
pos2 -= wrapperPos;
|
|
2058
|
+
pos2 = scrollBehavior.adjustPosition(pos2 - offset2);
|
|
2059
|
+
return pos2;
|
|
2060
|
+
};
|
|
2061
|
+
pos.left = getPos(pos.left, this.wrapperOffset.left, offsetX, this.scrollBehaviorX);
|
|
2062
|
+
pos.top = getPos(pos.top, this.wrapperOffset.top, offsetY, this.scrollBehaviorY);
|
|
2063
|
+
if (this.hooks.trigger(this.hooks.eventTypes.scrollToElement, targetEle, pos)) {
|
|
2064
|
+
return;
|
|
2065
|
+
}
|
|
2066
|
+
this.scrollTo(pos.left, pos.top, time, easing);
|
|
2067
|
+
};
|
|
2068
|
+
Scroller2.prototype.resetPosition = function(time, easing) {
|
|
2069
|
+
if (time === void 0) {
|
|
2070
|
+
time = 0;
|
|
2071
|
+
}
|
|
2072
|
+
if (easing === void 0) {
|
|
2073
|
+
easing = ease.bounce;
|
|
2074
|
+
}
|
|
2075
|
+
var _a2 = this.scrollBehaviorX.checkInBoundary(), x = _a2.position, xInBoundary = _a2.inBoundary;
|
|
2076
|
+
var _b2 = this.scrollBehaviorY.checkInBoundary(), y = _b2.position, yInBoundary = _b2.inBoundary;
|
|
2077
|
+
if (xInBoundary && yInBoundary) {
|
|
2078
|
+
return false;
|
|
2079
|
+
}
|
|
2080
|
+
if (isIOSBadVersion) {
|
|
2081
|
+
this.reflow();
|
|
2082
|
+
}
|
|
2083
|
+
this.scrollTo(x, y, time, easing);
|
|
2084
|
+
return true;
|
|
2085
|
+
};
|
|
2086
|
+
Scroller2.prototype.reflow = function() {
|
|
2087
|
+
this._reflow = this.content.offsetHeight;
|
|
2088
|
+
};
|
|
2089
|
+
Scroller2.prototype.updatePositions = function(pos) {
|
|
2090
|
+
this.scrollBehaviorX.updatePosition(pos.x);
|
|
2091
|
+
this.scrollBehaviorY.updatePosition(pos.y);
|
|
2092
|
+
};
|
|
2093
|
+
Scroller2.prototype.getCurrentPos = function() {
|
|
2094
|
+
return this.actions.getCurrentPos();
|
|
2095
|
+
};
|
|
2096
|
+
Scroller2.prototype.enable = function() {
|
|
2097
|
+
this.actions.enabled = true;
|
|
2098
|
+
};
|
|
2099
|
+
Scroller2.prototype.disable = function() {
|
|
2100
|
+
cancelAnimationFrame(this.animater.timer);
|
|
2101
|
+
this.actions.enabled = false;
|
|
2102
|
+
};
|
|
2103
|
+
Scroller2.prototype.destroy = function() {
|
|
2104
|
+
var _this = this;
|
|
2105
|
+
var keys = [
|
|
2106
|
+
"resizeRegister",
|
|
2107
|
+
"transitionEndRegister",
|
|
2108
|
+
"actionsHandler",
|
|
2109
|
+
"actions",
|
|
2110
|
+
"hooks",
|
|
2111
|
+
"animater",
|
|
2112
|
+
"translater",
|
|
2113
|
+
"scrollBehaviorX",
|
|
2114
|
+
"scrollBehaviorY"
|
|
2115
|
+
];
|
|
2116
|
+
keys.forEach(function(key) {
|
|
2117
|
+
return _this[key].destroy();
|
|
2118
|
+
});
|
|
2119
|
+
};
|
|
2120
|
+
return Scroller2;
|
|
2121
|
+
})()
|
|
2122
|
+
);
|
|
2123
|
+
var BScrollConstructor = (
|
|
2124
|
+
/** @class */
|
|
2125
|
+
(function(_super) {
|
|
2126
|
+
__extends(BScrollConstructor2, _super);
|
|
2127
|
+
function BScrollConstructor2(el, options) {
|
|
2128
|
+
var _this = _super.call(this, [
|
|
2129
|
+
"refresh",
|
|
2130
|
+
"contentChanged",
|
|
2131
|
+
"enable",
|
|
2132
|
+
"disable",
|
|
2133
|
+
"beforeScrollStart",
|
|
2134
|
+
"scrollStart",
|
|
2135
|
+
"scroll",
|
|
2136
|
+
"scrollEnd",
|
|
2137
|
+
"scrollCancel",
|
|
2138
|
+
"touchEnd",
|
|
2139
|
+
"flick",
|
|
2140
|
+
"destroy"
|
|
2141
|
+
]) || this;
|
|
2142
|
+
var wrapper = getElement(el);
|
|
2143
|
+
if (!wrapper) {
|
|
2144
|
+
warn("Can not resolve the wrapper DOM.");
|
|
2145
|
+
return _this;
|
|
2146
|
+
}
|
|
2147
|
+
_this.plugins = {};
|
|
2148
|
+
_this.options = new OptionsConstructor().merge(options).process();
|
|
2149
|
+
if (!_this.setContent(wrapper).valid) {
|
|
2150
|
+
return _this;
|
|
2151
|
+
}
|
|
2152
|
+
_this.hooks = new EventEmitter([
|
|
2153
|
+
"refresh",
|
|
2154
|
+
"enable",
|
|
2155
|
+
"disable",
|
|
2156
|
+
"destroy",
|
|
2157
|
+
"beforeInitialScrollTo",
|
|
2158
|
+
"contentChanged"
|
|
2159
|
+
]);
|
|
2160
|
+
_this.init(wrapper);
|
|
2161
|
+
return _this;
|
|
2162
|
+
}
|
|
2163
|
+
BScrollConstructor2.use = function(ctor) {
|
|
2164
|
+
var name = ctor.pluginName;
|
|
2165
|
+
var installed = BScrollConstructor2.plugins.some(function(plugin) {
|
|
2166
|
+
return ctor === plugin.ctor;
|
|
2167
|
+
});
|
|
2168
|
+
if (installed)
|
|
2169
|
+
return BScrollConstructor2;
|
|
2170
|
+
if (isUndef(name)) {
|
|
2171
|
+
warn("Plugin Class must specify plugin's name in static property by 'pluginName' field.");
|
|
2172
|
+
return BScrollConstructor2;
|
|
2173
|
+
}
|
|
2174
|
+
BScrollConstructor2.pluginsMap[name] = true;
|
|
2175
|
+
BScrollConstructor2.plugins.push({
|
|
2176
|
+
name,
|
|
2177
|
+
applyOrder: ctor.applyOrder,
|
|
2178
|
+
ctor
|
|
2179
|
+
});
|
|
2180
|
+
return BScrollConstructor2;
|
|
2181
|
+
};
|
|
2182
|
+
BScrollConstructor2.prototype.setContent = function(wrapper) {
|
|
2183
|
+
var contentChanged = false;
|
|
2184
|
+
var valid = true;
|
|
2185
|
+
var content = wrapper.children[this.options.specifiedIndexAsContent];
|
|
2186
|
+
if (!content) {
|
|
2187
|
+
warn("The wrapper need at least one child element to be content element to scroll.");
|
|
2188
|
+
valid = false;
|
|
2189
|
+
} else {
|
|
2190
|
+
contentChanged = this.content !== content;
|
|
2191
|
+
if (contentChanged) {
|
|
2192
|
+
this.content = content;
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
return {
|
|
2196
|
+
valid,
|
|
2197
|
+
contentChanged
|
|
2198
|
+
};
|
|
2199
|
+
};
|
|
2200
|
+
BScrollConstructor2.prototype.init = function(wrapper) {
|
|
2201
|
+
var _this = this;
|
|
2202
|
+
this.wrapper = wrapper;
|
|
2203
|
+
wrapper.isBScrollContainer = true;
|
|
2204
|
+
this.scroller = new Scroller(wrapper, this.content, this.options);
|
|
2205
|
+
this.scroller.hooks.on(this.scroller.hooks.eventTypes.resize, function() {
|
|
2206
|
+
_this.refresh();
|
|
2207
|
+
});
|
|
2208
|
+
this.eventBubbling();
|
|
2209
|
+
this.handleAutoBlur();
|
|
2210
|
+
this.enable();
|
|
2211
|
+
this.proxy(propertiesConfig);
|
|
2212
|
+
this.applyPlugins();
|
|
2213
|
+
this.refreshWithoutReset(this.content);
|
|
2214
|
+
var _a2 = this.options, startX = _a2.startX, startY = _a2.startY;
|
|
2215
|
+
var position = {
|
|
2216
|
+
x: startX,
|
|
2217
|
+
y: startY
|
|
2218
|
+
};
|
|
2219
|
+
if (this.hooks.trigger(this.hooks.eventTypes.beforeInitialScrollTo, position)) {
|
|
2220
|
+
return;
|
|
2221
|
+
}
|
|
2222
|
+
this.scroller.scrollTo(position.x, position.y);
|
|
2223
|
+
};
|
|
2224
|
+
BScrollConstructor2.prototype.applyPlugins = function() {
|
|
2225
|
+
var _this = this;
|
|
2226
|
+
var options = this.options;
|
|
2227
|
+
BScrollConstructor2.plugins.sort(function(a, b) {
|
|
2228
|
+
var _a2;
|
|
2229
|
+
var applyOrderMap = (_a2 = {}, _a2[
|
|
2230
|
+
"pre"
|
|
2231
|
+
/* Pre */
|
|
2232
|
+
] = -1, _a2[
|
|
2233
|
+
"post"
|
|
2234
|
+
/* Post */
|
|
2235
|
+
] = 1, _a2);
|
|
2236
|
+
var aOrder = a.applyOrder ? applyOrderMap[a.applyOrder] : 0;
|
|
2237
|
+
var bOrder = b.applyOrder ? applyOrderMap[b.applyOrder] : 0;
|
|
2238
|
+
return aOrder - bOrder;
|
|
2239
|
+
}).forEach(function(item) {
|
|
2240
|
+
var ctor = item.ctor;
|
|
2241
|
+
if (options[item.name] && typeof ctor === "function") {
|
|
2242
|
+
_this.plugins[item.name] = new ctor(_this);
|
|
2243
|
+
}
|
|
2244
|
+
});
|
|
2245
|
+
};
|
|
2246
|
+
BScrollConstructor2.prototype.handleAutoBlur = function() {
|
|
2247
|
+
if (this.options.autoBlur) {
|
|
2248
|
+
this.on(this.eventTypes.beforeScrollStart, function() {
|
|
2249
|
+
var activeElement = document.activeElement;
|
|
2250
|
+
if (activeElement && (activeElement.tagName === "INPUT" || activeElement.tagName === "TEXTAREA")) {
|
|
2251
|
+
activeElement.blur();
|
|
2252
|
+
}
|
|
2253
|
+
});
|
|
2254
|
+
}
|
|
2255
|
+
};
|
|
2256
|
+
BScrollConstructor2.prototype.eventBubbling = function() {
|
|
2257
|
+
bubbling(this.scroller.hooks, this, [
|
|
2258
|
+
this.eventTypes.beforeScrollStart,
|
|
2259
|
+
this.eventTypes.scrollStart,
|
|
2260
|
+
this.eventTypes.scroll,
|
|
2261
|
+
this.eventTypes.scrollEnd,
|
|
2262
|
+
this.eventTypes.scrollCancel,
|
|
2263
|
+
this.eventTypes.touchEnd,
|
|
2264
|
+
this.eventTypes.flick
|
|
2265
|
+
]);
|
|
2266
|
+
};
|
|
2267
|
+
BScrollConstructor2.prototype.refreshWithoutReset = function(content) {
|
|
2268
|
+
this.scroller.refresh(content);
|
|
2269
|
+
this.hooks.trigger(this.hooks.eventTypes.refresh, content);
|
|
2270
|
+
this.trigger(this.eventTypes.refresh, content);
|
|
2271
|
+
};
|
|
2272
|
+
BScrollConstructor2.prototype.proxy = function(propertiesConfig2) {
|
|
2273
|
+
var _this = this;
|
|
2274
|
+
propertiesConfig2.forEach(function(_a2) {
|
|
2275
|
+
var key = _a2.key, sourceKey = _a2.sourceKey;
|
|
2276
|
+
propertiesProxy(_this, sourceKey, key);
|
|
2277
|
+
});
|
|
2278
|
+
};
|
|
2279
|
+
BScrollConstructor2.prototype.refresh = function() {
|
|
2280
|
+
var _a2 = this.setContent(this.wrapper), contentChanged = _a2.contentChanged, valid = _a2.valid;
|
|
2281
|
+
if (valid) {
|
|
2282
|
+
var content = this.content;
|
|
2283
|
+
this.refreshWithoutReset(content);
|
|
2284
|
+
if (contentChanged) {
|
|
2285
|
+
this.hooks.trigger(this.hooks.eventTypes.contentChanged, content);
|
|
2286
|
+
this.trigger(this.eventTypes.contentChanged, content);
|
|
2287
|
+
}
|
|
2288
|
+
this.scroller.resetPosition();
|
|
2289
|
+
}
|
|
2290
|
+
};
|
|
2291
|
+
BScrollConstructor2.prototype.enable = function() {
|
|
2292
|
+
this.scroller.enable();
|
|
2293
|
+
this.hooks.trigger(this.hooks.eventTypes.enable);
|
|
2294
|
+
this.trigger(this.eventTypes.enable);
|
|
2295
|
+
};
|
|
2296
|
+
BScrollConstructor2.prototype.disable = function() {
|
|
2297
|
+
this.scroller.disable();
|
|
2298
|
+
this.hooks.trigger(this.hooks.eventTypes.disable);
|
|
2299
|
+
this.trigger(this.eventTypes.disable);
|
|
2300
|
+
};
|
|
2301
|
+
BScrollConstructor2.prototype.destroy = function() {
|
|
2302
|
+
this.hooks.trigger(this.hooks.eventTypes.destroy);
|
|
2303
|
+
this.trigger(this.eventTypes.destroy);
|
|
2304
|
+
this.scroller.destroy();
|
|
2305
|
+
};
|
|
2306
|
+
BScrollConstructor2.prototype.eventRegister = function(names) {
|
|
2307
|
+
this.registerType(names);
|
|
2308
|
+
};
|
|
2309
|
+
BScrollConstructor2.plugins = [];
|
|
2310
|
+
BScrollConstructor2.pluginsMap = {};
|
|
2311
|
+
return BScrollConstructor2;
|
|
2312
|
+
})(EventEmitter)
|
|
2313
|
+
);
|
|
2314
|
+
function createBScroll(el, options) {
|
|
2315
|
+
var bs = new BScrollConstructor(el, options);
|
|
2316
|
+
return bs;
|
|
2317
|
+
}
|
|
2318
|
+
createBScroll.use = BScrollConstructor.use;
|
|
2319
|
+
createBScroll.plugins = BScrollConstructor.plugins;
|
|
2320
|
+
createBScroll.pluginsMap = BScrollConstructor.pluginsMap;
|
|
2321
|
+
var BScroll = createBScroll;
|
|
2322
|
+
export {
|
|
2323
|
+
Behavior,
|
|
2324
|
+
CustomOptions,
|
|
2325
|
+
createBScroll,
|
|
2326
|
+
BScroll as default
|
|
2327
|
+
};
|