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