fastman2 3.0.0-alpha.1 → 3.0.0-alpha.2
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/actionsheetman.js +1 -96
- package/alertman.js +1 -79
- package/annotationman.js +17 -2912
- package/baseman.js +1 -115
- package/blankpageman.js +1 -171
- package/cascadepickerman.js +1 -322
- package/confirmman.js +1 -87
- package/coreman.js +3 -2182
- package/cryptoman.js +2 -8931
- package/datetimepickerman.js +1 -181
- package/domman.js +1 -2759
- package/eventemitterman.js +1 -112
- package/fileuploadman.js +1 -2970
- package/formvalidateman.js +1 -335
- package/jsbridgeman.js +1 -992
- package/lazyloadman.js +1 -133
- package/loadingman.js +1 -81
- package/modalman.js +1 -264
- package/mutationobserverman.js +1 -356
- package/package.json +1 -1
- package/passguardman.js +1 -1722
- package/persistman.js +1 -60
- package/pickerman.js +1 -680
- package/popupman.js +1 -61
- package/postman.js +1 -1649
- package/preloadman.js +2 -8760
- package/resultpageman.js +1 -153
- package/routerman.js +1 -1201
- package/scrollman-infiniteRefresh.js +1 -117
- package/scrollman-pullDownRefresh.js +1 -302
- package/scrollman.js +2 -2567
- package/storeman.js +1 -585
- package/swiperman.js +1 -4702
- package/swiperoldman.js +1 -3005
- package/tabman.js +1 -145
- package/tipman.js +1 -110
- package/toastman.js +1 -78
- package/toolman.js +1 -22
- package/whenman.js +1 -774
- package/wsman.js +1 -7624
package/scrollman.js
CHANGED
|
@@ -1,2567 +1,2 @@
|
|
|
1
|
-
(function
|
|
2
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory();
|
|
4
|
-
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define([], factory);
|
|
6
|
-
else if(typeof exports === 'object')
|
|
7
|
-
exports["fastman"] = factory();
|
|
8
|
-
else
|
|
9
|
-
root["fastman"] = factory();
|
|
10
|
-
})(this, function() {
|
|
11
|
-
return webpackJsonpfastman([10],{
|
|
12
|
-
|
|
13
|
-
/***/ 103:
|
|
14
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
15
|
-
|
|
16
|
-
"use strict";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(exports, "__esModule", {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Created by dfzq on 2017/2/10.
|
|
27
|
-
*/
|
|
28
|
-
var Util = __webpack_require__(31);
|
|
29
|
-
var IScroll = __webpack_require__(151);
|
|
30
|
-
var inViewport = __webpack_require__(59);
|
|
31
|
-
|
|
32
|
-
//重置zepto自带的滚动条
|
|
33
|
-
var _zeptoMethodCache = {
|
|
34
|
-
"scrollTop": $.fn.scrollTop,
|
|
35
|
-
"scrollLeft": $.fn.scrollLeft
|
|
36
|
-
};
|
|
37
|
-
//重置scrollLeft和scrollRight
|
|
38
|
-
(function () {
|
|
39
|
-
$.extend($.fn, {
|
|
40
|
-
scrollTop: function scrollTop(top, dur) {
|
|
41
|
-
if (!this.length) return;
|
|
42
|
-
var scroller = this.data('scroller');
|
|
43
|
-
if (scroller && scroller.scroller) {
|
|
44
|
-
//js滚动
|
|
45
|
-
return scroller.scrollTop(top, dur);
|
|
46
|
-
} else {
|
|
47
|
-
return _zeptoMethodCache.scrollTop.apply(this, arguments);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
$.extend($.fn, {
|
|
52
|
-
scrollLeft: function scrollLeft(left, dur) {
|
|
53
|
-
if (!this.length) return;
|
|
54
|
-
var scroller = this.data('scroller');
|
|
55
|
-
if (scroller && scroller.scroller) {
|
|
56
|
-
//js滚动
|
|
57
|
-
return scroller.scrollLeft(left, dur);
|
|
58
|
-
} else {
|
|
59
|
-
return _zeptoMethodCache.scrollLeft.apply(this, arguments);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
})();
|
|
64
|
-
|
|
65
|
-
//自定义的滚动条
|
|
66
|
-
var Scroller = function Scroller(pageContent, _options) {
|
|
67
|
-
var $pageContent = this.$pageContent = $(pageContent);
|
|
68
|
-
|
|
69
|
-
this.options = $.extend({}, this._defaults, _options);
|
|
70
|
-
|
|
71
|
-
var type = this.options.type;
|
|
72
|
-
//auto的type,系统版本的小于4.4.0的安卓设备和系统版本小于6.0.0的ios设备,启用js版的iscoll
|
|
73
|
-
var useJSScroller = type === 'js' || type === 'auto' && $.device.android && Util.compareVersion('4.4.0', $.device.osVersion) > -1 || type === 'auto' && $.device.ios && Util.compareVersion('6.0.0', $.device.osVersion) > -1;
|
|
74
|
-
|
|
75
|
-
if (useJSScroller) {
|
|
76
|
-
|
|
77
|
-
// TODO v-dom不允许在dom出现后再去更改dom,否则会出现不可预知的bug
|
|
78
|
-
// var $pageContentInner = $pageContent.find('.content-inner');
|
|
79
|
-
// //如果滚动内容没有被包裹,自动添加wrap
|
|
80
|
-
// if (!$pageContentInner[0]) {
|
|
81
|
-
// // $pageContent.html('<div class="content-inner">' + $pageContent.html() + '</div>');
|
|
82
|
-
// var children = $pageContent.children();
|
|
83
|
-
// if (children.length < 1) {
|
|
84
|
-
// $pageContent.children().wrapAll('<div class="content-inner"></div>');
|
|
85
|
-
// } else {
|
|
86
|
-
// $pageContent.html('<div class="content-inner">' + $pageContent.html() + '</div>');
|
|
87
|
-
// }
|
|
88
|
-
// }
|
|
89
|
-
|
|
90
|
-
if ($pageContent.hasClass('pull-down-refresh')) {
|
|
91
|
-
//因为iscroll 当页面高度不足 100% 时无法滑动,所以无法触发下拉动作,这里改动一下高度
|
|
92
|
-
//区分是否有.bar容器,如有,则content的top:0,无则content的top:-2.2rem,这里取2.2rem的最大值,近60
|
|
93
|
-
var minHeight = $(window).height() + ($pageContent.prev().hasClass(".bar") ? 1 : 61);
|
|
94
|
-
$pageContent.find('.content-inner').css('min-height', minHeight + 'px');
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
var ptr = $(pageContent).hasClass('pull-down-refresh');
|
|
98
|
-
//js滚动模式,用transform移动内容区位置,会导致fixed失效,表现类似absolute。因此禁用transform模式,强制使用native滚动条。
|
|
99
|
-
var useTransform = $pageContent.find('.fixed-tab').length === 0;
|
|
100
|
-
var options = {
|
|
101
|
-
probeType: 1,
|
|
102
|
-
mouseWheel: true,
|
|
103
|
-
//解决安卓js模式下,刷新滚动条后绑定的事件不响应,对chrome内核浏览器设置click:true
|
|
104
|
-
click: $.device.androidChrome,
|
|
105
|
-
useTransform: useTransform,
|
|
106
|
-
//js模式下允许滚动条横向滚动,但是需要注意,滚动容易宽度必须大于屏幕宽度滚动才生效
|
|
107
|
-
scrollX: true
|
|
108
|
-
};
|
|
109
|
-
if (ptr) {
|
|
110
|
-
options.ptr = true;
|
|
111
|
-
options.ptrOffset = 44;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// IScroll容器初始化
|
|
115
|
-
this.scroller = new IScroll(pageContent, options); // jshint ignore:line
|
|
116
|
-
//和native滚动统一起来
|
|
117
|
-
this._bindEventToDomWhenJs();
|
|
118
|
-
$.initPullToRefresh = $._pullToRefreshJSScroll.initPullToRefresh;
|
|
119
|
-
$.pullToRefreshDone = $._pullToRefreshJSScroll.pullToRefreshDone;
|
|
120
|
-
$.pullToRefreshTrigger = $._pullToRefreshJSScroll.pullToRefreshTrigger;
|
|
121
|
-
$.destroyToRefresh = $._pullToRefreshJSScroll.destroyToRefresh;
|
|
122
|
-
$pageContent.addClass('javascript-scroll');
|
|
123
|
-
if (!useTransform) {
|
|
124
|
-
$pageContent.find('.content-inner').css({
|
|
125
|
-
width: '100%',
|
|
126
|
-
position: 'absolute'
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
//如果页面本身已经进行了原生滚动,那么把这个滚动换成JS的滚动
|
|
131
|
-
var nativeScrollTop = this.$pageContent[0].scrollTop;
|
|
132
|
-
if (nativeScrollTop) {
|
|
133
|
-
this.$pageContent[0].scrollTop = 0;
|
|
134
|
-
this.scrollTop(nativeScrollTop);
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
$pageContent.addClass('native-scroll');
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
Scroller.prototype = {
|
|
141
|
-
_defaults: {
|
|
142
|
-
type: 'auto'
|
|
143
|
-
},
|
|
144
|
-
_bindEventToDomWhenJs: function _bindEventToDomWhenJs() {
|
|
145
|
-
//"scrollStart", //the scroll started.
|
|
146
|
-
//"scroll", //the content is scrolling. Available only in scroll-probe.js edition. See onScroll event.
|
|
147
|
-
//"scrollEnd", //content stopped scrolling.
|
|
148
|
-
if (this.scroller) {
|
|
149
|
-
var self = this;
|
|
150
|
-
this.scroller.on('scrollStart', function () {
|
|
151
|
-
self.$pageContent.trigger('scrollstart');
|
|
152
|
-
});
|
|
153
|
-
this.scroller.on('scroll', function () {
|
|
154
|
-
self.$pageContent.trigger('scroll');
|
|
155
|
-
});
|
|
156
|
-
this.scroller.on('scrollEnd', function () {
|
|
157
|
-
self.$pageContent.trigger('scrollend');
|
|
158
|
-
});
|
|
159
|
-
} else {
|
|
160
|
-
//TODO: 实现native的scrollStart和scrollEnd
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
scrollTop: function scrollTop(top, dur) {
|
|
164
|
-
if (this.scroller) {
|
|
165
|
-
if (top !== undefined) {
|
|
166
|
-
this.scroller.scrollTo(0, -1 * top, dur);
|
|
167
|
-
} else {
|
|
168
|
-
return this.scroller.getComputedPosition().y * -1;
|
|
169
|
-
}
|
|
170
|
-
} else {
|
|
171
|
-
return this.$pageContent.scrollTop(top, dur);
|
|
172
|
-
}
|
|
173
|
-
return this;
|
|
174
|
-
},
|
|
175
|
-
scrollLeft: function scrollLeft(left, dur) {
|
|
176
|
-
if (this.scroller) {
|
|
177
|
-
if (left !== undefined) {
|
|
178
|
-
this.scroller.scrollTo(-1 * left, 0);
|
|
179
|
-
} else {
|
|
180
|
-
return this.scroller.getComputedPosition().x * -1;
|
|
181
|
-
}
|
|
182
|
-
} else {
|
|
183
|
-
return this.$pageContent.scrollTop(left, dur);
|
|
184
|
-
}
|
|
185
|
-
return this;
|
|
186
|
-
},
|
|
187
|
-
on: function on(event, callback) {
|
|
188
|
-
if (this.scroller) {
|
|
189
|
-
this.scroller.on(event, function () {
|
|
190
|
-
callback.call(this.wrapper);
|
|
191
|
-
});
|
|
192
|
-
} else {
|
|
193
|
-
this.$pageContent.on(event, callback);
|
|
194
|
-
}
|
|
195
|
-
return this;
|
|
196
|
-
},
|
|
197
|
-
off: function off(event, callback) {
|
|
198
|
-
if (this.scroller) {
|
|
199
|
-
this.scroller.off(event, callback);
|
|
200
|
-
} else {
|
|
201
|
-
this.$pageContent.off(event, callback);
|
|
202
|
-
}
|
|
203
|
-
return this;
|
|
204
|
-
},
|
|
205
|
-
refresh: function refresh() {
|
|
206
|
-
if (this.scroller) this.scroller.refresh();
|
|
207
|
-
return this;
|
|
208
|
-
},
|
|
209
|
-
scrollHeight: function scrollHeight() {
|
|
210
|
-
if (this.scroller) {
|
|
211
|
-
return this.scroller.scrollerHeight;
|
|
212
|
-
} else {
|
|
213
|
-
return this.$pageContent[0].scrollHeight;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
//Scroller PLUGIN DEFINITION
|
|
220
|
-
// =======================
|
|
221
|
-
|
|
222
|
-
function Plugin(option) {
|
|
223
|
-
var args = Array.apply(null, arguments);
|
|
224
|
-
args.shift();
|
|
225
|
-
var internal_return;
|
|
226
|
-
|
|
227
|
-
this.each(function () {
|
|
228
|
-
|
|
229
|
-
var $this = $(this);
|
|
230
|
-
|
|
231
|
-
var options = $.extend({}, $this.dataset(), (typeof option === 'undefined' ? 'undefined' : _typeof(option)) === 'object' && option);
|
|
232
|
-
|
|
233
|
-
var data = $this.data('scroller');
|
|
234
|
-
//如果 scroller 没有被初始化,对scroller 进行初始化
|
|
235
|
-
if (!data) {
|
|
236
|
-
//获取data-api的
|
|
237
|
-
$this.data('scroller', data = new Scroller(this, options));
|
|
238
|
-
}
|
|
239
|
-
if (typeof option === 'string' && typeof data[option] === 'function') {
|
|
240
|
-
internal_return = data[option].apply(data, args);
|
|
241
|
-
if (internal_return !== undefined) return false;
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
if (internal_return !== undefined) return internal_return;else return this;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
var old = $.fn.scroller;
|
|
249
|
-
|
|
250
|
-
$.fn.scroller = Plugin;
|
|
251
|
-
$.fn.scroller.Constructor = Scroller;
|
|
252
|
-
|
|
253
|
-
// Scroll NO CONFLICT
|
|
254
|
-
// =================
|
|
255
|
-
|
|
256
|
-
$.fn.scroller.noConflict = function () {
|
|
257
|
-
$.fn.scroller = old;
|
|
258
|
-
return this;
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
// //添加data-api,具有该attr的标签自动升级为一个scroller组件
|
|
262
|
-
// $(function() {
|
|
263
|
-
// $('[data-toggle="scroller"]').scroller();
|
|
264
|
-
// });
|
|
265
|
-
|
|
266
|
-
//统一的接口,带有 .javascript-scroll 的content 进行刷新
|
|
267
|
-
$.refreshScroller = function (content) {
|
|
268
|
-
if (content) {
|
|
269
|
-
$(content).scroller('refresh');
|
|
270
|
-
} else {
|
|
271
|
-
$('.javascript-scroll').each(function () {
|
|
272
|
-
$(this).scroller('refresh');
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
//全局初始化方法,会对页面上的 [data-toggle="scroller"],.content. 进行滚动条初始化
|
|
277
|
-
$.initScroller = function (option) {
|
|
278
|
-
this.options = $.extend({}, (typeof option === 'undefined' ? 'undefined' : _typeof(option)) === 'object' && option);
|
|
279
|
-
$('[data-toggle="scroller"],.content').scroller(option);
|
|
280
|
-
};
|
|
281
|
-
//获取scroller对象
|
|
282
|
-
$.getScroller = function (content) {
|
|
283
|
-
//以前默认只能有一个无限滚动,因此infinitescroll都是加在content上,现在允许里面有多个,因此要判断父元素是否有content
|
|
284
|
-
content = $(content).hasClass('ui-container') ? content : $(content).parents('.ui-container');
|
|
285
|
-
if (content) {
|
|
286
|
-
return $(content).data('scroller');
|
|
287
|
-
} else {
|
|
288
|
-
return $('.content.javascript-scroll').data('scroller');
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
//检测滚动类型,
|
|
292
|
-
//‘js’: javascript 滚动条
|
|
293
|
-
//‘native’: 原生滚动条
|
|
294
|
-
$.detectScrollerType = function (content) {
|
|
295
|
-
if (content) {
|
|
296
|
-
if ($(content).data('scroller') && $(content).data('scroller').scroller) {
|
|
297
|
-
return 'js';
|
|
298
|
-
} else {
|
|
299
|
-
return 'native';
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
//////////////// 滚动 ////////////////
|
|
305
|
-
// 通过选择器的方式创建一个scroller
|
|
306
|
-
var initScroller = function initScroller(selector, option) {
|
|
307
|
-
if ($(selector).length > 0) {
|
|
308
|
-
$(selector).scroller(option);
|
|
309
|
-
}
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
// 刷新,支持单个容器和全局容器刷新
|
|
313
|
-
var refreshScroller = function refreshScroller(selector) {
|
|
314
|
-
$.refreshScroller(selector);
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
// 滚动接口
|
|
318
|
-
var scrollTop = function scrollTop(selector, topNumber) {
|
|
319
|
-
if ($(selector).length > 0) {
|
|
320
|
-
$(selector).scrollTop(topNumber == undefined ? 0 : topNumber);
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
//////////////// 下拉刷新 ////////////////
|
|
325
|
-
// 声明下拉刷新特性
|
|
326
|
-
var initPullDownRefresh = function initPullDownRefresh(selector) {
|
|
327
|
-
return $.initPullToRefresh($(selector));
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
// 下拉刷新时触发的刷新回调
|
|
331
|
-
var pullDownRefresh = function pullDownRefresh(callback) {
|
|
332
|
-
$(document).on('refresh', '.pull-down-refresh', callback);
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
// 完成下拉刷新,重置该特性状态
|
|
336
|
-
var pullDownRefreshDone = function pullDownRefreshDone(selector) {
|
|
337
|
-
return $.pullToRefreshDone(selector);
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
exports.initScroller = initScroller;
|
|
341
|
-
exports.refreshScroller = refreshScroller;
|
|
342
|
-
exports.scrollTop = scrollTop;
|
|
343
|
-
exports.initPullDownRefresh = initPullDownRefresh;
|
|
344
|
-
exports.pullDownRefresh = pullDownRefresh;
|
|
345
|
-
exports.pullDownRefreshDone = pullDownRefreshDone;
|
|
346
|
-
|
|
347
|
-
/***/ }),
|
|
348
|
-
|
|
349
|
-
/***/ 151:
|
|
350
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
351
|
-
|
|
352
|
-
"use strict";
|
|
353
|
-
var __WEBPACK_AMD_DEFINE_RESULT__;
|
|
354
|
-
|
|
355
|
-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
356
|
-
|
|
357
|
-
/*! iScroll v5.2.0-snapshot ~ (c) 2008-2017 Matteo Spinelli ~ http://cubiq.org/license */
|
|
358
|
-
// line 262: initMouseEvent is deprecated. 由于定义的参数已经被确认为只读属性,而该方案只针对旧款手机,因此这块的定义还是采用取消方案来代替
|
|
359
|
-
// line 760: 支持下拉刷新的函数注册
|
|
360
|
-
(function (window, document, Math) {
|
|
361
|
-
var rAF = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) {
|
|
362
|
-
window.setTimeout(callback, 1000 / 60);
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
var utils = function () {
|
|
366
|
-
var me = {};
|
|
367
|
-
|
|
368
|
-
var _elementStyle = document.createElement('div').style;
|
|
369
|
-
var _vendor = function () {
|
|
370
|
-
var vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'],
|
|
371
|
-
transform,
|
|
372
|
-
i = 0,
|
|
373
|
-
l = vendors.length;
|
|
374
|
-
|
|
375
|
-
for (; i < l; i++) {
|
|
376
|
-
transform = vendors[i] + 'ransform';
|
|
377
|
-
if (transform in _elementStyle) return vendors[i].substr(0, vendors[i].length - 1);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
return false;
|
|
381
|
-
}();
|
|
382
|
-
|
|
383
|
-
function _prefixStyle(style) {
|
|
384
|
-
if (_vendor === false) return false;
|
|
385
|
-
if (_vendor === '') return style;
|
|
386
|
-
return _vendor + style.charAt(0).toUpperCase() + style.substr(1);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
me.getTime = Date.now || function getTime() {
|
|
390
|
-
return new Date().getTime();
|
|
391
|
-
};
|
|
392
|
-
|
|
393
|
-
me.extend = function (target, obj) {
|
|
394
|
-
for (var i in obj) {
|
|
395
|
-
target[i] = obj[i];
|
|
396
|
-
}
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
me.addEvent = function (el, type, fn, capture) {
|
|
400
|
-
el.addEventListener(type, fn, !!capture);
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
me.removeEvent = function (el, type, fn, capture) {
|
|
404
|
-
el.removeEventListener(type, fn, !!capture);
|
|
405
|
-
};
|
|
406
|
-
|
|
407
|
-
me.prefixPointerEvent = function (pointerEvent) {
|
|
408
|
-
return window.MSPointerEvent ? 'MSPointer' + pointerEvent.charAt(7).toUpperCase() + pointerEvent.substr(8) : pointerEvent;
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
|
|
412
|
-
var distance = current - start,
|
|
413
|
-
speed = Math.abs(distance) / time,
|
|
414
|
-
destination,
|
|
415
|
-
duration;
|
|
416
|
-
|
|
417
|
-
deceleration = deceleration === undefined ? 0.0006 : deceleration;
|
|
418
|
-
|
|
419
|
-
destination = current + speed * speed / (2 * deceleration) * (distance < 0 ? -1 : 1);
|
|
420
|
-
duration = speed / deceleration;
|
|
421
|
-
|
|
422
|
-
if (destination < lowerMargin) {
|
|
423
|
-
destination = wrapperSize ? lowerMargin - wrapperSize / 2.5 * (speed / 8) : lowerMargin;
|
|
424
|
-
distance = Math.abs(destination - current);
|
|
425
|
-
duration = distance / speed;
|
|
426
|
-
} else if (destination > 0) {
|
|
427
|
-
destination = wrapperSize ? wrapperSize / 2.5 * (speed / 8) : 0;
|
|
428
|
-
distance = Math.abs(current) + destination;
|
|
429
|
-
duration = distance / speed;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
return {
|
|
433
|
-
destination: Math.round(destination),
|
|
434
|
-
duration: duration
|
|
435
|
-
};
|
|
436
|
-
};
|
|
437
|
-
|
|
438
|
-
var _transform = _prefixStyle('transform');
|
|
439
|
-
|
|
440
|
-
me.extend(me, {
|
|
441
|
-
hasTransform: _transform !== false,
|
|
442
|
-
hasPerspective: _prefixStyle('perspective') in _elementStyle,
|
|
443
|
-
hasTouch: 'ontouchstart' in window,
|
|
444
|
-
hasPointer: !!(window.PointerEvent || window.MSPointerEvent), // IE10 is prefixed
|
|
445
|
-
hasTransition: _prefixStyle('transition') in _elementStyle
|
|
446
|
-
});
|
|
447
|
-
|
|
448
|
-
/*
|
|
449
|
-
This should find all Android browsers lower than build 535.19 (both stock browser and webview)
|
|
450
|
-
- galaxy S2 is ok
|
|
451
|
-
- 2.3.6 : `AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1`
|
|
452
|
-
- 4.0.4 : `AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30`
|
|
453
|
-
- galaxy S3 is badAndroid (stock brower, webview)
|
|
454
|
-
`AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30`
|
|
455
|
-
- galaxy S4 is badAndroid (stock brower, webview)
|
|
456
|
-
`AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30`
|
|
457
|
-
- galaxy S5 is OK
|
|
458
|
-
`AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36 (Chrome/)`
|
|
459
|
-
- galaxy S6 is OK
|
|
460
|
-
`AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.36 (Chrome/)`
|
|
461
|
-
*/
|
|
462
|
-
me.isBadAndroid = function () {
|
|
463
|
-
var appVersion = window.navigator.appVersion;
|
|
464
|
-
// Android browser is not a chrome browser.
|
|
465
|
-
if (/Android/.test(appVersion) && !/Chrome\/\d/.test(appVersion)) {
|
|
466
|
-
var safariVersion = appVersion.match(/Safari\/(\d+.\d)/);
|
|
467
|
-
if (safariVersion && (typeof safariVersion === 'undefined' ? 'undefined' : _typeof(safariVersion)) === "object" && safariVersion.length >= 2) {
|
|
468
|
-
return parseFloat(safariVersion[1]) < 535.19;
|
|
469
|
-
} else {
|
|
470
|
-
return true;
|
|
471
|
-
}
|
|
472
|
-
} else {
|
|
473
|
-
return false;
|
|
474
|
-
}
|
|
475
|
-
}();
|
|
476
|
-
|
|
477
|
-
me.extend(me.style = {}, {
|
|
478
|
-
transform: _transform,
|
|
479
|
-
transitionTimingFunction: _prefixStyle('transitionTimingFunction'),
|
|
480
|
-
transitionDuration: _prefixStyle('transitionDuration'),
|
|
481
|
-
transitionDelay: _prefixStyle('transitionDelay'),
|
|
482
|
-
transformOrigin: _prefixStyle('transformOrigin'),
|
|
483
|
-
touchAction: _prefixStyle('touchAction')
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
me.hasClass = function (e, c) {
|
|
487
|
-
var re = new RegExp("(^|\\s)" + c + "(\\s|$)");
|
|
488
|
-
return re.test(e.className);
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
me.addClass = function (e, c) {
|
|
492
|
-
if (me.hasClass(e, c)) {
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
var newclass = e.className.split(' ');
|
|
497
|
-
newclass.push(c);
|
|
498
|
-
e.className = newclass.join(' ');
|
|
499
|
-
};
|
|
500
|
-
|
|
501
|
-
me.removeClass = function (e, c) {
|
|
502
|
-
if (!me.hasClass(e, c)) {
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
var re = new RegExp("(^|\\s)" + c + "(\\s|$)", 'g');
|
|
507
|
-
e.className = e.className.replace(re, ' ');
|
|
508
|
-
};
|
|
509
|
-
|
|
510
|
-
me.offset = function (el) {
|
|
511
|
-
var left = -el.offsetLeft,
|
|
512
|
-
top = -el.offsetTop;
|
|
513
|
-
|
|
514
|
-
// jshint -W084
|
|
515
|
-
while (el = el.offsetParent) {
|
|
516
|
-
left -= el.offsetLeft;
|
|
517
|
-
top -= el.offsetTop;
|
|
518
|
-
}
|
|
519
|
-
// jshint +W084
|
|
520
|
-
|
|
521
|
-
return {
|
|
522
|
-
left: left,
|
|
523
|
-
top: top
|
|
524
|
-
};
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
me.preventDefaultException = function (el, exceptions) {
|
|
528
|
-
for (var i in exceptions) {
|
|
529
|
-
if (exceptions[i].test(el[i])) {
|
|
530
|
-
return true;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
return false;
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
me.extend(me.eventType = {}, {
|
|
538
|
-
touchstart: 1,
|
|
539
|
-
touchmove: 1,
|
|
540
|
-
touchend: 1,
|
|
541
|
-
|
|
542
|
-
mousedown: 2,
|
|
543
|
-
mousemove: 2,
|
|
544
|
-
mouseup: 2,
|
|
545
|
-
|
|
546
|
-
pointerdown: 3,
|
|
547
|
-
pointermove: 3,
|
|
548
|
-
pointerup: 3,
|
|
549
|
-
|
|
550
|
-
MSPointerDown: 3,
|
|
551
|
-
MSPointerMove: 3,
|
|
552
|
-
MSPointerUp: 3
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
me.extend(me.ease = {}, {
|
|
556
|
-
quadratic: {
|
|
557
|
-
style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
|
|
558
|
-
fn: function fn(k) {
|
|
559
|
-
return k * (2 - k);
|
|
560
|
-
}
|
|
561
|
-
},
|
|
562
|
-
circular: {
|
|
563
|
-
style: 'cubic-bezier(0.1, 0.57, 0.1, 1)', // Not properly "circular" but this looks better, it should be (0.075, 0.82, 0.165, 1)
|
|
564
|
-
fn: function fn(k) {
|
|
565
|
-
return Math.sqrt(1 - --k * k);
|
|
566
|
-
}
|
|
567
|
-
},
|
|
568
|
-
back: {
|
|
569
|
-
style: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
|
|
570
|
-
fn: function fn(k) {
|
|
571
|
-
var b = 4;
|
|
572
|
-
return (k = k - 1) * k * ((b + 1) * k + b) + 1;
|
|
573
|
-
}
|
|
574
|
-
},
|
|
575
|
-
bounce: {
|
|
576
|
-
style: '',
|
|
577
|
-
fn: function fn(k) {
|
|
578
|
-
if ((k /= 1) < 1 / 2.75) {
|
|
579
|
-
return 7.5625 * k * k;
|
|
580
|
-
} else if (k < 2 / 2.75) {
|
|
581
|
-
return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75;
|
|
582
|
-
} else if (k < 2.5 / 2.75) {
|
|
583
|
-
return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375;
|
|
584
|
-
} else {
|
|
585
|
-
return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
},
|
|
589
|
-
elastic: {
|
|
590
|
-
style: '',
|
|
591
|
-
fn: function fn(k) {
|
|
592
|
-
var f = 0.22,
|
|
593
|
-
e = 0.4;
|
|
594
|
-
|
|
595
|
-
if (k === 0) {
|
|
596
|
-
return 0;
|
|
597
|
-
}
|
|
598
|
-
if (k == 1) {
|
|
599
|
-
return 1;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
return e * Math.pow(2, -10 * k) * Math.sin((k - f / 4) * (2 * Math.PI) / f) + 1;
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
});
|
|
606
|
-
|
|
607
|
-
me.tap = function (e, eventName) {
|
|
608
|
-
var ev = document.createEvent('Event');
|
|
609
|
-
ev.initEvent(eventName, true, true);
|
|
610
|
-
ev.pageX = e.pageX;
|
|
611
|
-
ev.pageY = e.pageY;
|
|
612
|
-
e.target.dispatchEvent(ev);
|
|
613
|
-
};
|
|
614
|
-
|
|
615
|
-
me.click = function (e) {
|
|
616
|
-
var target = e.target,
|
|
617
|
-
ev;
|
|
618
|
-
|
|
619
|
-
if (!/(SELECT|INPUT|TEXTAREA)/i.test(target.tagName)) {
|
|
620
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent
|
|
621
|
-
// initMouseEvent is deprecated.
|
|
622
|
-
// ev = document.createEvent(window.MouseEvent ? 'MouseEvents' : 'Event');
|
|
623
|
-
// ev.initEvent('click', true, true);
|
|
624
|
-
// ev.view = e.view || window;
|
|
625
|
-
// ev.detail = 1;
|
|
626
|
-
// ev.screenX = target.screenX || 0;
|
|
627
|
-
// ev.screenY = target.screenY || 0;
|
|
628
|
-
// ev.clientX = target.clientX || 0;
|
|
629
|
-
// ev.clientY = target.clientY || 0;
|
|
630
|
-
// ev.ctrlKey = !!e.ctrlKey;
|
|
631
|
-
// ev.altKey = !!e.altKey;
|
|
632
|
-
// ev.shiftKey = !!e.shiftKey;
|
|
633
|
-
// ev.metaKey = !!e.metaKey;
|
|
634
|
-
// ev.button = 0;
|
|
635
|
-
// ev.relatedTarget = null;
|
|
636
|
-
// ev._constructed = true;
|
|
637
|
-
// target.dispatchEvent(ev);
|
|
638
|
-
|
|
639
|
-
ev = document.createEvent('MouseEvents');
|
|
640
|
-
ev.initMouseEvent('click', true, true, e.view, 1, target.screenX, target.screenY, target.clientX, target.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, 0, null);
|
|
641
|
-
|
|
642
|
-
ev._constructed = true;
|
|
643
|
-
target.dispatchEvent(ev);
|
|
644
|
-
}
|
|
645
|
-
};
|
|
646
|
-
|
|
647
|
-
me.getTouchAction = function (eventPassthrough, addPinch) {
|
|
648
|
-
var touchAction = 'none';
|
|
649
|
-
if (eventPassthrough === 'vertical') {
|
|
650
|
-
touchAction = 'pan-y';
|
|
651
|
-
} else if (eventPassthrough === 'horizontal') {
|
|
652
|
-
touchAction = 'pan-x';
|
|
653
|
-
}
|
|
654
|
-
if (addPinch && touchAction != 'none') {
|
|
655
|
-
// add pinch-zoom support if the browser supports it, but if not (eg. Chrome <55) do nothing
|
|
656
|
-
touchAction += ' pinch-zoom';
|
|
657
|
-
}
|
|
658
|
-
return touchAction;
|
|
659
|
-
};
|
|
660
|
-
|
|
661
|
-
me.getRect = function (el) {
|
|
662
|
-
if (el instanceof SVGElement) {
|
|
663
|
-
var rect = el.getBoundingClientRect();
|
|
664
|
-
return {
|
|
665
|
-
top: rect.top,
|
|
666
|
-
left: rect.left,
|
|
667
|
-
width: rect.width,
|
|
668
|
-
height: rect.height
|
|
669
|
-
};
|
|
670
|
-
} else {
|
|
671
|
-
return {
|
|
672
|
-
top: el.offsetTop,
|
|
673
|
-
left: el.offsetLeft,
|
|
674
|
-
width: el.offsetWidth,
|
|
675
|
-
height: el.offsetHeight
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
|
-
|
|
680
|
-
return me;
|
|
681
|
-
}();
|
|
682
|
-
function IScroll(el, options) {
|
|
683
|
-
this.wrapper = typeof el == 'string' ? document.querySelector(el) : el;
|
|
684
|
-
this.scroller = this.wrapper.children[0];
|
|
685
|
-
this.scrollerStyle = this.scroller.style; // cache style for better performance
|
|
686
|
-
|
|
687
|
-
this.options = {
|
|
688
|
-
|
|
689
|
-
resizeScrollbars: true,
|
|
690
|
-
|
|
691
|
-
mouseWheelSpeed: 20,
|
|
692
|
-
|
|
693
|
-
snapThreshold: 0.334,
|
|
694
|
-
|
|
695
|
-
// INSERT POINT: OPTIONS
|
|
696
|
-
disablePointer: !utils.hasPointer,
|
|
697
|
-
disableTouch: utils.hasPointer || !utils.hasTouch,
|
|
698
|
-
disableMouse: utils.hasPointer || utils.hasTouch,
|
|
699
|
-
startX: 0,
|
|
700
|
-
startY: 0,
|
|
701
|
-
scrollY: true,
|
|
702
|
-
directionLockThreshold: 5,
|
|
703
|
-
momentum: true,
|
|
704
|
-
|
|
705
|
-
bounce: true,
|
|
706
|
-
bounceTime: 600,
|
|
707
|
-
bounceEasing: '',
|
|
708
|
-
|
|
709
|
-
preventDefault: true,
|
|
710
|
-
preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ },
|
|
711
|
-
|
|
712
|
-
HWCompositing: true,
|
|
713
|
-
useTransition: true,
|
|
714
|
-
useTransform: true,
|
|
715
|
-
bindToWrapper: typeof window.onmousedown === "undefined"
|
|
716
|
-
};
|
|
717
|
-
|
|
718
|
-
for (var i in options) {
|
|
719
|
-
this.options[i] = options[i];
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
// Normalize options
|
|
723
|
-
this.translateZ = this.options.HWCompositing && utils.hasPerspective ? ' translateZ(0)' : '';
|
|
724
|
-
|
|
725
|
-
this.options.useTransition = utils.hasTransition && this.options.useTransition;
|
|
726
|
-
this.options.useTransform = utils.hasTransform && this.options.useTransform;
|
|
727
|
-
|
|
728
|
-
this.options.eventPassthrough = this.options.eventPassthrough === true ? 'vertical' : this.options.eventPassthrough;
|
|
729
|
-
this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault;
|
|
730
|
-
|
|
731
|
-
// If you want eventPassthrough I have to lock one of the axes
|
|
732
|
-
this.options.scrollY = this.options.eventPassthrough == 'vertical' ? false : this.options.scrollY;
|
|
733
|
-
this.options.scrollX = this.options.eventPassthrough == 'horizontal' ? false : this.options.scrollX;
|
|
734
|
-
|
|
735
|
-
// With eventPassthrough we also need lockDirection mechanism
|
|
736
|
-
this.options.freeScroll = this.options.freeScroll && !this.options.eventPassthrough;
|
|
737
|
-
this.options.directionLockThreshold = this.options.eventPassthrough ? 0 : this.options.directionLockThreshold;
|
|
738
|
-
|
|
739
|
-
this.options.bounceEasing = typeof this.options.bounceEasing == 'string' ? utils.ease[this.options.bounceEasing] || utils.ease.circular : this.options.bounceEasing;
|
|
740
|
-
|
|
741
|
-
this.options.resizePolling = this.options.resizePolling === undefined ? 60 : this.options.resizePolling;
|
|
742
|
-
|
|
743
|
-
if (this.options.tap === true) {
|
|
744
|
-
this.options.tap = 'tap';
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
// https://github.com/cubiq/iscroll/issues/1029
|
|
748
|
-
if (!this.options.useTransition && !this.options.useTransform) {
|
|
749
|
-
if (!/relative|absolute/i.test(this.scrollerStyle.position)) {
|
|
750
|
-
this.scrollerStyle.position = "relative";
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
if (this.options.shrinkScrollbars == 'scale') {
|
|
755
|
-
this.options.useTransition = false;
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
this.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1;
|
|
759
|
-
|
|
760
|
-
if (this.options.probeType == 3) {
|
|
761
|
-
this.options.useTransition = false;
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
// INSERT POINT: NORMALIZATION
|
|
765
|
-
|
|
766
|
-
// Some defaults
|
|
767
|
-
this.x = 0;
|
|
768
|
-
this.y = 0;
|
|
769
|
-
this.directionX = 0;
|
|
770
|
-
this.directionY = 0;
|
|
771
|
-
this._events = {};
|
|
772
|
-
|
|
773
|
-
// INSERT POINT: DEFAULTS
|
|
774
|
-
|
|
775
|
-
this._init();
|
|
776
|
-
this.refresh();
|
|
777
|
-
|
|
778
|
-
this.scrollTo(this.options.startX, this.options.startY);
|
|
779
|
-
this.enable();
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
IScroll.prototype = {
|
|
783
|
-
version: '5.2.0-snapshot',
|
|
784
|
-
|
|
785
|
-
_init: function _init() {
|
|
786
|
-
this._initEvents();
|
|
787
|
-
|
|
788
|
-
if (this.options.scrollbars || this.options.indicators) {
|
|
789
|
-
this._initIndicators();
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
if (this.options.mouseWheel) {
|
|
793
|
-
this._initWheel();
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
if (this.options.snap) {
|
|
797
|
-
this._initSnap();
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
if (this.options.keyBindings) {
|
|
801
|
-
this._initKeys();
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
// INSERT POINT: _init
|
|
805
|
-
},
|
|
806
|
-
|
|
807
|
-
destroy: function destroy() {
|
|
808
|
-
this._initEvents(true);
|
|
809
|
-
clearTimeout(this.resizeTimeout);
|
|
810
|
-
this.resizeTimeout = null;
|
|
811
|
-
this._execEvent('destroy');
|
|
812
|
-
},
|
|
813
|
-
|
|
814
|
-
_transitionEnd: function _transitionEnd(e) {
|
|
815
|
-
if (e.target != this.scroller || !this.isInTransition) {
|
|
816
|
-
return;
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
this._transitionTime();
|
|
820
|
-
if (!this.resetPosition(this.options.bounceTime)) {
|
|
821
|
-
this.isInTransition = false;
|
|
822
|
-
this._execEvent('scrollEnd');
|
|
823
|
-
}
|
|
824
|
-
},
|
|
825
|
-
|
|
826
|
-
_start: function _start(e) {
|
|
827
|
-
// React to left mouse button only
|
|
828
|
-
if (utils.eventType[e.type] != 1) {
|
|
829
|
-
// for button property
|
|
830
|
-
// http://unixpapa.com/js/mouse.html
|
|
831
|
-
var button;
|
|
832
|
-
if (!e.which) {
|
|
833
|
-
/* IE case */
|
|
834
|
-
button = e.button < 2 ? 0 : e.button == 4 ? 1 : 2;
|
|
835
|
-
} else {
|
|
836
|
-
/* All others */
|
|
837
|
-
button = e.button;
|
|
838
|
-
}
|
|
839
|
-
if (button !== 0) {
|
|
840
|
-
return;
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
if (!this.enabled || this.initiated && utils.eventType[e.type] !== this.initiated) {
|
|
845
|
-
return;
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
if (this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException)) {
|
|
849
|
-
e.preventDefault();
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
var point = e.touches ? e.touches[0] : e,
|
|
853
|
-
pos;
|
|
854
|
-
|
|
855
|
-
this.initiated = utils.eventType[e.type];
|
|
856
|
-
this.moved = false;
|
|
857
|
-
this.distX = 0;
|
|
858
|
-
this.distY = 0;
|
|
859
|
-
this.directionX = 0;
|
|
860
|
-
this.directionY = 0;
|
|
861
|
-
this.directionLocked = 0;
|
|
862
|
-
|
|
863
|
-
this.startTime = utils.getTime();
|
|
864
|
-
|
|
865
|
-
if (this.options.useTransition && this.isInTransition) {
|
|
866
|
-
this._transitionTime();
|
|
867
|
-
this.isInTransition = false;
|
|
868
|
-
pos = this.getComputedPosition();
|
|
869
|
-
this._translate(Math.round(pos.x), Math.round(pos.y));
|
|
870
|
-
this._execEvent('scrollEnd');
|
|
871
|
-
} else if (!this.options.useTransition && this.isAnimating) {
|
|
872
|
-
this.isAnimating = false;
|
|
873
|
-
this._execEvent('scrollEnd');
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
this.startX = this.x;
|
|
877
|
-
this.startY = this.y;
|
|
878
|
-
this.absStartX = this.x;
|
|
879
|
-
this.absStartY = this.y;
|
|
880
|
-
this.pointX = point.pageX;
|
|
881
|
-
this.pointY = point.pageY;
|
|
882
|
-
|
|
883
|
-
this._execEvent('beforeScrollStart');
|
|
884
|
-
},
|
|
885
|
-
|
|
886
|
-
_move: function _move(e) {
|
|
887
|
-
if (!this.enabled || utils.eventType[e.type] !== this.initiated) {
|
|
888
|
-
return;
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
if (this.options.preventDefault) {
|
|
892
|
-
// increases performance on Android? TODO: check!
|
|
893
|
-
e.preventDefault();
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
var point = e.touches ? e.touches[0] : e,
|
|
897
|
-
deltaX = point.pageX - this.pointX,
|
|
898
|
-
deltaY = point.pageY - this.pointY,
|
|
899
|
-
timestamp = utils.getTime(),
|
|
900
|
-
newX,
|
|
901
|
-
newY,
|
|
902
|
-
absDistX,
|
|
903
|
-
absDistY;
|
|
904
|
-
|
|
905
|
-
this.pointX = point.pageX;
|
|
906
|
-
this.pointY = point.pageY;
|
|
907
|
-
|
|
908
|
-
this.distX += deltaX;
|
|
909
|
-
this.distY += deltaY;
|
|
910
|
-
absDistX = Math.abs(this.distX);
|
|
911
|
-
absDistY = Math.abs(this.distY);
|
|
912
|
-
|
|
913
|
-
// We need to move at least 10 pixels for the scrolling to initiate
|
|
914
|
-
if (timestamp - this.endTime > 300 && absDistX < 10 && absDistY < 10) {
|
|
915
|
-
return;
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
// If you are scrolling in one direction lock the other
|
|
919
|
-
if (!this.directionLocked && !this.options.freeScroll) {
|
|
920
|
-
if (absDistX > absDistY + this.options.directionLockThreshold) {
|
|
921
|
-
this.directionLocked = 'h'; // lock horizontally
|
|
922
|
-
} else if (absDistY >= absDistX + this.options.directionLockThreshold) {
|
|
923
|
-
this.directionLocked = 'v'; // lock vertically
|
|
924
|
-
} else {
|
|
925
|
-
this.directionLocked = 'n'; // no lock
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
if (this.directionLocked == 'h') {
|
|
930
|
-
if (this.options.eventPassthrough == 'vertical') {
|
|
931
|
-
e.preventDefault();
|
|
932
|
-
} else if (this.options.eventPassthrough == 'horizontal') {
|
|
933
|
-
this.initiated = false;
|
|
934
|
-
return;
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
deltaY = 0;
|
|
938
|
-
} else if (this.directionLocked == 'v') {
|
|
939
|
-
if (this.options.eventPassthrough == 'horizontal') {
|
|
940
|
-
e.preventDefault();
|
|
941
|
-
} else if (this.options.eventPassthrough == 'vertical') {
|
|
942
|
-
this.initiated = false;
|
|
943
|
-
return;
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
deltaX = 0;
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
deltaX = this.hasHorizontalScroll ? deltaX : 0;
|
|
950
|
-
deltaY = this.hasVerticalScroll ? deltaY : 0;
|
|
951
|
-
|
|
952
|
-
newX = this.x + deltaX;
|
|
953
|
-
newY = this.y + deltaY;
|
|
954
|
-
|
|
955
|
-
// Slow down if outside of the boundaries
|
|
956
|
-
if (newX > 0 || newX < this.maxScrollX) {
|
|
957
|
-
newX = this.options.bounce ? this.x + deltaX / 3 : newX > 0 ? 0 : this.maxScrollX;
|
|
958
|
-
}
|
|
959
|
-
if (newY > 0 || newY < this.maxScrollY) {
|
|
960
|
-
newY = this.options.bounce ? this.y + deltaY / 3 : newY > 0 ? 0 : this.maxScrollY;
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
this.directionX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
|
|
964
|
-
this.directionY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
|
|
965
|
-
|
|
966
|
-
if (!this.moved) {
|
|
967
|
-
this._execEvent('scrollStart');
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
this.moved = true;
|
|
971
|
-
|
|
972
|
-
this._translate(newX, newY);
|
|
973
|
-
|
|
974
|
-
/* REPLACE START: _move */
|
|
975
|
-
if (timestamp - this.startTime > 300) {
|
|
976
|
-
this.startTime = timestamp;
|
|
977
|
-
this.startX = this.x;
|
|
978
|
-
this.startY = this.y;
|
|
979
|
-
|
|
980
|
-
if (this.options.probeType == 1) {
|
|
981
|
-
this._execEvent('scroll');
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
if (this.options.probeType > 1) {
|
|
986
|
-
this._execEvent('scroll');
|
|
987
|
-
}
|
|
988
|
-
/* REPLACE END: _move */
|
|
989
|
-
},
|
|
990
|
-
|
|
991
|
-
_end: function _end(e) {
|
|
992
|
-
if (!this.enabled || utils.eventType[e.type] !== this.initiated) {
|
|
993
|
-
return;
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
if (this.options.preventDefault && !utils.preventDefaultException(e.target, this.options.preventDefaultException)) {
|
|
997
|
-
e.preventDefault();
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
var point = e.changedTouches ? e.changedTouches[0] : e,
|
|
1001
|
-
momentumX,
|
|
1002
|
-
momentumY,
|
|
1003
|
-
duration = utils.getTime() - this.startTime,
|
|
1004
|
-
newX = Math.round(this.x),
|
|
1005
|
-
newY = Math.round(this.y),
|
|
1006
|
-
distanceX = Math.abs(newX - this.startX),
|
|
1007
|
-
distanceY = Math.abs(newY - this.startY),
|
|
1008
|
-
time = 0,
|
|
1009
|
-
easing = '';
|
|
1010
|
-
|
|
1011
|
-
this.isInTransition = 0;
|
|
1012
|
-
this.initiated = 0;
|
|
1013
|
-
this.endTime = utils.getTime();
|
|
1014
|
-
|
|
1015
|
-
// reset if we are outside of the boundaries
|
|
1016
|
-
if (this.resetPosition(this.options.bounceTime)) {
|
|
1017
|
-
return;
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
this.scrollTo(newX, newY); // ensures that the last position is rounded
|
|
1021
|
-
|
|
1022
|
-
// we scrolled less than 10 pixels
|
|
1023
|
-
if (!this.moved) {
|
|
1024
|
-
if (this.options.tap) {
|
|
1025
|
-
utils.tap(e, this.options.tap);
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
if (this.options.click) {
|
|
1029
|
-
utils.click(e);
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
this._execEvent('scrollCancel');
|
|
1033
|
-
return;
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
if (this._events.flick && duration < 200 && distanceX < 100 && distanceY < 100) {
|
|
1037
|
-
this._execEvent('flick');
|
|
1038
|
-
return;
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
// start momentum animation if needed
|
|
1042
|
-
if (this.options.momentum && duration < 300) {
|
|
1043
|
-
momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 };
|
|
1044
|
-
momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 };
|
|
1045
|
-
newX = momentumX.destination;
|
|
1046
|
-
newY = momentumY.destination;
|
|
1047
|
-
time = Math.max(momentumX.duration, momentumY.duration);
|
|
1048
|
-
this.isInTransition = 1;
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
if (this.options.snap) {
|
|
1052
|
-
var snap = this._nearestSnap(newX, newY);
|
|
1053
|
-
this.currentPage = snap;
|
|
1054
|
-
time = this.options.snapSpeed || Math.max(Math.max(Math.min(Math.abs(newX - snap.x), 1000), Math.min(Math.abs(newY - snap.y), 1000)), 300);
|
|
1055
|
-
newX = snap.x;
|
|
1056
|
-
newY = snap.y;
|
|
1057
|
-
|
|
1058
|
-
this.directionX = 0;
|
|
1059
|
-
this.directionY = 0;
|
|
1060
|
-
easing = this.options.bounceEasing;
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
// INSERT POINT: _end
|
|
1064
|
-
|
|
1065
|
-
if (newX != this.x || newY != this.y) {
|
|
1066
|
-
// change easing function when scroller goes out of the boundaries
|
|
1067
|
-
if (newX > 0 || newX < this.maxScrollX || newY > 0 || newY < this.maxScrollY) {
|
|
1068
|
-
easing = utils.ease.quadratic;
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
this.scrollTo(newX, newY, time, easing);
|
|
1072
|
-
return;
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
this._execEvent('scrollEnd');
|
|
1076
|
-
},
|
|
1077
|
-
|
|
1078
|
-
_resize: function _resize() {
|
|
1079
|
-
var that = this;
|
|
1080
|
-
|
|
1081
|
-
clearTimeout(this.resizeTimeout);
|
|
1082
|
-
|
|
1083
|
-
this.resizeTimeout = setTimeout(function () {
|
|
1084
|
-
that.refresh();
|
|
1085
|
-
}, this.options.resizePolling);
|
|
1086
|
-
},
|
|
1087
|
-
|
|
1088
|
-
resetPosition: function resetPosition(time) {
|
|
1089
|
-
var x = this.x,
|
|
1090
|
-
y = this.y;
|
|
1091
|
-
|
|
1092
|
-
time = time || 0;
|
|
1093
|
-
|
|
1094
|
-
if (!this.hasHorizontalScroll || this.x > 0) {
|
|
1095
|
-
x = 0;
|
|
1096
|
-
} else if (this.x < this.maxScrollX) {
|
|
1097
|
-
x = this.maxScrollX;
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
if (!this.hasVerticalScroll || this.y > 0) {
|
|
1101
|
-
y = 0;
|
|
1102
|
-
} else if (this.y < this.maxScrollY) {
|
|
1103
|
-
y = this.maxScrollY;
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
if (x == this.x && y == this.y) {
|
|
1107
|
-
return false;
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
// 支持下拉刷新的函数注册
|
|
1111
|
-
if (this.options.ptr && this.y > 44 && this.startY * -1 < $(window).height() && !this.ptrLock) {
|
|
1112
|
-
// jshint ignore:line
|
|
1113
|
-
// not trigger ptr when user want to scroll to top
|
|
1114
|
-
y = this.options.ptrOffset || 44;
|
|
1115
|
-
this._execEvent('ptr');
|
|
1116
|
-
// 防止返回的过程中再次触发了 ptr ,导致被定位到 44px(因为可能done事件触发很快,在返回到44px以前就触发done
|
|
1117
|
-
this.ptrLock = true;
|
|
1118
|
-
var self = this;
|
|
1119
|
-
setTimeout(function () {
|
|
1120
|
-
self.ptrLock = false;
|
|
1121
|
-
}, 500);
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
this.scrollTo(x, y, time, this.options.bounceEasing);
|
|
1125
|
-
|
|
1126
|
-
return true;
|
|
1127
|
-
},
|
|
1128
|
-
|
|
1129
|
-
disable: function disable() {
|
|
1130
|
-
this.enabled = false;
|
|
1131
|
-
},
|
|
1132
|
-
|
|
1133
|
-
enable: function enable() {
|
|
1134
|
-
this.enabled = true;
|
|
1135
|
-
},
|
|
1136
|
-
|
|
1137
|
-
refresh: function refresh() {
|
|
1138
|
-
utils.getRect(this.wrapper); // Force reflow
|
|
1139
|
-
|
|
1140
|
-
this.wrapperWidth = this.wrapper.clientWidth;
|
|
1141
|
-
this.wrapperHeight = this.wrapper.clientHeight;
|
|
1142
|
-
|
|
1143
|
-
var rect = utils.getRect(this.scroller);
|
|
1144
|
-
/* REPLACE START: refresh */
|
|
1145
|
-
|
|
1146
|
-
this.scrollerWidth = rect.width;
|
|
1147
|
-
this.scrollerHeight = rect.height;
|
|
1148
|
-
|
|
1149
|
-
this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
|
|
1150
|
-
this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
|
|
1151
|
-
|
|
1152
|
-
/* REPLACE END: refresh */
|
|
1153
|
-
|
|
1154
|
-
this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
|
|
1155
|
-
this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
|
|
1156
|
-
|
|
1157
|
-
if (!this.hasHorizontalScroll) {
|
|
1158
|
-
this.maxScrollX = 0;
|
|
1159
|
-
this.scrollerWidth = this.wrapperWidth;
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
if (!this.hasVerticalScroll) {
|
|
1163
|
-
this.maxScrollY = 0;
|
|
1164
|
-
this.scrollerHeight = this.wrapperHeight;
|
|
1165
|
-
}
|
|
1166
|
-
|
|
1167
|
-
this.endTime = 0;
|
|
1168
|
-
this.directionX = 0;
|
|
1169
|
-
this.directionY = 0;
|
|
1170
|
-
|
|
1171
|
-
if (utils.hasPointer && !this.options.disablePointer) {
|
|
1172
|
-
// The wrapper should have `touchAction` property for using pointerEvent.
|
|
1173
|
-
this.wrapper.style[utils.style.touchAction] = utils.getTouchAction(this.options.eventPassthrough, true);
|
|
1174
|
-
|
|
1175
|
-
// case. not support 'pinch-zoom'
|
|
1176
|
-
// https://github.com/cubiq/iscroll/issues/1118#issuecomment-270057583
|
|
1177
|
-
if (!this.wrapper.style[utils.style.touchAction]) {
|
|
1178
|
-
this.wrapper.style[utils.style.touchAction] = utils.getTouchAction(this.options.eventPassthrough, false);
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
this.wrapperOffset = utils.offset(this.wrapper);
|
|
1182
|
-
|
|
1183
|
-
this._execEvent('refresh');
|
|
1184
|
-
|
|
1185
|
-
this.resetPosition();
|
|
1186
|
-
|
|
1187
|
-
// INSERT POINT: _refresh
|
|
1188
|
-
},
|
|
1189
|
-
|
|
1190
|
-
on: function on(type, fn) {
|
|
1191
|
-
if (!this._events[type]) {
|
|
1192
|
-
this._events[type] = [];
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
this._events[type].push(fn);
|
|
1196
|
-
},
|
|
1197
|
-
|
|
1198
|
-
off: function off(type, fn) {
|
|
1199
|
-
if (!this._events[type]) {
|
|
1200
|
-
return;
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
var index = this._events[type].indexOf(fn);
|
|
1204
|
-
|
|
1205
|
-
if (index > -1) {
|
|
1206
|
-
this._events[type].splice(index, 1);
|
|
1207
|
-
}
|
|
1208
|
-
},
|
|
1209
|
-
|
|
1210
|
-
_execEvent: function _execEvent(type) {
|
|
1211
|
-
if (!this._events[type]) {
|
|
1212
|
-
return;
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
var i = 0,
|
|
1216
|
-
l = this._events[type].length;
|
|
1217
|
-
|
|
1218
|
-
if (!l) {
|
|
1219
|
-
return;
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
for (; i < l; i++) {
|
|
1223
|
-
this._events[type][i].apply(this, [].slice.call(arguments, 1));
|
|
1224
|
-
}
|
|
1225
|
-
},
|
|
1226
|
-
|
|
1227
|
-
scrollBy: function scrollBy(x, y, time, easing) {
|
|
1228
|
-
x = this.x + x;
|
|
1229
|
-
y = this.y + y;
|
|
1230
|
-
time = time || 0;
|
|
1231
|
-
|
|
1232
|
-
this.scrollTo(x, y, time, easing);
|
|
1233
|
-
},
|
|
1234
|
-
|
|
1235
|
-
scrollTo: function scrollTo(x, y, time, easing) {
|
|
1236
|
-
easing = easing || utils.ease.circular;
|
|
1237
|
-
|
|
1238
|
-
this.isInTransition = this.options.useTransition && time > 0;
|
|
1239
|
-
var transitionType = this.options.useTransition && easing.style;
|
|
1240
|
-
if (!time || transitionType) {
|
|
1241
|
-
if (transitionType) {
|
|
1242
|
-
this._transitionTimingFunction(easing.style);
|
|
1243
|
-
this._transitionTime(time);
|
|
1244
|
-
}
|
|
1245
|
-
this._translate(x, y);
|
|
1246
|
-
} else {
|
|
1247
|
-
this._animate(x, y, time, easing.fn);
|
|
1248
|
-
}
|
|
1249
|
-
},
|
|
1250
|
-
|
|
1251
|
-
scrollToElement: function scrollToElement(el, time, offsetX, offsetY, easing) {
|
|
1252
|
-
el = el.nodeType ? el : this.scroller.querySelector(el);
|
|
1253
|
-
|
|
1254
|
-
if (!el) {
|
|
1255
|
-
return;
|
|
1256
|
-
}
|
|
1257
|
-
|
|
1258
|
-
var pos = utils.offset(el);
|
|
1259
|
-
|
|
1260
|
-
pos.left -= this.wrapperOffset.left;
|
|
1261
|
-
pos.top -= this.wrapperOffset.top;
|
|
1262
|
-
|
|
1263
|
-
// if offsetX/Y are true we center the element to the screen
|
|
1264
|
-
var elRect = utils.getRect(el);
|
|
1265
|
-
var wrapperRect = utils.getRect(this.wrapper);
|
|
1266
|
-
if (offsetX === true) {
|
|
1267
|
-
offsetX = Math.round(elRect.width / 2 - wrapperRect.width / 2);
|
|
1268
|
-
}
|
|
1269
|
-
if (offsetY === true) {
|
|
1270
|
-
offsetY = Math.round(elRect.height / 2 - wrapperRect.height / 2);
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
pos.left -= offsetX || 0;
|
|
1274
|
-
pos.top -= offsetY || 0;
|
|
1275
|
-
|
|
1276
|
-
pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left;
|
|
1277
|
-
pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top;
|
|
1278
|
-
|
|
1279
|
-
time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(this.x - pos.left), Math.abs(this.y - pos.top)) : time;
|
|
1280
|
-
|
|
1281
|
-
this.scrollTo(pos.left, pos.top, time, easing);
|
|
1282
|
-
},
|
|
1283
|
-
|
|
1284
|
-
_transitionTime: function _transitionTime(time) {
|
|
1285
|
-
if (!this.options.useTransition) {
|
|
1286
|
-
return;
|
|
1287
|
-
}
|
|
1288
|
-
time = time || 0;
|
|
1289
|
-
var durationProp = utils.style.transitionDuration;
|
|
1290
|
-
if (!durationProp) {
|
|
1291
|
-
return;
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
this.scrollerStyle[durationProp] = time + 'ms';
|
|
1295
|
-
|
|
1296
|
-
if (!time && utils.isBadAndroid) {
|
|
1297
|
-
this.scrollerStyle[durationProp] = '0.0001ms';
|
|
1298
|
-
// remove 0.0001ms
|
|
1299
|
-
var self = this;
|
|
1300
|
-
rAF(function () {
|
|
1301
|
-
if (self.scrollerStyle[durationProp] === '0.0001ms') {
|
|
1302
|
-
self.scrollerStyle[durationProp] = '0s';
|
|
1303
|
-
}
|
|
1304
|
-
});
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
if (this.indicators) {
|
|
1308
|
-
for (var i = this.indicators.length; i--;) {
|
|
1309
|
-
this.indicators[i].transitionTime(time);
|
|
1310
|
-
}
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
// INSERT POINT: _transitionTime
|
|
1314
|
-
},
|
|
1315
|
-
|
|
1316
|
-
_transitionTimingFunction: function _transitionTimingFunction(easing) {
|
|
1317
|
-
this.scrollerStyle[utils.style.transitionTimingFunction] = easing;
|
|
1318
|
-
|
|
1319
|
-
if (this.indicators) {
|
|
1320
|
-
for (var i = this.indicators.length; i--;) {
|
|
1321
|
-
this.indicators[i].transitionTimingFunction(easing);
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
// INSERT POINT: _transitionTimingFunction
|
|
1326
|
-
},
|
|
1327
|
-
|
|
1328
|
-
_translate: function _translate(x, y) {
|
|
1329
|
-
if (this.options.useTransform) {
|
|
1330
|
-
|
|
1331
|
-
/* REPLACE START: _translate */
|
|
1332
|
-
|
|
1333
|
-
this.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.translateZ;
|
|
1334
|
-
|
|
1335
|
-
/* REPLACE END: _translate */
|
|
1336
|
-
} else {
|
|
1337
|
-
x = Math.round(x);
|
|
1338
|
-
y = Math.round(y);
|
|
1339
|
-
this.scrollerStyle.left = x + 'px';
|
|
1340
|
-
this.scrollerStyle.top = y + 'px';
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
this.x = x;
|
|
1344
|
-
this.y = y;
|
|
1345
|
-
|
|
1346
|
-
if (this.indicators) {
|
|
1347
|
-
for (var i = this.indicators.length; i--;) {
|
|
1348
|
-
this.indicators[i].updatePosition();
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
// INSERT POINT: _translate
|
|
1353
|
-
},
|
|
1354
|
-
|
|
1355
|
-
_initEvents: function _initEvents(remove) {
|
|
1356
|
-
var eventType = remove ? utils.removeEvent : utils.addEvent,
|
|
1357
|
-
target = this.options.bindToWrapper ? this.wrapper : window;
|
|
1358
|
-
|
|
1359
|
-
eventType(window, 'orientationchange', this);
|
|
1360
|
-
eventType(window, 'resize', this);
|
|
1361
|
-
|
|
1362
|
-
if (this.options.click) {
|
|
1363
|
-
eventType(this.wrapper, 'click', this, true);
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
if (!this.options.disableMouse) {
|
|
1367
|
-
eventType(this.wrapper, 'mousedown', this);
|
|
1368
|
-
eventType(target, 'mousemove', this);
|
|
1369
|
-
eventType(target, 'mousecancel', this);
|
|
1370
|
-
eventType(target, 'mouseup', this);
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
if (utils.hasPointer && !this.options.disablePointer) {
|
|
1374
|
-
eventType(this.wrapper, utils.prefixPointerEvent('pointerdown'), this);
|
|
1375
|
-
eventType(target, utils.prefixPointerEvent('pointermove'), this);
|
|
1376
|
-
eventType(target, utils.prefixPointerEvent('pointercancel'), this);
|
|
1377
|
-
eventType(target, utils.prefixPointerEvent('pointerup'), this);
|
|
1378
|
-
}
|
|
1379
|
-
|
|
1380
|
-
if (utils.hasTouch && !this.options.disableTouch) {
|
|
1381
|
-
eventType(this.wrapper, 'touchstart', this);
|
|
1382
|
-
eventType(target, 'touchmove', this);
|
|
1383
|
-
eventType(target, 'touchcancel', this);
|
|
1384
|
-
eventType(target, 'touchend', this);
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
eventType(this.scroller, 'transitionend', this);
|
|
1388
|
-
eventType(this.scroller, 'webkitTransitionEnd', this);
|
|
1389
|
-
eventType(this.scroller, 'oTransitionEnd', this);
|
|
1390
|
-
eventType(this.scroller, 'MSTransitionEnd', this);
|
|
1391
|
-
},
|
|
1392
|
-
|
|
1393
|
-
getComputedPosition: function getComputedPosition() {
|
|
1394
|
-
var matrix = window.getComputedStyle(this.scroller, null),
|
|
1395
|
-
x,
|
|
1396
|
-
y;
|
|
1397
|
-
|
|
1398
|
-
if (this.options.useTransform) {
|
|
1399
|
-
matrix = matrix[utils.style.transform].split(')')[0].split(', ');
|
|
1400
|
-
x = +(matrix[12] || matrix[4]);
|
|
1401
|
-
y = +(matrix[13] || matrix[5]);
|
|
1402
|
-
} else {
|
|
1403
|
-
x = +matrix.left.replace(/[^-\d.]/g, '');
|
|
1404
|
-
y = +matrix.top.replace(/[^-\d.]/g, '');
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
return { x: x, y: y };
|
|
1408
|
-
},
|
|
1409
|
-
_initIndicators: function _initIndicators() {
|
|
1410
|
-
var interactive = this.options.interactiveScrollbars,
|
|
1411
|
-
customStyle = typeof this.options.scrollbars != 'string',
|
|
1412
|
-
indicators = [],
|
|
1413
|
-
indicator;
|
|
1414
|
-
|
|
1415
|
-
var that = this;
|
|
1416
|
-
|
|
1417
|
-
this.indicators = [];
|
|
1418
|
-
|
|
1419
|
-
if (this.options.scrollbars) {
|
|
1420
|
-
// Vertical scrollbar
|
|
1421
|
-
if (this.options.scrollY) {
|
|
1422
|
-
indicator = {
|
|
1423
|
-
el: createDefaultScrollbar('v', interactive, this.options.scrollbars),
|
|
1424
|
-
interactive: interactive,
|
|
1425
|
-
defaultScrollbars: true,
|
|
1426
|
-
customStyle: customStyle,
|
|
1427
|
-
resize: this.options.resizeScrollbars,
|
|
1428
|
-
shrink: this.options.shrinkScrollbars,
|
|
1429
|
-
fade: this.options.fadeScrollbars,
|
|
1430
|
-
listenX: false
|
|
1431
|
-
};
|
|
1432
|
-
|
|
1433
|
-
this.wrapper.appendChild(indicator.el);
|
|
1434
|
-
indicators.push(indicator);
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
// Horizontal scrollbar
|
|
1438
|
-
if (this.options.scrollX) {
|
|
1439
|
-
indicator = {
|
|
1440
|
-
el: createDefaultScrollbar('h', interactive, this.options.scrollbars),
|
|
1441
|
-
interactive: interactive,
|
|
1442
|
-
defaultScrollbars: true,
|
|
1443
|
-
customStyle: customStyle,
|
|
1444
|
-
resize: this.options.resizeScrollbars,
|
|
1445
|
-
shrink: this.options.shrinkScrollbars,
|
|
1446
|
-
fade: this.options.fadeScrollbars,
|
|
1447
|
-
listenY: false
|
|
1448
|
-
};
|
|
1449
|
-
|
|
1450
|
-
this.wrapper.appendChild(indicator.el);
|
|
1451
|
-
indicators.push(indicator);
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
if (this.options.indicators) {
|
|
1456
|
-
// TODO: check concat compatibility
|
|
1457
|
-
indicators = indicators.concat(this.options.indicators);
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
for (var i = indicators.length; i--;) {
|
|
1461
|
-
this.indicators.push(new Indicator(this, indicators[i]));
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
// TODO: check if we can use array.map (wide compatibility and performance issues)
|
|
1465
|
-
function _indicatorsMap(fn) {
|
|
1466
|
-
if (that.indicators) {
|
|
1467
|
-
for (var i = that.indicators.length; i--;) {
|
|
1468
|
-
fn.call(that.indicators[i]);
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
if (this.options.fadeScrollbars) {
|
|
1474
|
-
this.on('scrollEnd', function () {
|
|
1475
|
-
_indicatorsMap(function () {
|
|
1476
|
-
this.fade();
|
|
1477
|
-
});
|
|
1478
|
-
});
|
|
1479
|
-
|
|
1480
|
-
this.on('scrollCancel', function () {
|
|
1481
|
-
_indicatorsMap(function () {
|
|
1482
|
-
this.fade();
|
|
1483
|
-
});
|
|
1484
|
-
});
|
|
1485
|
-
|
|
1486
|
-
this.on('scrollStart', function () {
|
|
1487
|
-
_indicatorsMap(function () {
|
|
1488
|
-
this.fade(1);
|
|
1489
|
-
});
|
|
1490
|
-
});
|
|
1491
|
-
|
|
1492
|
-
this.on('beforeScrollStart', function () {
|
|
1493
|
-
_indicatorsMap(function () {
|
|
1494
|
-
this.fade(1, true);
|
|
1495
|
-
});
|
|
1496
|
-
});
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
this.on('refresh', function () {
|
|
1500
|
-
_indicatorsMap(function () {
|
|
1501
|
-
this.refresh();
|
|
1502
|
-
});
|
|
1503
|
-
});
|
|
1504
|
-
|
|
1505
|
-
this.on('destroy', function () {
|
|
1506
|
-
_indicatorsMap(function () {
|
|
1507
|
-
this.destroy();
|
|
1508
|
-
});
|
|
1509
|
-
|
|
1510
|
-
delete this.indicators;
|
|
1511
|
-
});
|
|
1512
|
-
},
|
|
1513
|
-
|
|
1514
|
-
_initWheel: function _initWheel() {
|
|
1515
|
-
utils.addEvent(this.wrapper, 'wheel', this);
|
|
1516
|
-
utils.addEvent(this.wrapper, 'mousewheel', this);
|
|
1517
|
-
utils.addEvent(this.wrapper, 'DOMMouseScroll', this);
|
|
1518
|
-
|
|
1519
|
-
this.on('destroy', function () {
|
|
1520
|
-
clearTimeout(this.wheelTimeout);
|
|
1521
|
-
this.wheelTimeout = null;
|
|
1522
|
-
utils.removeEvent(this.wrapper, 'wheel', this);
|
|
1523
|
-
utils.removeEvent(this.wrapper, 'mousewheel', this);
|
|
1524
|
-
utils.removeEvent(this.wrapper, 'DOMMouseScroll', this);
|
|
1525
|
-
});
|
|
1526
|
-
},
|
|
1527
|
-
|
|
1528
|
-
_wheel: function _wheel(e) {
|
|
1529
|
-
if (!this.enabled) {
|
|
1530
|
-
return;
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
e.preventDefault();
|
|
1534
|
-
|
|
1535
|
-
var wheelDeltaX,
|
|
1536
|
-
wheelDeltaY,
|
|
1537
|
-
newX,
|
|
1538
|
-
newY,
|
|
1539
|
-
that = this;
|
|
1540
|
-
|
|
1541
|
-
if (this.wheelTimeout === undefined) {
|
|
1542
|
-
that._execEvent('scrollStart');
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
// Execute the scrollEnd event after 400ms the wheel stopped scrolling
|
|
1546
|
-
clearTimeout(this.wheelTimeout);
|
|
1547
|
-
this.wheelTimeout = setTimeout(function () {
|
|
1548
|
-
if (!that.options.snap) {
|
|
1549
|
-
that._execEvent('scrollEnd');
|
|
1550
|
-
}
|
|
1551
|
-
that.wheelTimeout = undefined;
|
|
1552
|
-
}, 400);
|
|
1553
|
-
|
|
1554
|
-
if ('deltaX' in e) {
|
|
1555
|
-
if (e.deltaMode === 1) {
|
|
1556
|
-
wheelDeltaX = -e.deltaX * this.options.mouseWheelSpeed;
|
|
1557
|
-
wheelDeltaY = -e.deltaY * this.options.mouseWheelSpeed;
|
|
1558
|
-
} else {
|
|
1559
|
-
wheelDeltaX = -e.deltaX;
|
|
1560
|
-
wheelDeltaY = -e.deltaY;
|
|
1561
|
-
}
|
|
1562
|
-
} else if ('wheelDeltaX' in e) {
|
|
1563
|
-
wheelDeltaX = e.wheelDeltaX / 120 * this.options.mouseWheelSpeed;
|
|
1564
|
-
wheelDeltaY = e.wheelDeltaY / 120 * this.options.mouseWheelSpeed;
|
|
1565
|
-
} else if ('wheelDelta' in e) {
|
|
1566
|
-
wheelDeltaX = wheelDeltaY = e.wheelDelta / 120 * this.options.mouseWheelSpeed;
|
|
1567
|
-
} else if ('detail' in e) {
|
|
1568
|
-
wheelDeltaX = wheelDeltaY = -e.detail / 3 * this.options.mouseWheelSpeed;
|
|
1569
|
-
} else {
|
|
1570
|
-
return;
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
|
-
wheelDeltaX *= this.options.invertWheelDirection;
|
|
1574
|
-
wheelDeltaY *= this.options.invertWheelDirection;
|
|
1575
|
-
|
|
1576
|
-
if (!this.hasVerticalScroll) {
|
|
1577
|
-
wheelDeltaX = wheelDeltaY;
|
|
1578
|
-
wheelDeltaY = 0;
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
if (this.options.snap) {
|
|
1582
|
-
newX = this.currentPage.pageX;
|
|
1583
|
-
newY = this.currentPage.pageY;
|
|
1584
|
-
|
|
1585
|
-
if (wheelDeltaX > 0) {
|
|
1586
|
-
newX--;
|
|
1587
|
-
} else if (wheelDeltaX < 0) {
|
|
1588
|
-
newX++;
|
|
1589
|
-
}
|
|
1590
|
-
|
|
1591
|
-
if (wheelDeltaY > 0) {
|
|
1592
|
-
newY--;
|
|
1593
|
-
} else if (wheelDeltaY < 0) {
|
|
1594
|
-
newY++;
|
|
1595
|
-
}
|
|
1596
|
-
|
|
1597
|
-
this.goToPage(newX, newY);
|
|
1598
|
-
|
|
1599
|
-
return;
|
|
1600
|
-
}
|
|
1601
|
-
|
|
1602
|
-
newX = this.x + Math.round(this.hasHorizontalScroll ? wheelDeltaX : 0);
|
|
1603
|
-
newY = this.y + Math.round(this.hasVerticalScroll ? wheelDeltaY : 0);
|
|
1604
|
-
|
|
1605
|
-
this.directionX = wheelDeltaX > 0 ? -1 : wheelDeltaX < 0 ? 1 : 0;
|
|
1606
|
-
this.directionY = wheelDeltaY > 0 ? -1 : wheelDeltaY < 0 ? 1 : 0;
|
|
1607
|
-
|
|
1608
|
-
if (newX > 0) {
|
|
1609
|
-
newX = 0;
|
|
1610
|
-
} else if (newX < this.maxScrollX) {
|
|
1611
|
-
newX = this.maxScrollX;
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
|
-
if (newY > 0) {
|
|
1615
|
-
newY = 0;
|
|
1616
|
-
} else if (newY < this.maxScrollY) {
|
|
1617
|
-
newY = this.maxScrollY;
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
this.scrollTo(newX, newY, 0);
|
|
1621
|
-
|
|
1622
|
-
if (this.options.probeType > 1) {
|
|
1623
|
-
this._execEvent('scroll');
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
|
-
// INSERT POINT: _wheel
|
|
1627
|
-
},
|
|
1628
|
-
|
|
1629
|
-
_initSnap: function _initSnap() {
|
|
1630
|
-
this.currentPage = {};
|
|
1631
|
-
|
|
1632
|
-
if (typeof this.options.snap == 'string') {
|
|
1633
|
-
this.options.snap = this.scroller.querySelectorAll(this.options.snap);
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
|
-
this.on('refresh', function () {
|
|
1637
|
-
var i = 0,
|
|
1638
|
-
l,
|
|
1639
|
-
m = 0,
|
|
1640
|
-
n,
|
|
1641
|
-
cx,
|
|
1642
|
-
cy,
|
|
1643
|
-
x = 0,
|
|
1644
|
-
y,
|
|
1645
|
-
stepX = this.options.snapStepX || this.wrapperWidth,
|
|
1646
|
-
stepY = this.options.snapStepY || this.wrapperHeight,
|
|
1647
|
-
el,
|
|
1648
|
-
rect;
|
|
1649
|
-
|
|
1650
|
-
this.pages = [];
|
|
1651
|
-
|
|
1652
|
-
if (!this.wrapperWidth || !this.wrapperHeight || !this.scrollerWidth || !this.scrollerHeight) {
|
|
1653
|
-
return;
|
|
1654
|
-
}
|
|
1655
|
-
|
|
1656
|
-
if (this.options.snap === true) {
|
|
1657
|
-
cx = Math.round(stepX / 2);
|
|
1658
|
-
cy = Math.round(stepY / 2);
|
|
1659
|
-
|
|
1660
|
-
while (x > -this.scrollerWidth) {
|
|
1661
|
-
this.pages[i] = [];
|
|
1662
|
-
l = 0;
|
|
1663
|
-
y = 0;
|
|
1664
|
-
|
|
1665
|
-
while (y > -this.scrollerHeight) {
|
|
1666
|
-
this.pages[i][l] = {
|
|
1667
|
-
x: Math.max(x, this.maxScrollX),
|
|
1668
|
-
y: Math.max(y, this.maxScrollY),
|
|
1669
|
-
width: stepX,
|
|
1670
|
-
height: stepY,
|
|
1671
|
-
cx: x - cx,
|
|
1672
|
-
cy: y - cy
|
|
1673
|
-
};
|
|
1674
|
-
|
|
1675
|
-
y -= stepY;
|
|
1676
|
-
l++;
|
|
1677
|
-
}
|
|
1678
|
-
|
|
1679
|
-
x -= stepX;
|
|
1680
|
-
i++;
|
|
1681
|
-
}
|
|
1682
|
-
} else {
|
|
1683
|
-
el = this.options.snap;
|
|
1684
|
-
l = el.length;
|
|
1685
|
-
n = -1;
|
|
1686
|
-
|
|
1687
|
-
for (; i < l; i++) {
|
|
1688
|
-
rect = utils.getRect(el[i]);
|
|
1689
|
-
if (i === 0 || rect.left <= utils.getRect(el[i - 1]).left) {
|
|
1690
|
-
m = 0;
|
|
1691
|
-
n++;
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
if (!this.pages[m]) {
|
|
1695
|
-
this.pages[m] = [];
|
|
1696
|
-
}
|
|
1697
|
-
|
|
1698
|
-
x = Math.max(-rect.left, this.maxScrollX);
|
|
1699
|
-
y = Math.max(-rect.top, this.maxScrollY);
|
|
1700
|
-
cx = x - Math.round(rect.width / 2);
|
|
1701
|
-
cy = y - Math.round(rect.height / 2);
|
|
1702
|
-
|
|
1703
|
-
this.pages[m][n] = {
|
|
1704
|
-
x: x,
|
|
1705
|
-
y: y,
|
|
1706
|
-
width: rect.width,
|
|
1707
|
-
height: rect.height,
|
|
1708
|
-
cx: cx,
|
|
1709
|
-
cy: cy
|
|
1710
|
-
};
|
|
1711
|
-
|
|
1712
|
-
if (x > this.maxScrollX) {
|
|
1713
|
-
m++;
|
|
1714
|
-
}
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
|
|
1718
|
-
this.goToPage(this.currentPage.pageX || 0, this.currentPage.pageY || 0, 0);
|
|
1719
|
-
|
|
1720
|
-
// Update snap threshold if needed
|
|
1721
|
-
if (this.options.snapThreshold % 1 === 0) {
|
|
1722
|
-
this.snapThresholdX = this.options.snapThreshold;
|
|
1723
|
-
this.snapThresholdY = this.options.snapThreshold;
|
|
1724
|
-
} else {
|
|
1725
|
-
this.snapThresholdX = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width * this.options.snapThreshold);
|
|
1726
|
-
this.snapThresholdY = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height * this.options.snapThreshold);
|
|
1727
|
-
}
|
|
1728
|
-
});
|
|
1729
|
-
|
|
1730
|
-
this.on('flick', function () {
|
|
1731
|
-
var time = this.options.snapSpeed || Math.max(Math.max(Math.min(Math.abs(this.x - this.startX), 1000), Math.min(Math.abs(this.y - this.startY), 1000)), 300);
|
|
1732
|
-
|
|
1733
|
-
this.goToPage(this.currentPage.pageX + this.directionX, this.currentPage.pageY + this.directionY, time);
|
|
1734
|
-
});
|
|
1735
|
-
},
|
|
1736
|
-
|
|
1737
|
-
_nearestSnap: function _nearestSnap(x, y) {
|
|
1738
|
-
if (!this.pages.length) {
|
|
1739
|
-
return { x: 0, y: 0, pageX: 0, pageY: 0 };
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
var i = 0,
|
|
1743
|
-
l = this.pages.length,
|
|
1744
|
-
m = 0;
|
|
1745
|
-
|
|
1746
|
-
// Check if we exceeded the snap threshold
|
|
1747
|
-
if (Math.abs(x - this.absStartX) < this.snapThresholdX && Math.abs(y - this.absStartY) < this.snapThresholdY) {
|
|
1748
|
-
return this.currentPage;
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
|
-
if (x > 0) {
|
|
1752
|
-
x = 0;
|
|
1753
|
-
} else if (x < this.maxScrollX) {
|
|
1754
|
-
x = this.maxScrollX;
|
|
1755
|
-
}
|
|
1756
|
-
|
|
1757
|
-
if (y > 0) {
|
|
1758
|
-
y = 0;
|
|
1759
|
-
} else if (y < this.maxScrollY) {
|
|
1760
|
-
y = this.maxScrollY;
|
|
1761
|
-
}
|
|
1762
|
-
|
|
1763
|
-
for (; i < l; i++) {
|
|
1764
|
-
if (x >= this.pages[i][0].cx) {
|
|
1765
|
-
x = this.pages[i][0].x;
|
|
1766
|
-
break;
|
|
1767
|
-
}
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
l = this.pages[i].length;
|
|
1771
|
-
|
|
1772
|
-
for (; m < l; m++) {
|
|
1773
|
-
if (y >= this.pages[0][m].cy) {
|
|
1774
|
-
y = this.pages[0][m].y;
|
|
1775
|
-
break;
|
|
1776
|
-
}
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
|
-
if (i == this.currentPage.pageX) {
|
|
1780
|
-
i += this.directionX;
|
|
1781
|
-
|
|
1782
|
-
if (i < 0) {
|
|
1783
|
-
i = 0;
|
|
1784
|
-
} else if (i >= this.pages.length) {
|
|
1785
|
-
i = this.pages.length - 1;
|
|
1786
|
-
}
|
|
1787
|
-
|
|
1788
|
-
x = this.pages[i][0].x;
|
|
1789
|
-
}
|
|
1790
|
-
|
|
1791
|
-
if (m == this.currentPage.pageY) {
|
|
1792
|
-
m += this.directionY;
|
|
1793
|
-
|
|
1794
|
-
if (m < 0) {
|
|
1795
|
-
m = 0;
|
|
1796
|
-
} else if (m >= this.pages[0].length) {
|
|
1797
|
-
m = this.pages[0].length - 1;
|
|
1798
|
-
}
|
|
1799
|
-
|
|
1800
|
-
y = this.pages[0][m].y;
|
|
1801
|
-
}
|
|
1802
|
-
|
|
1803
|
-
return {
|
|
1804
|
-
x: x,
|
|
1805
|
-
y: y,
|
|
1806
|
-
pageX: i,
|
|
1807
|
-
pageY: m
|
|
1808
|
-
};
|
|
1809
|
-
},
|
|
1810
|
-
|
|
1811
|
-
goToPage: function goToPage(x, y, time, easing) {
|
|
1812
|
-
easing = easing || this.options.bounceEasing;
|
|
1813
|
-
|
|
1814
|
-
if (x >= this.pages.length) {
|
|
1815
|
-
x = this.pages.length - 1;
|
|
1816
|
-
} else if (x < 0) {
|
|
1817
|
-
x = 0;
|
|
1818
|
-
}
|
|
1819
|
-
|
|
1820
|
-
if (y >= this.pages[x].length) {
|
|
1821
|
-
y = this.pages[x].length - 1;
|
|
1822
|
-
} else if (y < 0) {
|
|
1823
|
-
y = 0;
|
|
1824
|
-
}
|
|
1825
|
-
|
|
1826
|
-
var posX = this.pages[x][y].x,
|
|
1827
|
-
posY = this.pages[x][y].y;
|
|
1828
|
-
|
|
1829
|
-
time = time === undefined ? this.options.snapSpeed || Math.max(Math.max(Math.min(Math.abs(posX - this.x), 1000), Math.min(Math.abs(posY - this.y), 1000)), 300) : time;
|
|
1830
|
-
|
|
1831
|
-
this.currentPage = {
|
|
1832
|
-
x: posX,
|
|
1833
|
-
y: posY,
|
|
1834
|
-
pageX: x,
|
|
1835
|
-
pageY: y
|
|
1836
|
-
};
|
|
1837
|
-
|
|
1838
|
-
this.scrollTo(posX, posY, time, easing);
|
|
1839
|
-
},
|
|
1840
|
-
|
|
1841
|
-
next: function next(time, easing) {
|
|
1842
|
-
var x = this.currentPage.pageX,
|
|
1843
|
-
y = this.currentPage.pageY;
|
|
1844
|
-
|
|
1845
|
-
x++;
|
|
1846
|
-
|
|
1847
|
-
if (x >= this.pages.length && this.hasVerticalScroll) {
|
|
1848
|
-
x = 0;
|
|
1849
|
-
y++;
|
|
1850
|
-
}
|
|
1851
|
-
|
|
1852
|
-
this.goToPage(x, y, time, easing);
|
|
1853
|
-
},
|
|
1854
|
-
|
|
1855
|
-
prev: function prev(time, easing) {
|
|
1856
|
-
var x = this.currentPage.pageX,
|
|
1857
|
-
y = this.currentPage.pageY;
|
|
1858
|
-
|
|
1859
|
-
x--;
|
|
1860
|
-
|
|
1861
|
-
if (x < 0 && this.hasVerticalScroll) {
|
|
1862
|
-
x = 0;
|
|
1863
|
-
y--;
|
|
1864
|
-
}
|
|
1865
|
-
|
|
1866
|
-
this.goToPage(x, y, time, easing);
|
|
1867
|
-
},
|
|
1868
|
-
|
|
1869
|
-
_initKeys: function _initKeys(e) {
|
|
1870
|
-
// default key bindings
|
|
1871
|
-
var keys = {
|
|
1872
|
-
pageUp: 33,
|
|
1873
|
-
pageDown: 34,
|
|
1874
|
-
end: 35,
|
|
1875
|
-
home: 36,
|
|
1876
|
-
left: 37,
|
|
1877
|
-
up: 38,
|
|
1878
|
-
right: 39,
|
|
1879
|
-
down: 40
|
|
1880
|
-
};
|
|
1881
|
-
var i;
|
|
1882
|
-
|
|
1883
|
-
// if you give me characters I give you keycode
|
|
1884
|
-
if (_typeof(this.options.keyBindings) == 'object') {
|
|
1885
|
-
for (i in this.options.keyBindings) {
|
|
1886
|
-
if (typeof this.options.keyBindings[i] == 'string') {
|
|
1887
|
-
this.options.keyBindings[i] = this.options.keyBindings[i].toUpperCase().charCodeAt(0);
|
|
1888
|
-
}
|
|
1889
|
-
}
|
|
1890
|
-
} else {
|
|
1891
|
-
this.options.keyBindings = {};
|
|
1892
|
-
}
|
|
1893
|
-
|
|
1894
|
-
for (i in keys) {
|
|
1895
|
-
this.options.keyBindings[i] = this.options.keyBindings[i] || keys[i];
|
|
1896
|
-
}
|
|
1897
|
-
|
|
1898
|
-
utils.addEvent(window, 'keydown', this);
|
|
1899
|
-
|
|
1900
|
-
this.on('destroy', function () {
|
|
1901
|
-
utils.removeEvent(window, 'keydown', this);
|
|
1902
|
-
});
|
|
1903
|
-
},
|
|
1904
|
-
|
|
1905
|
-
_key: function _key(e) {
|
|
1906
|
-
if (!this.enabled) {
|
|
1907
|
-
return;
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
var snap = this.options.snap,
|
|
1911
|
-
// we are using this alot, better to cache it
|
|
1912
|
-
newX = snap ? this.currentPage.pageX : this.x,
|
|
1913
|
-
newY = snap ? this.currentPage.pageY : this.y,
|
|
1914
|
-
now = utils.getTime(),
|
|
1915
|
-
prevTime = this.keyTime || 0,
|
|
1916
|
-
acceleration = 0.250,
|
|
1917
|
-
pos;
|
|
1918
|
-
|
|
1919
|
-
if (this.options.useTransition && this.isInTransition) {
|
|
1920
|
-
pos = this.getComputedPosition();
|
|
1921
|
-
|
|
1922
|
-
this._translate(Math.round(pos.x), Math.round(pos.y));
|
|
1923
|
-
this.isInTransition = false;
|
|
1924
|
-
}
|
|
1925
|
-
|
|
1926
|
-
this.keyAcceleration = now - prevTime < 200 ? Math.min(this.keyAcceleration + acceleration, 50) : 0;
|
|
1927
|
-
|
|
1928
|
-
switch (e.keyCode) {
|
|
1929
|
-
case this.options.keyBindings.pageUp:
|
|
1930
|
-
if (this.hasHorizontalScroll && !this.hasVerticalScroll) {
|
|
1931
|
-
newX += snap ? 1 : this.wrapperWidth;
|
|
1932
|
-
} else {
|
|
1933
|
-
newY += snap ? 1 : this.wrapperHeight;
|
|
1934
|
-
}
|
|
1935
|
-
break;
|
|
1936
|
-
case this.options.keyBindings.pageDown:
|
|
1937
|
-
if (this.hasHorizontalScroll && !this.hasVerticalScroll) {
|
|
1938
|
-
newX -= snap ? 1 : this.wrapperWidth;
|
|
1939
|
-
} else {
|
|
1940
|
-
newY -= snap ? 1 : this.wrapperHeight;
|
|
1941
|
-
}
|
|
1942
|
-
break;
|
|
1943
|
-
case this.options.keyBindings.end:
|
|
1944
|
-
newX = snap ? this.pages.length - 1 : this.maxScrollX;
|
|
1945
|
-
newY = snap ? this.pages[0].length - 1 : this.maxScrollY;
|
|
1946
|
-
break;
|
|
1947
|
-
case this.options.keyBindings.home:
|
|
1948
|
-
newX = 0;
|
|
1949
|
-
newY = 0;
|
|
1950
|
-
break;
|
|
1951
|
-
case this.options.keyBindings.left:
|
|
1952
|
-
newX += snap ? -1 : 5 + this.keyAcceleration >> 0;
|
|
1953
|
-
break;
|
|
1954
|
-
case this.options.keyBindings.up:
|
|
1955
|
-
newY += snap ? 1 : 5 + this.keyAcceleration >> 0;
|
|
1956
|
-
break;
|
|
1957
|
-
case this.options.keyBindings.right:
|
|
1958
|
-
newX -= snap ? -1 : 5 + this.keyAcceleration >> 0;
|
|
1959
|
-
break;
|
|
1960
|
-
case this.options.keyBindings.down:
|
|
1961
|
-
newY -= snap ? 1 : 5 + this.keyAcceleration >> 0;
|
|
1962
|
-
break;
|
|
1963
|
-
default:
|
|
1964
|
-
return;
|
|
1965
|
-
}
|
|
1966
|
-
|
|
1967
|
-
if (snap) {
|
|
1968
|
-
this.goToPage(newX, newY);
|
|
1969
|
-
return;
|
|
1970
|
-
}
|
|
1971
|
-
|
|
1972
|
-
if (newX > 0) {
|
|
1973
|
-
newX = 0;
|
|
1974
|
-
this.keyAcceleration = 0;
|
|
1975
|
-
} else if (newX < this.maxScrollX) {
|
|
1976
|
-
newX = this.maxScrollX;
|
|
1977
|
-
this.keyAcceleration = 0;
|
|
1978
|
-
}
|
|
1979
|
-
|
|
1980
|
-
if (newY > 0) {
|
|
1981
|
-
newY = 0;
|
|
1982
|
-
this.keyAcceleration = 0;
|
|
1983
|
-
} else if (newY < this.maxScrollY) {
|
|
1984
|
-
newY = this.maxScrollY;
|
|
1985
|
-
this.keyAcceleration = 0;
|
|
1986
|
-
}
|
|
1987
|
-
|
|
1988
|
-
this.scrollTo(newX, newY, 0);
|
|
1989
|
-
|
|
1990
|
-
this.keyTime = now;
|
|
1991
|
-
},
|
|
1992
|
-
|
|
1993
|
-
_animate: function _animate(destX, destY, duration, easingFn) {
|
|
1994
|
-
var that = this,
|
|
1995
|
-
startX = this.x,
|
|
1996
|
-
startY = this.y,
|
|
1997
|
-
startTime = utils.getTime(),
|
|
1998
|
-
destTime = startTime + duration;
|
|
1999
|
-
|
|
2000
|
-
function step() {
|
|
2001
|
-
var now = utils.getTime(),
|
|
2002
|
-
newX,
|
|
2003
|
-
newY,
|
|
2004
|
-
easing;
|
|
2005
|
-
|
|
2006
|
-
if (now >= destTime) {
|
|
2007
|
-
that.isAnimating = false;
|
|
2008
|
-
that._translate(destX, destY);
|
|
2009
|
-
|
|
2010
|
-
if (!that.resetPosition(that.options.bounceTime)) {
|
|
2011
|
-
that._execEvent('scrollEnd');
|
|
2012
|
-
}
|
|
2013
|
-
|
|
2014
|
-
return;
|
|
2015
|
-
}
|
|
2016
|
-
|
|
2017
|
-
now = (now - startTime) / duration;
|
|
2018
|
-
easing = easingFn(now);
|
|
2019
|
-
newX = (destX - startX) * easing + startX;
|
|
2020
|
-
newY = (destY - startY) * easing + startY;
|
|
2021
|
-
that._translate(newX, newY);
|
|
2022
|
-
|
|
2023
|
-
if (that.isAnimating) {
|
|
2024
|
-
rAF(step);
|
|
2025
|
-
}
|
|
2026
|
-
|
|
2027
|
-
if (that.options.probeType == 3) {
|
|
2028
|
-
that._execEvent('scroll');
|
|
2029
|
-
}
|
|
2030
|
-
}
|
|
2031
|
-
|
|
2032
|
-
this.isAnimating = true;
|
|
2033
|
-
step();
|
|
2034
|
-
},
|
|
2035
|
-
|
|
2036
|
-
handleEvent: function handleEvent(e) {
|
|
2037
|
-
switch (e.type) {
|
|
2038
|
-
case 'touchstart':
|
|
2039
|
-
case 'pointerdown':
|
|
2040
|
-
case 'MSPointerDown':
|
|
2041
|
-
case 'mousedown':
|
|
2042
|
-
this._start(e);
|
|
2043
|
-
break;
|
|
2044
|
-
case 'touchmove':
|
|
2045
|
-
case 'pointermove':
|
|
2046
|
-
case 'MSPointerMove':
|
|
2047
|
-
case 'mousemove':
|
|
2048
|
-
this._move(e);
|
|
2049
|
-
break;
|
|
2050
|
-
case 'touchend':
|
|
2051
|
-
case 'pointerup':
|
|
2052
|
-
case 'MSPointerUp':
|
|
2053
|
-
case 'mouseup':
|
|
2054
|
-
case 'touchcancel':
|
|
2055
|
-
case 'pointercancel':
|
|
2056
|
-
case 'MSPointerCancel':
|
|
2057
|
-
case 'mousecancel':
|
|
2058
|
-
this._end(e);
|
|
2059
|
-
break;
|
|
2060
|
-
case 'orientationchange':
|
|
2061
|
-
case 'resize':
|
|
2062
|
-
this._resize();
|
|
2063
|
-
break;
|
|
2064
|
-
case 'transitionend':
|
|
2065
|
-
case 'webkitTransitionEnd':
|
|
2066
|
-
case 'oTransitionEnd':
|
|
2067
|
-
case 'MSTransitionEnd':
|
|
2068
|
-
this._transitionEnd(e);
|
|
2069
|
-
break;
|
|
2070
|
-
case 'wheel':
|
|
2071
|
-
case 'DOMMouseScroll':
|
|
2072
|
-
case 'mousewheel':
|
|
2073
|
-
this._wheel(e);
|
|
2074
|
-
break;
|
|
2075
|
-
case 'keydown':
|
|
2076
|
-
this._key(e);
|
|
2077
|
-
break;
|
|
2078
|
-
case 'click':
|
|
2079
|
-
if (this.enabled && !e._constructed) {
|
|
2080
|
-
e.preventDefault();
|
|
2081
|
-
e.stopPropagation();
|
|
2082
|
-
}
|
|
2083
|
-
break;
|
|
2084
|
-
}
|
|
2085
|
-
}
|
|
2086
|
-
};
|
|
2087
|
-
function createDefaultScrollbar(direction, interactive, type) {
|
|
2088
|
-
var scrollbar = document.createElement('div'),
|
|
2089
|
-
indicator = document.createElement('div');
|
|
2090
|
-
|
|
2091
|
-
if (type === true) {
|
|
2092
|
-
scrollbar.style.cssText = 'position:absolute;z-index:9999';
|
|
2093
|
-
indicator.style.cssText = '-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px';
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2096
|
-
indicator.className = 'iScrollIndicator';
|
|
2097
|
-
|
|
2098
|
-
if (direction == 'h') {
|
|
2099
|
-
if (type === true) {
|
|
2100
|
-
scrollbar.style.cssText += ';height:7px;left:2px;right:2px;bottom:0';
|
|
2101
|
-
indicator.style.height = '100%';
|
|
2102
|
-
}
|
|
2103
|
-
scrollbar.className = 'iScrollHorizontalScrollbar';
|
|
2104
|
-
} else {
|
|
2105
|
-
if (type === true) {
|
|
2106
|
-
scrollbar.style.cssText += ';width:7px;bottom:2px;top:2px;right:1px';
|
|
2107
|
-
indicator.style.width = '100%';
|
|
2108
|
-
}
|
|
2109
|
-
scrollbar.className = 'iScrollVerticalScrollbar';
|
|
2110
|
-
}
|
|
2111
|
-
|
|
2112
|
-
scrollbar.style.cssText += ';overflow:hidden';
|
|
2113
|
-
|
|
2114
|
-
if (!interactive) {
|
|
2115
|
-
scrollbar.style.pointerEvents = 'none';
|
|
2116
|
-
}
|
|
2117
|
-
|
|
2118
|
-
scrollbar.appendChild(indicator);
|
|
2119
|
-
|
|
2120
|
-
return scrollbar;
|
|
2121
|
-
}
|
|
2122
|
-
|
|
2123
|
-
function Indicator(scroller, options) {
|
|
2124
|
-
this.wrapper = typeof options.el == 'string' ? document.querySelector(options.el) : options.el;
|
|
2125
|
-
this.wrapperStyle = this.wrapper.style;
|
|
2126
|
-
this.indicator = this.wrapper.children[0];
|
|
2127
|
-
this.indicatorStyle = this.indicator.style;
|
|
2128
|
-
this.scroller = scroller;
|
|
2129
|
-
|
|
2130
|
-
this.options = {
|
|
2131
|
-
listenX: true,
|
|
2132
|
-
listenY: true,
|
|
2133
|
-
interactive: false,
|
|
2134
|
-
resize: true,
|
|
2135
|
-
defaultScrollbars: false,
|
|
2136
|
-
shrink: false,
|
|
2137
|
-
fade: false,
|
|
2138
|
-
speedRatioX: 0,
|
|
2139
|
-
speedRatioY: 0
|
|
2140
|
-
};
|
|
2141
|
-
|
|
2142
|
-
for (var i in options) {
|
|
2143
|
-
this.options[i] = options[i];
|
|
2144
|
-
}
|
|
2145
|
-
|
|
2146
|
-
this.sizeRatioX = 1;
|
|
2147
|
-
this.sizeRatioY = 1;
|
|
2148
|
-
this.maxPosX = 0;
|
|
2149
|
-
this.maxPosY = 0;
|
|
2150
|
-
|
|
2151
|
-
if (this.options.interactive) {
|
|
2152
|
-
if (!this.options.disableTouch) {
|
|
2153
|
-
utils.addEvent(this.indicator, 'touchstart', this);
|
|
2154
|
-
utils.addEvent(window, 'touchend', this);
|
|
2155
|
-
}
|
|
2156
|
-
if (!this.options.disablePointer) {
|
|
2157
|
-
utils.addEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this);
|
|
2158
|
-
utils.addEvent(window, utils.prefixPointerEvent('pointerup'), this);
|
|
2159
|
-
}
|
|
2160
|
-
if (!this.options.disableMouse) {
|
|
2161
|
-
utils.addEvent(this.indicator, 'mousedown', this);
|
|
2162
|
-
utils.addEvent(window, 'mouseup', this);
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
|
|
2166
|
-
if (this.options.fade) {
|
|
2167
|
-
this.wrapperStyle[utils.style.transform] = this.scroller.translateZ;
|
|
2168
|
-
var durationProp = utils.style.transitionDuration;
|
|
2169
|
-
if (!durationProp) {
|
|
2170
|
-
return;
|
|
2171
|
-
}
|
|
2172
|
-
this.wrapperStyle[durationProp] = utils.isBadAndroid ? '0.0001ms' : '0ms';
|
|
2173
|
-
// remove 0.0001ms
|
|
2174
|
-
var self = this;
|
|
2175
|
-
if (utils.isBadAndroid) {
|
|
2176
|
-
rAF(function () {
|
|
2177
|
-
if (self.wrapperStyle[durationProp] === '0.0001ms') {
|
|
2178
|
-
self.wrapperStyle[durationProp] = '0s';
|
|
2179
|
-
}
|
|
2180
|
-
});
|
|
2181
|
-
}
|
|
2182
|
-
this.wrapperStyle.opacity = '0';
|
|
2183
|
-
}
|
|
2184
|
-
}
|
|
2185
|
-
|
|
2186
|
-
Indicator.prototype = {
|
|
2187
|
-
handleEvent: function handleEvent(e) {
|
|
2188
|
-
switch (e.type) {
|
|
2189
|
-
case 'touchstart':
|
|
2190
|
-
case 'pointerdown':
|
|
2191
|
-
case 'MSPointerDown':
|
|
2192
|
-
case 'mousedown':
|
|
2193
|
-
this._start(e);
|
|
2194
|
-
break;
|
|
2195
|
-
case 'touchmove':
|
|
2196
|
-
case 'pointermove':
|
|
2197
|
-
case 'MSPointerMove':
|
|
2198
|
-
case 'mousemove':
|
|
2199
|
-
this._move(e);
|
|
2200
|
-
break;
|
|
2201
|
-
case 'touchend':
|
|
2202
|
-
case 'pointerup':
|
|
2203
|
-
case 'MSPointerUp':
|
|
2204
|
-
case 'mouseup':
|
|
2205
|
-
case 'touchcancel':
|
|
2206
|
-
case 'pointercancel':
|
|
2207
|
-
case 'MSPointerCancel':
|
|
2208
|
-
case 'mousecancel':
|
|
2209
|
-
this._end(e);
|
|
2210
|
-
break;
|
|
2211
|
-
}
|
|
2212
|
-
},
|
|
2213
|
-
|
|
2214
|
-
destroy: function destroy() {
|
|
2215
|
-
if (this.options.fadeScrollbars) {
|
|
2216
|
-
clearTimeout(this.fadeTimeout);
|
|
2217
|
-
this.fadeTimeout = null;
|
|
2218
|
-
}
|
|
2219
|
-
if (this.options.interactive) {
|
|
2220
|
-
utils.removeEvent(this.indicator, 'touchstart', this);
|
|
2221
|
-
utils.removeEvent(this.indicator, utils.prefixPointerEvent('pointerdown'), this);
|
|
2222
|
-
utils.removeEvent(this.indicator, 'mousedown', this);
|
|
2223
|
-
|
|
2224
|
-
utils.removeEvent(window, 'touchmove', this);
|
|
2225
|
-
utils.removeEvent(window, utils.prefixPointerEvent('pointermove'), this);
|
|
2226
|
-
utils.removeEvent(window, 'mousemove', this);
|
|
2227
|
-
|
|
2228
|
-
utils.removeEvent(window, 'touchend', this);
|
|
2229
|
-
utils.removeEvent(window, utils.prefixPointerEvent('pointerup'), this);
|
|
2230
|
-
utils.removeEvent(window, 'mouseup', this);
|
|
2231
|
-
}
|
|
2232
|
-
|
|
2233
|
-
if (this.options.defaultScrollbars && this.wrapper.parentNode) {
|
|
2234
|
-
this.wrapper.parentNode.removeChild(this.wrapper);
|
|
2235
|
-
}
|
|
2236
|
-
},
|
|
2237
|
-
|
|
2238
|
-
_start: function _start(e) {
|
|
2239
|
-
var point = e.touches ? e.touches[0] : e;
|
|
2240
|
-
|
|
2241
|
-
e.preventDefault();
|
|
2242
|
-
e.stopPropagation();
|
|
2243
|
-
|
|
2244
|
-
this.transitionTime();
|
|
2245
|
-
|
|
2246
|
-
this.initiated = true;
|
|
2247
|
-
this.moved = false;
|
|
2248
|
-
this.lastPointX = point.pageX;
|
|
2249
|
-
this.lastPointY = point.pageY;
|
|
2250
|
-
|
|
2251
|
-
this.startTime = utils.getTime();
|
|
2252
|
-
|
|
2253
|
-
if (!this.options.disableTouch) {
|
|
2254
|
-
utils.addEvent(window, 'touchmove', this);
|
|
2255
|
-
}
|
|
2256
|
-
if (!this.options.disablePointer) {
|
|
2257
|
-
utils.addEvent(window, utils.prefixPointerEvent('pointermove'), this);
|
|
2258
|
-
}
|
|
2259
|
-
if (!this.options.disableMouse) {
|
|
2260
|
-
utils.addEvent(window, 'mousemove', this);
|
|
2261
|
-
}
|
|
2262
|
-
|
|
2263
|
-
this.scroller._execEvent('beforeScrollStart');
|
|
2264
|
-
},
|
|
2265
|
-
|
|
2266
|
-
_move: function _move(e) {
|
|
2267
|
-
var point = e.touches ? e.touches[0] : e,
|
|
2268
|
-
deltaX,
|
|
2269
|
-
deltaY,
|
|
2270
|
-
newX,
|
|
2271
|
-
newY,
|
|
2272
|
-
timestamp = utils.getTime();
|
|
2273
|
-
|
|
2274
|
-
if (!this.moved) {
|
|
2275
|
-
this.scroller._execEvent('scrollStart');
|
|
2276
|
-
}
|
|
2277
|
-
|
|
2278
|
-
this.moved = true;
|
|
2279
|
-
|
|
2280
|
-
deltaX = point.pageX - this.lastPointX;
|
|
2281
|
-
this.lastPointX = point.pageX;
|
|
2282
|
-
|
|
2283
|
-
deltaY = point.pageY - this.lastPointY;
|
|
2284
|
-
this.lastPointY = point.pageY;
|
|
2285
|
-
|
|
2286
|
-
newX = this.x + deltaX;
|
|
2287
|
-
newY = this.y + deltaY;
|
|
2288
|
-
|
|
2289
|
-
this._pos(newX, newY);
|
|
2290
|
-
|
|
2291
|
-
if (this.scroller.options.probeType == 1 && timestamp - this.startTime > 300) {
|
|
2292
|
-
this.startTime = timestamp;
|
|
2293
|
-
this.scroller._execEvent('scroll');
|
|
2294
|
-
} else if (this.scroller.options.probeType > 1) {
|
|
2295
|
-
this.scroller._execEvent('scroll');
|
|
2296
|
-
}
|
|
2297
|
-
|
|
2298
|
-
// INSERT POINT: indicator._move
|
|
2299
|
-
|
|
2300
|
-
e.preventDefault();
|
|
2301
|
-
e.stopPropagation();
|
|
2302
|
-
},
|
|
2303
|
-
|
|
2304
|
-
_end: function _end(e) {
|
|
2305
|
-
if (!this.initiated) {
|
|
2306
|
-
return;
|
|
2307
|
-
}
|
|
2308
|
-
|
|
2309
|
-
this.initiated = false;
|
|
2310
|
-
|
|
2311
|
-
e.preventDefault();
|
|
2312
|
-
e.stopPropagation();
|
|
2313
|
-
|
|
2314
|
-
utils.removeEvent(window, 'touchmove', this);
|
|
2315
|
-
utils.removeEvent(window, utils.prefixPointerEvent('pointermove'), this);
|
|
2316
|
-
utils.removeEvent(window, 'mousemove', this);
|
|
2317
|
-
|
|
2318
|
-
if (this.scroller.options.snap) {
|
|
2319
|
-
var snap = this.scroller._nearestSnap(this.scroller.x, this.scroller.y);
|
|
2320
|
-
|
|
2321
|
-
var time = this.options.snapSpeed || Math.max(Math.max(Math.min(Math.abs(this.scroller.x - snap.x), 1000), Math.min(Math.abs(this.scroller.y - snap.y), 1000)), 300);
|
|
2322
|
-
|
|
2323
|
-
if (this.scroller.x != snap.x || this.scroller.y != snap.y) {
|
|
2324
|
-
this.scroller.directionX = 0;
|
|
2325
|
-
this.scroller.directionY = 0;
|
|
2326
|
-
this.scroller.currentPage = snap;
|
|
2327
|
-
this.scroller.scrollTo(snap.x, snap.y, time, this.scroller.options.bounceEasing);
|
|
2328
|
-
}
|
|
2329
|
-
}
|
|
2330
|
-
|
|
2331
|
-
if (this.moved) {
|
|
2332
|
-
this.scroller._execEvent('scrollEnd');
|
|
2333
|
-
}
|
|
2334
|
-
},
|
|
2335
|
-
|
|
2336
|
-
transitionTime: function transitionTime(time) {
|
|
2337
|
-
time = time || 0;
|
|
2338
|
-
var durationProp = utils.style.transitionDuration;
|
|
2339
|
-
if (!durationProp) {
|
|
2340
|
-
return;
|
|
2341
|
-
}
|
|
2342
|
-
|
|
2343
|
-
this.indicatorStyle[durationProp] = time + 'ms';
|
|
2344
|
-
|
|
2345
|
-
if (!time && utils.isBadAndroid) {
|
|
2346
|
-
this.indicatorStyle[durationProp] = '0.0001ms';
|
|
2347
|
-
// remove 0.0001ms
|
|
2348
|
-
var self = this;
|
|
2349
|
-
rAF(function () {
|
|
2350
|
-
if (self.indicatorStyle[durationProp] === '0.0001ms') {
|
|
2351
|
-
self.indicatorStyle[durationProp] = '0s';
|
|
2352
|
-
}
|
|
2353
|
-
});
|
|
2354
|
-
}
|
|
2355
|
-
},
|
|
2356
|
-
|
|
2357
|
-
transitionTimingFunction: function transitionTimingFunction(easing) {
|
|
2358
|
-
this.indicatorStyle[utils.style.transitionTimingFunction] = easing;
|
|
2359
|
-
},
|
|
2360
|
-
|
|
2361
|
-
refresh: function refresh() {
|
|
2362
|
-
this.transitionTime();
|
|
2363
|
-
|
|
2364
|
-
if (this.options.listenX && !this.options.listenY) {
|
|
2365
|
-
this.indicatorStyle.display = this.scroller.hasHorizontalScroll ? 'block' : 'none';
|
|
2366
|
-
} else if (this.options.listenY && !this.options.listenX) {
|
|
2367
|
-
this.indicatorStyle.display = this.scroller.hasVerticalScroll ? 'block' : 'none';
|
|
2368
|
-
} else {
|
|
2369
|
-
this.indicatorStyle.display = this.scroller.hasHorizontalScroll || this.scroller.hasVerticalScroll ? 'block' : 'none';
|
|
2370
|
-
}
|
|
2371
|
-
|
|
2372
|
-
if (this.scroller.hasHorizontalScroll && this.scroller.hasVerticalScroll) {
|
|
2373
|
-
utils.addClass(this.wrapper, 'iScrollBothScrollbars');
|
|
2374
|
-
utils.removeClass(this.wrapper, 'iScrollLoneScrollbar');
|
|
2375
|
-
|
|
2376
|
-
if (this.options.defaultScrollbars && this.options.customStyle) {
|
|
2377
|
-
if (this.options.listenX) {
|
|
2378
|
-
this.wrapper.style.right = '8px';
|
|
2379
|
-
} else {
|
|
2380
|
-
this.wrapper.style.bottom = '8px';
|
|
2381
|
-
}
|
|
2382
|
-
}
|
|
2383
|
-
} else {
|
|
2384
|
-
utils.removeClass(this.wrapper, 'iScrollBothScrollbars');
|
|
2385
|
-
utils.addClass(this.wrapper, 'iScrollLoneScrollbar');
|
|
2386
|
-
|
|
2387
|
-
if (this.options.defaultScrollbars && this.options.customStyle) {
|
|
2388
|
-
if (this.options.listenX) {
|
|
2389
|
-
this.wrapper.style.right = '2px';
|
|
2390
|
-
} else {
|
|
2391
|
-
this.wrapper.style.bottom = '2px';
|
|
2392
|
-
}
|
|
2393
|
-
}
|
|
2394
|
-
}
|
|
2395
|
-
|
|
2396
|
-
utils.getRect(this.wrapper); // force refresh
|
|
2397
|
-
|
|
2398
|
-
if (this.options.listenX) {
|
|
2399
|
-
this.wrapperWidth = this.wrapper.clientWidth;
|
|
2400
|
-
if (this.options.resize) {
|
|
2401
|
-
this.indicatorWidth = Math.max(Math.round(this.wrapperWidth * this.wrapperWidth / (this.scroller.scrollerWidth || this.wrapperWidth || 1)), 8);
|
|
2402
|
-
this.indicatorStyle.width = this.indicatorWidth + 'px';
|
|
2403
|
-
} else {
|
|
2404
|
-
this.indicatorWidth = this.indicator.clientWidth;
|
|
2405
|
-
}
|
|
2406
|
-
|
|
2407
|
-
this.maxPosX = this.wrapperWidth - this.indicatorWidth;
|
|
2408
|
-
|
|
2409
|
-
if (this.options.shrink == 'clip') {
|
|
2410
|
-
this.minBoundaryX = -this.indicatorWidth + 8;
|
|
2411
|
-
this.maxBoundaryX = this.wrapperWidth - 8;
|
|
2412
|
-
} else {
|
|
2413
|
-
this.minBoundaryX = 0;
|
|
2414
|
-
this.maxBoundaryX = this.maxPosX;
|
|
2415
|
-
}
|
|
2416
|
-
|
|
2417
|
-
this.sizeRatioX = this.options.speedRatioX || this.scroller.maxScrollX && this.maxPosX / this.scroller.maxScrollX;
|
|
2418
|
-
}
|
|
2419
|
-
|
|
2420
|
-
if (this.options.listenY) {
|
|
2421
|
-
this.wrapperHeight = this.wrapper.clientHeight;
|
|
2422
|
-
if (this.options.resize) {
|
|
2423
|
-
this.indicatorHeight = Math.max(Math.round(this.wrapperHeight * this.wrapperHeight / (this.scroller.scrollerHeight || this.wrapperHeight || 1)), 8);
|
|
2424
|
-
this.indicatorStyle.height = this.indicatorHeight + 'px';
|
|
2425
|
-
} else {
|
|
2426
|
-
this.indicatorHeight = this.indicator.clientHeight;
|
|
2427
|
-
}
|
|
2428
|
-
|
|
2429
|
-
this.maxPosY = this.wrapperHeight - this.indicatorHeight;
|
|
2430
|
-
|
|
2431
|
-
if (this.options.shrink == 'clip') {
|
|
2432
|
-
this.minBoundaryY = -this.indicatorHeight + 8;
|
|
2433
|
-
this.maxBoundaryY = this.wrapperHeight - 8;
|
|
2434
|
-
} else {
|
|
2435
|
-
this.minBoundaryY = 0;
|
|
2436
|
-
this.maxBoundaryY = this.maxPosY;
|
|
2437
|
-
}
|
|
2438
|
-
|
|
2439
|
-
this.maxPosY = this.wrapperHeight - this.indicatorHeight;
|
|
2440
|
-
this.sizeRatioY = this.options.speedRatioY || this.scroller.maxScrollY && this.maxPosY / this.scroller.maxScrollY;
|
|
2441
|
-
}
|
|
2442
|
-
|
|
2443
|
-
this.updatePosition();
|
|
2444
|
-
},
|
|
2445
|
-
|
|
2446
|
-
updatePosition: function updatePosition() {
|
|
2447
|
-
var x = this.options.listenX && Math.round(this.sizeRatioX * this.scroller.x) || 0,
|
|
2448
|
-
y = this.options.listenY && Math.round(this.sizeRatioY * this.scroller.y) || 0;
|
|
2449
|
-
|
|
2450
|
-
if (!this.options.ignoreBoundaries) {
|
|
2451
|
-
if (x < this.minBoundaryX) {
|
|
2452
|
-
if (this.options.shrink == 'scale') {
|
|
2453
|
-
this.width = Math.max(this.indicatorWidth + x, 8);
|
|
2454
|
-
this.indicatorStyle.width = this.width + 'px';
|
|
2455
|
-
}
|
|
2456
|
-
x = this.minBoundaryX;
|
|
2457
|
-
} else if (x > this.maxBoundaryX) {
|
|
2458
|
-
if (this.options.shrink == 'scale') {
|
|
2459
|
-
this.width = Math.max(this.indicatorWidth - (x - this.maxPosX), 8);
|
|
2460
|
-
this.indicatorStyle.width = this.width + 'px';
|
|
2461
|
-
x = this.maxPosX + this.indicatorWidth - this.width;
|
|
2462
|
-
} else {
|
|
2463
|
-
x = this.maxBoundaryX;
|
|
2464
|
-
}
|
|
2465
|
-
} else if (this.options.shrink == 'scale' && this.width != this.indicatorWidth) {
|
|
2466
|
-
this.width = this.indicatorWidth;
|
|
2467
|
-
this.indicatorStyle.width = this.width + 'px';
|
|
2468
|
-
}
|
|
2469
|
-
|
|
2470
|
-
if (y < this.minBoundaryY) {
|
|
2471
|
-
if (this.options.shrink == 'scale') {
|
|
2472
|
-
this.height = Math.max(this.indicatorHeight + y * 3, 8);
|
|
2473
|
-
this.indicatorStyle.height = this.height + 'px';
|
|
2474
|
-
}
|
|
2475
|
-
y = this.minBoundaryY;
|
|
2476
|
-
} else if (y > this.maxBoundaryY) {
|
|
2477
|
-
if (this.options.shrink == 'scale') {
|
|
2478
|
-
this.height = Math.max(this.indicatorHeight - (y - this.maxPosY) * 3, 8);
|
|
2479
|
-
this.indicatorStyle.height = this.height + 'px';
|
|
2480
|
-
y = this.maxPosY + this.indicatorHeight - this.height;
|
|
2481
|
-
} else {
|
|
2482
|
-
y = this.maxBoundaryY;
|
|
2483
|
-
}
|
|
2484
|
-
} else if (this.options.shrink == 'scale' && this.height != this.indicatorHeight) {
|
|
2485
|
-
this.height = this.indicatorHeight;
|
|
2486
|
-
this.indicatorStyle.height = this.height + 'px';
|
|
2487
|
-
}
|
|
2488
|
-
}
|
|
2489
|
-
|
|
2490
|
-
this.x = x;
|
|
2491
|
-
this.y = y;
|
|
2492
|
-
|
|
2493
|
-
if (this.scroller.options.useTransform) {
|
|
2494
|
-
this.indicatorStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.scroller.translateZ;
|
|
2495
|
-
} else {
|
|
2496
|
-
this.indicatorStyle.left = x + 'px';
|
|
2497
|
-
this.indicatorStyle.top = y + 'px';
|
|
2498
|
-
}
|
|
2499
|
-
},
|
|
2500
|
-
|
|
2501
|
-
_pos: function _pos(x, y) {
|
|
2502
|
-
if (x < 0) {
|
|
2503
|
-
x = 0;
|
|
2504
|
-
} else if (x > this.maxPosX) {
|
|
2505
|
-
x = this.maxPosX;
|
|
2506
|
-
}
|
|
2507
|
-
|
|
2508
|
-
if (y < 0) {
|
|
2509
|
-
y = 0;
|
|
2510
|
-
} else if (y > this.maxPosY) {
|
|
2511
|
-
y = this.maxPosY;
|
|
2512
|
-
}
|
|
2513
|
-
|
|
2514
|
-
x = this.options.listenX ? Math.round(x / this.sizeRatioX) : this.scroller.x;
|
|
2515
|
-
y = this.options.listenY ? Math.round(y / this.sizeRatioY) : this.scroller.y;
|
|
2516
|
-
|
|
2517
|
-
this.scroller.scrollTo(x, y);
|
|
2518
|
-
},
|
|
2519
|
-
|
|
2520
|
-
fade: function fade(val, hold) {
|
|
2521
|
-
if (hold && !this.visible) {
|
|
2522
|
-
return;
|
|
2523
|
-
}
|
|
2524
|
-
|
|
2525
|
-
clearTimeout(this.fadeTimeout);
|
|
2526
|
-
this.fadeTimeout = null;
|
|
2527
|
-
|
|
2528
|
-
var time = val ? 250 : 500,
|
|
2529
|
-
delay = val ? 0 : 300;
|
|
2530
|
-
|
|
2531
|
-
val = val ? '1' : '0';
|
|
2532
|
-
|
|
2533
|
-
this.wrapperStyle[utils.style.transitionDuration] = time + 'ms';
|
|
2534
|
-
|
|
2535
|
-
this.fadeTimeout = setTimeout(function (val) {
|
|
2536
|
-
this.wrapperStyle.opacity = val;
|
|
2537
|
-
this.visible = +val;
|
|
2538
|
-
}.bind(this, val), delay);
|
|
2539
|
-
}
|
|
2540
|
-
};
|
|
2541
|
-
|
|
2542
|
-
IScroll.utils = utils;
|
|
2543
|
-
|
|
2544
|
-
if (typeof module != 'undefined' && module.exports) {
|
|
2545
|
-
module.exports = IScroll;
|
|
2546
|
-
} else if (true) {
|
|
2547
|
-
!(__WEBPACK_AMD_DEFINE_RESULT__ = function () {
|
|
2548
|
-
return IScroll;
|
|
2549
|
-
}.call(exports, __webpack_require__, exports, module),
|
|
2550
|
-
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
|
2551
|
-
} else {
|
|
2552
|
-
window.IScroll = IScroll;
|
|
2553
|
-
}
|
|
2554
|
-
})(window, document, Math);
|
|
2555
|
-
|
|
2556
|
-
/***/ }),
|
|
2557
|
-
|
|
2558
|
-
/***/ 238:
|
|
2559
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
2560
|
-
|
|
2561
|
-
module.exports = __webpack_require__(103);
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
/***/ })
|
|
2565
|
-
|
|
2566
|
-
},[238]);
|
|
2567
|
-
});
|
|
1
|
+
!function(t,i){"object"==typeof exports&&"object"==typeof module?module.exports=i():"function"==typeof define&&define.amd?define([],i):"object"==typeof exports?exports.fastman=i():t.fastman=i()}(this,function(){return webpackJsonpfastman([10],{103:function(t,i,s){"use strict";function e(t){var i=Array.apply(null,arguments);i.shift();var s;return this.each(function(){var e=$(this),n=$.extend({},e.dataset(),"object"===(void 0===t?"undefined":o(t))&&t),r=e.data("scroller");if(r||e.data("scroller",r=new a(this,n)),"string"==typeof t&&"function"==typeof r[t]&&void 0!==(s=r[t].apply(r,i)))return!1}),void 0!==s?s:this}Object.defineProperty(i,"__esModule",{value:!0});var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n=s(31),r=s(151),h=(s(59),{scrollTop:$.fn.scrollTop,scrollLeft:$.fn.scrollLeft});!function(){$.extend($.fn,{scrollTop:function(t,i){if(this.length){var s=this.data("scroller");return s&&s.scroller?s.scrollTop(t,i):h.scrollTop.apply(this,arguments)}}}),$.extend($.fn,{scrollLeft:function(t,i){if(this.length){var s=this.data("scroller");return s&&s.scroller?s.scrollLeft(t,i):h.scrollLeft.apply(this,arguments)}}})}();var a=function(t,i){var s=this.$pageContent=$(t);this.options=$.extend({},this._defaults,i);var e=this.options.type;if("js"===e||"auto"===e&&$.device.android&&n.compareVersion("4.4.0",$.device.osVersion)>-1||"auto"===e&&$.device.ios&&n.compareVersion("6.0.0",$.device.osVersion)>-1){if(s.hasClass("pull-down-refresh")){var o=$(window).height()+(s.prev().hasClass(".bar")?1:61);s.find(".content-inner").css("min-height",o+"px")}var h=$(t).hasClass("pull-down-refresh"),a=0===s.find(".fixed-tab").length,l={probeType:1,mouseWheel:!0,click:$.device.androidChrome,useTransform:a,scrollX:!0};h&&(l.ptr=!0,l.ptrOffset=44),this.scroller=new r(t,l),this._bindEventToDomWhenJs(),$.initPullToRefresh=$._pullToRefreshJSScroll.initPullToRefresh,$.pullToRefreshDone=$._pullToRefreshJSScroll.pullToRefreshDone,$.pullToRefreshTrigger=$._pullToRefreshJSScroll.pullToRefreshTrigger,$.destroyToRefresh=$._pullToRefreshJSScroll.destroyToRefresh,s.addClass("javascript-scroll"),a||s.find(".content-inner").css({width:"100%",position:"absolute"});var c=this.$pageContent[0].scrollTop;c&&(this.$pageContent[0].scrollTop=0,this.scrollTop(c))}else s.addClass("native-scroll")};a.prototype={_defaults:{type:"auto"},_bindEventToDomWhenJs:function(){if(this.scroller){var t=this;this.scroller.on("scrollStart",function(){t.$pageContent.trigger("scrollstart")}),this.scroller.on("scroll",function(){t.$pageContent.trigger("scroll")}),this.scroller.on("scrollEnd",function(){t.$pageContent.trigger("scrollend")})}},scrollTop:function(t,i){return this.scroller?void 0===t?-1*this.scroller.getComputedPosition().y:(this.scroller.scrollTo(0,-1*t,i),this):this.$pageContent.scrollTop(t,i)},scrollLeft:function(t,i){return this.scroller?void 0===t?-1*this.scroller.getComputedPosition().x:(this.scroller.scrollTo(-1*t,0),this):this.$pageContent.scrollTop(t,i)},on:function(t,i){return this.scroller?this.scroller.on(t,function(){i.call(this.wrapper)}):this.$pageContent.on(t,i),this},off:function(t,i){return this.scroller?this.scroller.off(t,i):this.$pageContent.off(t,i),this},refresh:function(){return this.scroller&&this.scroller.refresh(),this},scrollHeight:function(){return this.scroller?this.scroller.scrollerHeight:this.$pageContent[0].scrollHeight}};var l=$.fn.scroller;$.fn.scroller=e,$.fn.scroller.Constructor=a,$.fn.scroller.noConflict=function(){return $.fn.scroller=l,this},$.refreshScroller=function(t){t?$(t).scroller("refresh"):$(".javascript-scroll").each(function(){$(this).scroller("refresh")})},$.initScroller=function(t){this.options=$.extend({},"object"===(void 0===t?"undefined":o(t))&&t),$('[data-toggle="scroller"],.content').scroller(t)},$.getScroller=function(t){return t=$(t).hasClass("ui-container")?t:$(t).parents(".ui-container"),t?$(t).data("scroller"):$(".content.javascript-scroll").data("scroller")},$.detectScrollerType=function(t){if(t)return $(t).data("scroller")&&$(t).data("scroller").scroller?"js":"native"};var c=function(t,i){$(t).length>0&&$(t).scroller(i)},p=function(t){$.refreshScroller(t)},d=function(t,i){$(t).length>0&&$(t).scrollTop(void 0==i?0:i)},u=function(t){return $.initPullToRefresh($(t))},f=function(t){$(document).on("refresh",".pull-down-refresh",t)},m=function(t){return $.pullToRefreshDone(t)};i.initScroller=c,i.refreshScroller=p,i.scrollTop=d,i.initPullDownRefresh=u,i.pullDownRefresh=f,i.pullDownRefreshDone=m},151:function(t,i,s){"use strict";var e,o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};/*! iScroll v5.2.0-snapshot ~ (c) 2008-2017 Matteo Spinelli ~ http://cubiq.org/license */
|
|
2
|
+
!function(n,r,h){function a(t,i){this.wrapper="string"==typeof t?r.querySelector(t):t,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={resizeScrollbars:!0,mouseWheelSpeed:20,snapThreshold:.334,disablePointer:!d.hasPointer,disableTouch:d.hasPointer||!d.hasTouch,disableMouse:d.hasPointer||d.hasTouch,startX:0,startY:0,scrollY:!0,directionLockThreshold:5,momentum:!0,bounce:!0,bounceTime:600,bounceEasing:"",preventDefault:!0,preventDefaultException:{tagName:/^(INPUT|TEXTAREA|BUTTON|SELECT)$/},HWCompositing:!0,useTransition:!0,useTransform:!0,bindToWrapper:void 0===n.onmousedown};for(var s in i)this.options[s]=i[s];this.translateZ=this.options.HWCompositing&&d.hasPerspective?" translateZ(0)":"",this.options.useTransition=d.hasTransition&&this.options.useTransition,this.options.useTransform=d.hasTransform&&this.options.useTransform,this.options.eventPassthrough=!0===this.options.eventPassthrough?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"!=this.options.eventPassthrough&&this.options.scrollY,this.options.scrollX="horizontal"!=this.options.eventPassthrough&&this.options.scrollX,this.options.freeScroll=this.options.freeScroll&&!this.options.eventPassthrough,this.options.directionLockThreshold=this.options.eventPassthrough?0:this.options.directionLockThreshold,this.options.bounceEasing="string"==typeof this.options.bounceEasing?d.ease[this.options.bounceEasing]||d.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,!0===this.options.tap&&(this.options.tap="tap"),this.options.useTransition||this.options.useTransform||/relative|absolute/i.test(this.scrollerStyle.position)||(this.scrollerStyle.position="relative"),"scale"==this.options.shrinkScrollbars&&(this.options.useTransition=!1),this.options.invertWheelDirection=this.options.invertWheelDirection?-1:1,3==this.options.probeType&&(this.options.useTransition=!1),this.x=0,this.y=0,this.directionX=0,this.directionY=0,this._events={},this._init(),this.refresh(),this.scrollTo(this.options.startX,this.options.startY),this.enable()}function l(t,i,s){var e=r.createElement("div"),o=r.createElement("div");return!0===s&&(e.style.cssText="position:absolute;z-index:9999",o.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px"),o.className="iScrollIndicator","h"==t?(!0===s&&(e.style.cssText+=";height:7px;left:2px;right:2px;bottom:0",o.style.height="100%"),e.className="iScrollHorizontalScrollbar"):(!0===s&&(e.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px",o.style.width="100%"),e.className="iScrollVerticalScrollbar"),e.style.cssText+=";overflow:hidden",i||(e.style.pointerEvents="none"),e.appendChild(o),e}function c(t,i){this.wrapper="string"==typeof i.el?r.querySelector(i.el):i.el,this.wrapperStyle=this.wrapper.style,this.indicator=this.wrapper.children[0],this.indicatorStyle=this.indicator.style,this.scroller=t,this.options={listenX:!0,listenY:!0,interactive:!1,resize:!0,defaultScrollbars:!1,shrink:!1,fade:!1,speedRatioX:0,speedRatioY:0};for(var s in i)this.options[s]=i[s];if(this.sizeRatioX=1,this.sizeRatioY=1,this.maxPosX=0,this.maxPosY=0,this.options.interactive&&(this.options.disableTouch||(d.addEvent(this.indicator,"touchstart",this),d.addEvent(n,"touchend",this)),this.options.disablePointer||(d.addEvent(this.indicator,d.prefixPointerEvent("pointerdown"),this),d.addEvent(n,d.prefixPointerEvent("pointerup"),this)),this.options.disableMouse||(d.addEvent(this.indicator,"mousedown",this),d.addEvent(n,"mouseup",this))),this.options.fade){this.wrapperStyle[d.style.transform]=this.scroller.translateZ;var e=d.style.transitionDuration;if(!e)return;this.wrapperStyle[e]=d.isBadAndroid?"0.0001ms":"0ms";var o=this;d.isBadAndroid&&p(function(){"0.0001ms"===o.wrapperStyle[e]&&(o.wrapperStyle[e]="0s")}),this.wrapperStyle.opacity="0"}}var p=n.requestAnimationFrame||n.webkitRequestAnimationFrame||n.mozRequestAnimationFrame||n.oRequestAnimationFrame||n.msRequestAnimationFrame||function(t){n.setTimeout(t,1e3/60)},d=function(){function t(t){return!1!==e&&(""===e?t:e+t.charAt(0).toUpperCase()+t.substr(1))}var i={},s=r.createElement("div").style,e=function(){for(var t=["t","webkitT","MozT","msT","OT"],i=0,e=t.length;i<e;i++)if(t[i]+"ransform"in s)return t[i].substr(0,t[i].length-1);return!1}();i.getTime=Date.now||function(){return(new Date).getTime()},i.extend=function(t,i){for(var s in i)t[s]=i[s]},i.addEvent=function(t,i,s,e){t.addEventListener(i,s,!!e)},i.removeEvent=function(t,i,s,e){t.removeEventListener(i,s,!!e)},i.prefixPointerEvent=function(t){return n.MSPointerEvent?"MSPointer"+t.charAt(7).toUpperCase()+t.substr(8):t},i.momentum=function(t,i,s,e,o,n){var r,a,l=t-i,c=h.abs(l)/s;return n=void 0===n?6e-4:n,r=t+c*c/(2*n)*(l<0?-1:1),a=c/n,r<e?(r=o?e-o/2.5*(c/8):e,l=h.abs(r-t),a=l/c):r>0&&(r=o?o/2.5*(c/8):0,l=h.abs(t)+r,a=l/c),{destination:h.round(r),duration:a}};var a=t("transform");return i.extend(i,{hasTransform:!1!==a,hasPerspective:t("perspective")in s,hasTouch:"ontouchstart"in n,hasPointer:!(!n.PointerEvent&&!n.MSPointerEvent),hasTransition:t("transition")in s}),i.isBadAndroid=function(){var t=n.navigator.appVersion;if(/Android/.test(t)&&!/Chrome\/\d/.test(t)){var i=t.match(/Safari\/(\d+.\d)/);return!(i&&"object"===(void 0===i?"undefined":o(i))&&i.length>=2)||parseFloat(i[1])<535.19}return!1}(),i.extend(i.style={},{transform:a,transitionTimingFunction:t("transitionTimingFunction"),transitionDuration:t("transitionDuration"),transitionDelay:t("transitionDelay"),transformOrigin:t("transformOrigin"),touchAction:t("touchAction")}),i.hasClass=function(t,i){return new RegExp("(^|\\s)"+i+"(\\s|$)").test(t.className)},i.addClass=function(t,s){if(!i.hasClass(t,s)){var e=t.className.split(" ");e.push(s),t.className=e.join(" ")}},i.removeClass=function(t,s){if(i.hasClass(t,s)){var e=new RegExp("(^|\\s)"+s+"(\\s|$)","g");t.className=t.className.replace(e," ")}},i.offset=function(t){for(var i=-t.offsetLeft,s=-t.offsetTop;t=t.offsetParent;)i-=t.offsetLeft,s-=t.offsetTop;return{left:i,top:s}},i.preventDefaultException=function(t,i){for(var s in i)if(i[s].test(t[s]))return!0;return!1},i.extend(i.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,pointerdown:3,pointermove:3,pointerup:3,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),i.extend(i.ease={},{quadratic:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(t){return t*(2-t)}},circular:{style:"cubic-bezier(0.1, 0.57, 0.1, 1)",fn:function(t){return h.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){return(t-=1)*t*(5*t+4)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){return 0===t?0:1==t?1:.4*h.pow(2,-10*t)*h.sin((t-.055)*(2*h.PI)/.22)+1}}}),i.tap=function(t,i){var s=r.createEvent("Event");s.initEvent(i,!0,!0),s.pageX=t.pageX,s.pageY=t.pageY,t.target.dispatchEvent(s)},i.click=function(t){var i,s=t.target;/(SELECT|INPUT|TEXTAREA)/i.test(s.tagName)||(i=r.createEvent("MouseEvents"),i.initMouseEvent("click",!0,!0,t.view,1,s.screenX,s.screenY,s.clientX,s.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,null),i._constructed=!0,s.dispatchEvent(i))},i.getTouchAction=function(t,i){var s="none";return"vertical"===t?s="pan-y":"horizontal"===t&&(s="pan-x"),i&&"none"!=s&&(s+=" pinch-zoom"),s},i.getRect=function(t){if(t instanceof SVGElement){var i=t.getBoundingClientRect();return{top:i.top,left:i.left,width:i.width,height:i.height}}return{top:t.offsetTop,left:t.offsetLeft,width:t.offsetWidth,height:t.offsetHeight}},i}();a.prototype={version:"5.2.0-snapshot",_init:function(){this._initEvents(),(this.options.scrollbars||this.options.indicators)&&this._initIndicators(),this.options.mouseWheel&&this._initWheel(),this.options.snap&&this._initSnap(),this.options.keyBindings&&this._initKeys()},destroy:function(){this._initEvents(!0),clearTimeout(this.resizeTimeout),this.resizeTimeout=null,this._execEvent("destroy")},_transitionEnd:function(t){t.target==this.scroller&&this.isInTransition&&(this._transitionTime(),this.resetPosition(this.options.bounceTime)||(this.isInTransition=!1,this._execEvent("scrollEnd")))},_start:function(t){if(1!=d.eventType[t.type]){if(0!==(t.which?t.button:t.button<2?0:4==t.button?1:2))return}if(this.enabled&&(!this.initiated||d.eventType[t.type]===this.initiated)){!this.options.preventDefault||d.isBadAndroid||d.preventDefaultException(t.target,this.options.preventDefaultException)||t.preventDefault();var i,s=t.touches?t.touches[0]:t;this.initiated=d.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this.startTime=d.getTime(),this.options.useTransition&&this.isInTransition?(this._transitionTime(),this.isInTransition=!1,i=this.getComputedPosition(),this._translate(h.round(i.x),h.round(i.y)),this._execEvent("scrollEnd")):!this.options.useTransition&&this.isAnimating&&(this.isAnimating=!1,this._execEvent("scrollEnd")),this.startX=this.x,this.startY=this.y,this.absStartX=this.x,this.absStartY=this.y,this.pointX=s.pageX,this.pointY=s.pageY,this._execEvent("beforeScrollStart")}},_move:function(t){if(this.enabled&&d.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,s,e,o,n=t.touches?t.touches[0]:t,r=n.pageX-this.pointX,a=n.pageY-this.pointY,l=d.getTime();if(this.pointX=n.pageX,this.pointY=n.pageY,this.distX+=r,this.distY+=a,e=h.abs(this.distX),o=h.abs(this.distY),!(l-this.endTime>300&&e<10&&o<10)){if(this.directionLocked||this.options.freeScroll||(e>o+this.options.directionLockThreshold?this.directionLocked="h":o>=e+this.options.directionLockThreshold?this.directionLocked="v":this.directionLocked="n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return void(this.initiated=!1);a=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return void(this.initiated=!1);r=0}r=this.hasHorizontalScroll?r:0,a=this.hasVerticalScroll?a:0,i=this.x+r,s=this.y+a,(i>0||i<this.maxScrollX)&&(i=this.options.bounce?this.x+r/3:i>0?0:this.maxScrollX),(s>0||s<this.maxScrollY)&&(s=this.options.bounce?this.y+a/3:s>0?0:this.maxScrollY),this.directionX=r>0?-1:r<0?1:0,this.directionY=a>0?-1:a<0?1:0,this.moved||this._execEvent("scrollStart"),this.moved=!0,this._translate(i,s),l-this.startTime>300&&(this.startTime=l,this.startX=this.x,this.startY=this.y,1==this.options.probeType&&this._execEvent("scroll")),this.options.probeType>1&&this._execEvent("scroll")}}},_end:function(t){if(this.enabled&&d.eventType[t.type]===this.initiated){this.options.preventDefault&&!d.preventDefaultException(t.target,this.options.preventDefaultException)&&t.preventDefault();var i,s,e=(t.changedTouches&&t.changedTouches[0],d.getTime()-this.startTime),o=h.round(this.x),n=h.round(this.y),r=h.abs(o-this.startX),a=h.abs(n-this.startY),l=0,c="";if(this.isInTransition=0,this.initiated=0,this.endTime=d.getTime(),!this.resetPosition(this.options.bounceTime)){if(this.scrollTo(o,n),!this.moved)return this.options.tap&&d.tap(t,this.options.tap),this.options.click&&d.click(t),void this._execEvent("scrollCancel");if(this._events.flick&&e<200&&r<100&&a<100)return void this._execEvent("flick");if(this.options.momentum&&e<300&&(i=this.hasHorizontalScroll?d.momentum(this.x,this.startX,e,this.maxScrollX,this.options.bounce?this.wrapperWidth:0,this.options.deceleration):{destination:o,duration:0},s=this.hasVerticalScroll?d.momentum(this.y,this.startY,e,this.maxScrollY,this.options.bounce?this.wrapperHeight:0,this.options.deceleration):{destination:n,duration:0},o=i.destination,n=s.destination,l=h.max(i.duration,s.duration),this.isInTransition=1),this.options.snap){var p=this._nearestSnap(o,n);this.currentPage=p,l=this.options.snapSpeed||h.max(h.max(h.min(h.abs(o-p.x),1e3),h.min(h.abs(n-p.y),1e3)),300),o=p.x,n=p.y,this.directionX=0,this.directionY=0,c=this.options.bounceEasing}if(o!=this.x||n!=this.y)return(o>0||o<this.maxScrollX||n>0||n<this.maxScrollY)&&(c=d.ease.quadratic),void this.scrollTo(o,n,l,c);this._execEvent("scrollEnd")}}},_resize:function(){var t=this;clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(function(){t.refresh()},this.options.resizePolling)},resetPosition:function(t){var i=this.x,s=this.y;if(t=t||0,!this.hasHorizontalScroll||this.x>0?i=0:this.x<this.maxScrollX&&(i=this.maxScrollX),!this.hasVerticalScroll||this.y>0?s=0:this.y<this.maxScrollY&&(s=this.maxScrollY),i==this.x&&s==this.y)return!1;if(this.options.ptr&&this.y>44&&-1*this.startY<$(n).height()&&!this.ptrLock){s=this.options.ptrOffset||44,this._execEvent("ptr"),this.ptrLock=!0;var e=this;setTimeout(function(){e.ptrLock=!1},500)}return this.scrollTo(i,s,t,this.options.bounceEasing),!0},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){d.getRect(this.wrapper),this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight;var t=d.getRect(this.scroller);this.scrollerWidth=t.width,this.scrollerHeight=t.height,this.maxScrollX=this.wrapperWidth-this.scrollerWidth,this.maxScrollY=this.wrapperHeight-this.scrollerHeight,this.hasHorizontalScroll=this.options.scrollX&&this.maxScrollX<0,this.hasVerticalScroll=this.options.scrollY&&this.maxScrollY<0,this.hasHorizontalScroll||(this.maxScrollX=0,this.scrollerWidth=this.wrapperWidth),this.hasVerticalScroll||(this.maxScrollY=0,this.scrollerHeight=this.wrapperHeight),this.endTime=0,this.directionX=0,this.directionY=0,d.hasPointer&&!this.options.disablePointer&&(this.wrapper.style[d.style.touchAction]=d.getTouchAction(this.options.eventPassthrough,!0),this.wrapper.style[d.style.touchAction]||(this.wrapper.style[d.style.touchAction]=d.getTouchAction(this.options.eventPassthrough,!1))),this.wrapperOffset=d.offset(this.wrapper),this._execEvent("refresh"),this.resetPosition()},on:function(t,i){this._events[t]||(this._events[t]=[]),this._events[t].push(i)},off:function(t,i){if(this._events[t]){var s=this._events[t].indexOf(i);s>-1&&this._events[t].splice(s,1)}},_execEvent:function(t){if(this._events[t]){var i=0,s=this._events[t].length;if(s)for(;i<s;i++)this._events[t][i].apply(this,[].slice.call(arguments,1))}},scrollBy:function(t,i,s,e){t=this.x+t,i=this.y+i,s=s||0,this.scrollTo(t,i,s,e)},scrollTo:function(t,i,s,e){e=e||d.ease.circular,this.isInTransition=this.options.useTransition&&s>0;var o=this.options.useTransition&&e.style;!s||o?(o&&(this._transitionTimingFunction(e.style),this._transitionTime(s)),this._translate(t,i)):this._animate(t,i,s,e.fn)},scrollToElement:function(t,i,s,e,o){if(t=t.nodeType?t:this.scroller.querySelector(t)){var n=d.offset(t);n.left-=this.wrapperOffset.left,n.top-=this.wrapperOffset.top;var r=d.getRect(t),a=d.getRect(this.wrapper);!0===s&&(s=h.round(r.width/2-a.width/2)),!0===e&&(e=h.round(r.height/2-a.height/2)),n.left-=s||0,n.top-=e||0,n.left=n.left>0?0:n.left<this.maxScrollX?this.maxScrollX:n.left,n.top=n.top>0?0:n.top<this.maxScrollY?this.maxScrollY:n.top,i=void 0===i||null===i||"auto"===i?h.max(h.abs(this.x-n.left),h.abs(this.y-n.top)):i,this.scrollTo(n.left,n.top,i,o)}},_transitionTime:function(t){if(this.options.useTransition){t=t||0;var i=d.style.transitionDuration;if(i){if(this.scrollerStyle[i]=t+"ms",!t&&d.isBadAndroid){this.scrollerStyle[i]="0.0001ms";var s=this;p(function(){"0.0001ms"===s.scrollerStyle[i]&&(s.scrollerStyle[i]="0s")})}if(this.indicators)for(var e=this.indicators.length;e--;)this.indicators[e].transitionTime(t)}}},_transitionTimingFunction:function(t){if(this.scrollerStyle[d.style.transitionTimingFunction]=t,this.indicators)for(var i=this.indicators.length;i--;)this.indicators[i].transitionTimingFunction(t)},_translate:function(t,i){if(this.options.useTransform?this.scrollerStyle[d.style.transform]="translate("+t+"px,"+i+"px)"+this.translateZ:(t=h.round(t),i=h.round(i),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=i+"px"),this.x=t,this.y=i,this.indicators)for(var s=this.indicators.length;s--;)this.indicators[s].updatePosition()},_initEvents:function(t){var i=t?d.removeEvent:d.addEvent,s=this.options.bindToWrapper?this.wrapper:n;i(n,"orientationchange",this),i(n,"resize",this),this.options.click&&i(this.wrapper,"click",this,!0),this.options.disableMouse||(i(this.wrapper,"mousedown",this),i(s,"mousemove",this),i(s,"mousecancel",this),i(s,"mouseup",this)),d.hasPointer&&!this.options.disablePointer&&(i(this.wrapper,d.prefixPointerEvent("pointerdown"),this),i(s,d.prefixPointerEvent("pointermove"),this),i(s,d.prefixPointerEvent("pointercancel"),this),i(s,d.prefixPointerEvent("pointerup"),this)),d.hasTouch&&!this.options.disableTouch&&(i(this.wrapper,"touchstart",this),i(s,"touchmove",this),i(s,"touchcancel",this),i(s,"touchend",this)),i(this.scroller,"transitionend",this),i(this.scroller,"webkitTransitionEnd",this),i(this.scroller,"oTransitionEnd",this),i(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var t,i,s=n.getComputedStyle(this.scroller,null);return this.options.useTransform?(s=s[d.style.transform].split(")")[0].split(", "),t=+(s[12]||s[4]),i=+(s[13]||s[5])):(t=+s.left.replace(/[^-\d.]/g,""),i=+s.top.replace(/[^-\d.]/g,"")),{x:t,y:i}},_initIndicators:function(){function t(t){if(n.indicators)for(var i=n.indicators.length;i--;)t.call(n.indicators[i])}var i,s=this.options.interactiveScrollbars,e="string"!=typeof this.options.scrollbars,o=[],n=this;this.indicators=[],this.options.scrollbars&&(this.options.scrollY&&(i={el:l("v",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,customStyle:e,resize:this.options.resizeScrollbars,shrink:this.options.shrinkScrollbars,fade:this.options.fadeScrollbars,listenX:!1},this.wrapper.appendChild(i.el),o.push(i)),this.options.scrollX&&(i={el:l("h",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,customStyle:e,resize:this.options.resizeScrollbars,shrink:this.options.shrinkScrollbars,fade:this.options.fadeScrollbars,listenY:!1},this.wrapper.appendChild(i.el),o.push(i))),this.options.indicators&&(o=o.concat(this.options.indicators));for(var r=o.length;r--;)this.indicators.push(new c(this,o[r]));this.options.fadeScrollbars&&(this.on("scrollEnd",function(){t(function(){this.fade()})}),this.on("scrollCancel",function(){t(function(){this.fade()})}),this.on("scrollStart",function(){t(function(){this.fade(1)})}),this.on("beforeScrollStart",function(){t(function(){this.fade(1,!0)})})),this.on("refresh",function(){t(function(){this.refresh()})}),this.on("destroy",function(){t(function(){this.destroy()}),delete this.indicators})},_initWheel:function(){d.addEvent(this.wrapper,"wheel",this),d.addEvent(this.wrapper,"mousewheel",this),d.addEvent(this.wrapper,"DOMMouseScroll",this),this.on("destroy",function(){clearTimeout(this.wheelTimeout),this.wheelTimeout=null,d.removeEvent(this.wrapper,"wheel",this),d.removeEvent(this.wrapper,"mousewheel",this),d.removeEvent(this.wrapper,"DOMMouseScroll",this)})},_wheel:function(t){if(this.enabled){t.preventDefault();var i,s,e,o,n=this;if(void 0===this.wheelTimeout&&n._execEvent("scrollStart"),clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout(function(){n.options.snap||n._execEvent("scrollEnd"),n.wheelTimeout=void 0},400),"deltaX"in t)1===t.deltaMode?(i=-t.deltaX*this.options.mouseWheelSpeed,s=-t.deltaY*this.options.mouseWheelSpeed):(i=-t.deltaX,s=-t.deltaY);else if("wheelDeltaX"in t)i=t.wheelDeltaX/120*this.options.mouseWheelSpeed,s=t.wheelDeltaY/120*this.options.mouseWheelSpeed;else if("wheelDelta"in t)i=s=t.wheelDelta/120*this.options.mouseWheelSpeed;else{if(!("detail"in t))return;i=s=-t.detail/3*this.options.mouseWheelSpeed}if(i*=this.options.invertWheelDirection,s*=this.options.invertWheelDirection,this.hasVerticalScroll||(i=s,s=0),this.options.snap)return e=this.currentPage.pageX,o=this.currentPage.pageY,i>0?e--:i<0&&e++,s>0?o--:s<0&&o++,void this.goToPage(e,o);e=this.x+h.round(this.hasHorizontalScroll?i:0),o=this.y+h.round(this.hasVerticalScroll?s:0),this.directionX=i>0?-1:i<0?1:0,this.directionY=s>0?-1:s<0?1:0,e>0?e=0:e<this.maxScrollX&&(e=this.maxScrollX),o>0?o=0:o<this.maxScrollY&&(o=this.maxScrollY),this.scrollTo(e,o,0),this.options.probeType>1&&this._execEvent("scroll")}},_initSnap:function(){this.currentPage={},"string"==typeof this.options.snap&&(this.options.snap=this.scroller.querySelectorAll(this.options.snap)),this.on("refresh",function(){var t,i,s,e,o,n,r,a=0,l=0,c=0,p=this.options.snapStepX||this.wrapperWidth,u=this.options.snapStepY||this.wrapperHeight;if(this.pages=[],this.wrapperWidth&&this.wrapperHeight&&this.scrollerWidth&&this.scrollerHeight){if(!0===this.options.snap)for(s=h.round(p/2),e=h.round(u/2);c>-this.scrollerWidth;){for(this.pages[a]=[],t=0,o=0;o>-this.scrollerHeight;)this.pages[a][t]={x:h.max(c,this.maxScrollX),y:h.max(o,this.maxScrollY),width:p,height:u,cx:c-s,cy:o-e},o-=u,t++;c-=p,a++}else for(n=this.options.snap,t=n.length,i=-1;a<t;a++)r=d.getRect(n[a]),(0===a||r.left<=d.getRect(n[a-1]).left)&&(l=0,i++),this.pages[l]||(this.pages[l]=[]),c=h.max(-r.left,this.maxScrollX),o=h.max(-r.top,this.maxScrollY),s=c-h.round(r.width/2),e=o-h.round(r.height/2),this.pages[l][i]={x:c,y:o,width:r.width,height:r.height,cx:s,cy:e},c>this.maxScrollX&&l++;this.goToPage(this.currentPage.pageX||0,this.currentPage.pageY||0,0),this.options.snapThreshold%1==0?(this.snapThresholdX=this.options.snapThreshold,this.snapThresholdY=this.options.snapThreshold):(this.snapThresholdX=h.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*this.options.snapThreshold),this.snapThresholdY=h.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold))}}),this.on("flick",function(){var t=this.options.snapSpeed||h.max(h.max(h.min(h.abs(this.x-this.startX),1e3),h.min(h.abs(this.y-this.startY),1e3)),300);this.goToPage(this.currentPage.pageX+this.directionX,this.currentPage.pageY+this.directionY,t)})},_nearestSnap:function(t,i){if(!this.pages.length)return{x:0,y:0,pageX:0,pageY:0};var s=0,e=this.pages.length,o=0;if(h.abs(t-this.absStartX)<this.snapThresholdX&&h.abs(i-this.absStartY)<this.snapThresholdY)return this.currentPage;for(t>0?t=0:t<this.maxScrollX&&(t=this.maxScrollX),i>0?i=0:i<this.maxScrollY&&(i=this.maxScrollY);s<e;s++)if(t>=this.pages[s][0].cx){t=this.pages[s][0].x;break}for(e=this.pages[s].length;o<e;o++)if(i>=this.pages[0][o].cy){i=this.pages[0][o].y;break}return s==this.currentPage.pageX&&(s+=this.directionX,s<0?s=0:s>=this.pages.length&&(s=this.pages.length-1),t=this.pages[s][0].x),o==this.currentPage.pageY&&(o+=this.directionY,o<0?o=0:o>=this.pages[0].length&&(o=this.pages[0].length-1),i=this.pages[0][o].y),{x:t,y:i,pageX:s,pageY:o}},goToPage:function(t,i,s,e){e=e||this.options.bounceEasing,t>=this.pages.length?t=this.pages.length-1:t<0&&(t=0),i>=this.pages[t].length?i=this.pages[t].length-1:i<0&&(i=0);var o=this.pages[t][i].x,n=this.pages[t][i].y;s=void 0===s?this.options.snapSpeed||h.max(h.max(h.min(h.abs(o-this.x),1e3),h.min(h.abs(n-this.y),1e3)),300):s,this.currentPage={x:o,y:n,pageX:t,pageY:i},this.scrollTo(o,n,s,e)},next:function(t,i){var s=this.currentPage.pageX,e=this.currentPage.pageY;s++,s>=this.pages.length&&this.hasVerticalScroll&&(s=0,e++),this.goToPage(s,e,t,i)},prev:function(t,i){var s=this.currentPage.pageX,e=this.currentPage.pageY;s--,s<0&&this.hasVerticalScroll&&(s=0,e--),this.goToPage(s,e,t,i)},_initKeys:function(t){var i,s={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40};if("object"==o(this.options.keyBindings))for(i in this.options.keyBindings)"string"==typeof this.options.keyBindings[i]&&(this.options.keyBindings[i]=this.options.keyBindings[i].toUpperCase().charCodeAt(0));else this.options.keyBindings={};for(i in s)this.options.keyBindings[i]=this.options.keyBindings[i]||s[i];d.addEvent(n,"keydown",this),this.on("destroy",function(){d.removeEvent(n,"keydown",this)})},_key:function(t){if(this.enabled){var i,s=this.options.snap,e=s?this.currentPage.pageX:this.x,o=s?this.currentPage.pageY:this.y,n=d.getTime(),r=this.keyTime||0;switch(this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(h.round(i.x),h.round(i.y)),this.isInTransition=!1),this.keyAcceleration=n-r<200?h.min(this.keyAcceleration+.25,50):0,t.keyCode){case this.options.keyBindings.pageUp:this.hasHorizontalScroll&&!this.hasVerticalScroll?e+=s?1:this.wrapperWidth:o+=s?1:this.wrapperHeight;break;case this.options.keyBindings.pageDown:this.hasHorizontalScroll&&!this.hasVerticalScroll?e-=s?1:this.wrapperWidth:o-=s?1:this.wrapperHeight;break;case this.options.keyBindings.end:e=s?this.pages.length-1:this.maxScrollX,o=s?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:e=0,o=0;break;case this.options.keyBindings.left:e+=s?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.up:o+=s?1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.right:e-=s?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.down:o-=s?1:5+this.keyAcceleration>>0;break;default:return}if(s)return void this.goToPage(e,o);e>0?(e=0,this.keyAcceleration=0):e<this.maxScrollX&&(e=this.maxScrollX,this.keyAcceleration=0),o>0?(o=0,this.keyAcceleration=0):o<this.maxScrollY&&(o=this.maxScrollY,this.keyAcceleration=0),this.scrollTo(e,o,0),this.keyTime=n}},_animate:function(t,i,s,e){function o(){var c,u,f,m=d.getTime();if(m>=l)return n.isAnimating=!1,n._translate(t,i),void(n.resetPosition(n.options.bounceTime)||n._execEvent("scrollEnd"));m=(m-a)/s,f=e(m),c=(t-r)*f+r,u=(i-h)*f+h,n._translate(c,u),n.isAnimating&&p(o),3==n.options.probeType&&n._execEvent("scroll")}var n=this,r=this.x,h=this.y,a=d.getTime(),l=a+s;this.isAnimating=!0,o()},handleEvent:function(t){switch(t.type){case"touchstart":case"pointerdown":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"pointermove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"pointerup":case"MSPointerUp":case"mouseup":case"touchcancel":case"pointercancel":case"MSPointerCancel":case"mousecancel":this._end(t);break;case"orientationchange":case"resize":this._resize();break;case"transitionend":case"webkitTransitionEnd":case"oTransitionEnd":case"MSTransitionEnd":this._transitionEnd(t);break;case"wheel":case"DOMMouseScroll":case"mousewheel":this._wheel(t);break;case"keydown":this._key(t);break;case"click":this.enabled&&!t._constructed&&(t.preventDefault(),t.stopPropagation())}}},c.prototype={handleEvent:function(t){switch(t.type){case"touchstart":case"pointerdown":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"pointermove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"pointerup":case"MSPointerUp":case"mouseup":case"touchcancel":case"pointercancel":case"MSPointerCancel":case"mousecancel":this._end(t)}},destroy:function(){this.options.fadeScrollbars&&(clearTimeout(this.fadeTimeout),this.fadeTimeout=null),this.options.interactive&&(d.removeEvent(this.indicator,"touchstart",this),d.removeEvent(this.indicator,d.prefixPointerEvent("pointerdown"),this),d.removeEvent(this.indicator,"mousedown",this),d.removeEvent(n,"touchmove",this),d.removeEvent(n,d.prefixPointerEvent("pointermove"),this),d.removeEvent(n,"mousemove",this),d.removeEvent(n,"touchend",this),d.removeEvent(n,d.prefixPointerEvent("pointerup"),this),d.removeEvent(n,"mouseup",this)),this.options.defaultScrollbars&&this.wrapper.parentNode&&this.wrapper.parentNode.removeChild(this.wrapper)},_start:function(t){var i=t.touches?t.touches[0]:t;t.preventDefault(),t.stopPropagation(),this.transitionTime(),this.initiated=!0,this.moved=!1,this.lastPointX=i.pageX,this.lastPointY=i.pageY,this.startTime=d.getTime(),this.options.disableTouch||d.addEvent(n,"touchmove",this),this.options.disablePointer||d.addEvent(n,d.prefixPointerEvent("pointermove"),this),this.options.disableMouse||d.addEvent(n,"mousemove",this),this.scroller._execEvent("beforeScrollStart")},_move:function(t){var i,s,e,o,n=t.touches?t.touches[0]:t,r=d.getTime();this.moved||this.scroller._execEvent("scrollStart"),this.moved=!0,i=n.pageX-this.lastPointX,this.lastPointX=n.pageX,s=n.pageY-this.lastPointY,this.lastPointY=n.pageY,e=this.x+i,o=this.y+s,this._pos(e,o),1==this.scroller.options.probeType&&r-this.startTime>300?(this.startTime=r,this.scroller._execEvent("scroll")):this.scroller.options.probeType>1&&this.scroller._execEvent("scroll"),t.preventDefault(),t.stopPropagation()},_end:function(t){if(this.initiated){if(this.initiated=!1,t.preventDefault(),t.stopPropagation(),d.removeEvent(n,"touchmove",this),d.removeEvent(n,d.prefixPointerEvent("pointermove"),this),d.removeEvent(n,"mousemove",this),this.scroller.options.snap){var i=this.scroller._nearestSnap(this.scroller.x,this.scroller.y),s=this.options.snapSpeed||h.max(h.max(h.min(h.abs(this.scroller.x-i.x),1e3),h.min(h.abs(this.scroller.y-i.y),1e3)),300);this.scroller.x==i.x&&this.scroller.y==i.y||(this.scroller.directionX=0,this.scroller.directionY=0,this.scroller.currentPage=i,this.scroller.scrollTo(i.x,i.y,s,this.scroller.options.bounceEasing))}this.moved&&this.scroller._execEvent("scrollEnd")}},transitionTime:function(t){t=t||0;var i=d.style.transitionDuration;if(i&&(this.indicatorStyle[i]=t+"ms",!t&&d.isBadAndroid)){this.indicatorStyle[i]="0.0001ms";var s=this;p(function(){"0.0001ms"===s.indicatorStyle[i]&&(s.indicatorStyle[i]="0s")})}},transitionTimingFunction:function(t){this.indicatorStyle[d.style.transitionTimingFunction]=t},refresh:function(){this.transitionTime(),this.options.listenX&&!this.options.listenY?this.indicatorStyle.display=this.scroller.hasHorizontalScroll?"block":"none":this.options.listenY&&!this.options.listenX?this.indicatorStyle.display=this.scroller.hasVerticalScroll?"block":"none":this.indicatorStyle.display=this.scroller.hasHorizontalScroll||this.scroller.hasVerticalScroll?"block":"none",this.scroller.hasHorizontalScroll&&this.scroller.hasVerticalScroll?(d.addClass(this.wrapper,"iScrollBothScrollbars"),d.removeClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&this.options.customStyle&&(this.options.listenX?this.wrapper.style.right="8px":this.wrapper.style.bottom="8px")):(d.removeClass(this.wrapper,"iScrollBothScrollbars"),d.addClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&this.options.customStyle&&(this.options.listenX?this.wrapper.style.right="2px":this.wrapper.style.bottom="2px")),d.getRect(this.wrapper),this.options.listenX&&(this.wrapperWidth=this.wrapper.clientWidth,this.options.resize?(this.indicatorWidth=h.max(h.round(this.wrapperWidth*this.wrapperWidth/(this.scroller.scrollerWidth||this.wrapperWidth||1)),8),this.indicatorStyle.width=this.indicatorWidth+"px"):this.indicatorWidth=this.indicator.clientWidth,this.maxPosX=this.wrapperWidth-this.indicatorWidth,"clip"==this.options.shrink?(this.minBoundaryX=8-this.indicatorWidth,this.maxBoundaryX=this.wrapperWidth-8):(this.minBoundaryX=0,this.maxBoundaryX=this.maxPosX),this.sizeRatioX=this.options.speedRatioX||this.scroller.maxScrollX&&this.maxPosX/this.scroller.maxScrollX),this.options.listenY&&(this.wrapperHeight=this.wrapper.clientHeight,this.options.resize?(this.indicatorHeight=h.max(h.round(this.wrapperHeight*this.wrapperHeight/(this.scroller.scrollerHeight||this.wrapperHeight||1)),8),this.indicatorStyle.height=this.indicatorHeight+"px"):this.indicatorHeight=this.indicator.clientHeight,this.maxPosY=this.wrapperHeight-this.indicatorHeight,"clip"==this.options.shrink?(this.minBoundaryY=8-this.indicatorHeight,this.maxBoundaryY=this.wrapperHeight-8):(this.minBoundaryY=0,this.maxBoundaryY=this.maxPosY),this.maxPosY=this.wrapperHeight-this.indicatorHeight,this.sizeRatioY=this.options.speedRatioY||this.scroller.maxScrollY&&this.maxPosY/this.scroller.maxScrollY),this.updatePosition()},updatePosition:function(){var t=this.options.listenX&&h.round(this.sizeRatioX*this.scroller.x)||0,i=this.options.listenY&&h.round(this.sizeRatioY*this.scroller.y)||0;this.options.ignoreBoundaries||(t<this.minBoundaryX?("scale"==this.options.shrink&&(this.width=h.max(this.indicatorWidth+t,8),this.indicatorStyle.width=this.width+"px"),t=this.minBoundaryX):t>this.maxBoundaryX?"scale"==this.options.shrink?(this.width=h.max(this.indicatorWidth-(t-this.maxPosX),8),this.indicatorStyle.width=this.width+"px",t=this.maxPosX+this.indicatorWidth-this.width):t=this.maxBoundaryX:"scale"==this.options.shrink&&this.width!=this.indicatorWidth&&(this.width=this.indicatorWidth,this.indicatorStyle.width=this.width+"px"),i<this.minBoundaryY?("scale"==this.options.shrink&&(this.height=h.max(this.indicatorHeight+3*i,8),this.indicatorStyle.height=this.height+"px"),i=this.minBoundaryY):i>this.maxBoundaryY?"scale"==this.options.shrink?(this.height=h.max(this.indicatorHeight-3*(i-this.maxPosY),8),this.indicatorStyle.height=this.height+"px",i=this.maxPosY+this.indicatorHeight-this.height):i=this.maxBoundaryY:"scale"==this.options.shrink&&this.height!=this.indicatorHeight&&(this.height=this.indicatorHeight,this.indicatorStyle.height=this.height+"px")),this.x=t,this.y=i,this.scroller.options.useTransform?this.indicatorStyle[d.style.transform]="translate("+t+"px,"+i+"px)"+this.scroller.translateZ:(this.indicatorStyle.left=t+"px",this.indicatorStyle.top=i+"px")},_pos:function(t,i){t<0?t=0:t>this.maxPosX&&(t=this.maxPosX),i<0?i=0:i>this.maxPosY&&(i=this.maxPosY),t=this.options.listenX?h.round(t/this.sizeRatioX):this.scroller.x,i=this.options.listenY?h.round(i/this.sizeRatioY):this.scroller.y,this.scroller.scrollTo(t,i)},fade:function(t,i){if(!i||this.visible){clearTimeout(this.fadeTimeout),this.fadeTimeout=null;var s=t?250:500,e=t?0:300;t=t?"1":"0",this.wrapperStyle[d.style.transitionDuration]=s+"ms",this.fadeTimeout=setTimeout(function(t){this.wrapperStyle.opacity=t,this.visible=+t}.bind(this,t),e)}}},a.utils=d,void 0!==t&&t.exports?t.exports=a:void 0!==(e=function(){return a}.call(i,s,i,t))&&(t.exports=e)}(window,document,Math)},238:function(t,i,s){t.exports=s(103)}},[238])});
|