Elffuss BraidHub

kikocis/iscroll public

infinite scrolling
Changeset0a2801d9d66c112e2a50e26285257d6f3457d849ca7149108036328627f4fcce
Authorcubiq <matteo@cubiq.org> · 2014-01-08 18:46 +01:00
Committercubiq <matteo@cubiq.org> · 2014-01-08 18:46 +01:00
Parents354758342380

Browse the files at this changeset

24 files changed

modified CONTRIBUTING.md +6 −6
@@ -1,13 +1,8 @@
11 # Contributing to iScroll / FAQ
22
3-## Why is my patch not accepted?
4-Thank you very much for your contribution. Please make sure you signed the CLA (see below). Also, we have to test every change on countless devices before we can add it to the project. Often one fix for one device breaks a lof of stuff for others. Unlike other open-source projects, we don't have the luxury of being able to unit test changes. A lot of manual testing is involved. Please be patient with us.
5-
6-If you want to speed up the process, please provide your own test results and try to be as specific as possible.
7-
83 ## Why we need a CLA (Contributor License Agreement)
94
10-All contributions are welcome but to enforce the openess of this script I have to ask all contributors to sign a Contributor License Agreement. I'm sorry about this but it's the only way to keep the script free and Open Source.
5+All contributions are welcome but to enforce the openness of this script I have to ask all contributors to sign a Contributor License Agreement. I'm sorry about this but it's the only way to keep the script free and Open Source.
116
127 If you are an individual, please sign the following form:
138 http://cubiq.org/iscroll/cla/individual.html
@@ -15,5 +10,10 @@
1510 If you are a company or an entity please sign the following form:
1611 http://cubiq.org/iscroll/cla/entity.html
1712
13+## Why is my patch not accepted yet?
14+Thank you very much for your contribution. Please make sure you signed the CLA (see above). Please note that pull requests may take some time to be accepted. Testing iScroll is one of the most time consuming tasks of the project. iScroll works from desktop to smartphone, from tablets to smart TVs. I do not have physical access to all the testing devices, so before I can push a change I have to make sure that the new code is working everywhere.
15+
16+If you want to speed up the process, please provide your own test results and try to be as more specific as possible.
17+
1818 Thanks!
1919 Matteo Spinelli
No newline at the end of the file
modified README.md +769 −7
@@ -1,13 +1,775 @@
1-# iScroll 5
1+# iScroll, smooth scrolling for the web
22
3-Documentation soon to come. In the meantime please reference to the examples in the demos directory.
3+iScroll is a high performance, small footprint, dependency free, multi-platform javascript scroller.
44
5-## Build system (for developers only)
5+It works on desktop, mobile and smart TV. It has been vigorously optimized for performance and size so to offer the smoothest result on modern and old devices alike.
66
7-iScroll comes with a custom build system. The required nodejs packages are included in the package.json. To build all main releases just do:
7+iScroll does not just *scroll*. It can handle any element that needs to be moved with user interaction. It adds scrolling, zooming, panning, infinite scrolling, parallax scrolling, carousels to your projects and manages to do that in just 4kb. Give it a broom and it will also clean up your office.
88
9- ./build.js dist
9+Even on platforms where native scrolling is good enough, iScroll adds features that wouldn't be possible otherwise. Specifically:
1010
11-The compiled scripts will be saved in the /build and /dist directories.
11+* Granular control over the scroll position, even during momentum. You can always get and set the x,y coordinates of the scroller.
12+* Animation can be customized with user defined easing functions (bounce, elastic, back, ...).
13+* You can easily hook to a plethora of custom events (onBeforeScrollStart, onScrollStart, onScroll, onScrollEnd, flick, ...).
14+* Out of the box multi-platform support. From older Android devices to the latest iPhone, from Chrome to Internet Explorer.
1215
13-Script released under the MIT license.
No newline at the end of the file
16+<h2 id="iscroll-versions">The many faces of iScroll</h2>
17+
18+iScroll is all about optimization. To reach the highest performance it has been divided into multiple versions. You can pick the version that better suits your need.
19+
20+Currently we have the following fragrances:
21+
22+* **iscroll.js**, it is the general purpose script. It includes the most commonly used features and grants very high performance in a small footprint.
23+* **iscroll-lite.js**, it is a stripped down version of the main script. It doesn't support snap, scrollbars, mouse wheel, key bindings. But if all you need is scrolling (especially on mobile) *iScroll lite* is the smallest, fastest solution.
24+* **iscroll-probe.js**, probing the current scroll position is a demanding task, that's why I decided to build a dedicated version for it. If you need to know the scrolling position at any given time, this is the iScroll for you. (I'm making some more tests, this might end up in the regular `iscroll.js` script, so keep an eye on it).
25+* **iscroll-zoom.js**, adds zooming to the standard scroll.
26+* **iscroll-infinite.js**, can do infinite and cached scrolling. Handling very long lists of elements is no easy task for mobile devices. *iScroll infinite* uses a caching mechanism that lets you scroll a potentially infinite number of elements.
27+
28+<h2 id="getting-started">Getting started</h2>
29+
30+So you want to be an iScroll master. Cool, because that is what I'll make you into.
31+
32+The best way to learn the iScroll is by looking at the demos. In the archive you'll find a `demo` folder [stuffed with examples](https://github.com/cubiq/iscroll/tree/master/demos). Most of the script features are outlined there.
33+
34+`IScroll` is a class that needs to be initiated for each scrolling area. There's no limit to the number of iScrolls you can have in each page if not that imposed by the device CPU/Memory.
35+
36+Try to keep the DOM as simple as possible. iScroll uses the hardware compositing layer but there's a limit to the elements the hardware can handle.
37+
38+The optimal HTML structure is:
39+
40+ <div id="wrapper">
41+ <ul>
42+ <li>...</li>
43+ <li>...</li>
44+ ...
45+ </ul>
46+ </div>
47+
48+iScroll must be applied to the wrapper of the scrolling area. In the above example the `UL` element will be scrolled. Only the first child of the container element is scrolled, additional children are simply ignored.
49+
50+<div class="tip">
51+<p><code>box-shadow</code>, <code>opacity</code>, <code>text-shadow</code> and alpha channels are all properties that don't go very well together with hardware acceleration. Scrolling might look good with few elements but as soon as your DOM becomes more complex you'll start experiencing lag and jerkiness.</p>
52+
53+<p>Sometimes a background image to simulate the shadow performs better than <code>box-shadow</code>. The bottom line is: experiment with CSS properties, you'll be surprised by the difference in performance a small CSS change can do.</p>
54+</div>
55+
56+The minimal call to initiate the script is as follow:
57+
58+ <script type="text/javascript">
59+ var myScroll = new IScroll('#wrapper');
60+ </script>
61+
62+The first parameter can be a string representing the DOM selector of the scroll container element OR a reference to the element itself. The following is a valid syntax too:
63+
64+ var wrapper = document.getElementById('wrapper');
65+ var myScroll = new IScroll(wrapper);
66+
67+So basically either you pass the element directly or a string that will be given to `querySelector`. Consequently to select a wrapper by its class name instead of the ID, you'd do:
68+
69+ var myScroll = new IScroll('.wrapper');
70+
71+Note that iScroll uses `querySelector` not `querySelectorAll`, so only the first occurrence of the selector is used. If you need to apply iScroll to multiple objects you'll have to build your own cycle.
72+
73+<div class="tip">
74+<p>You don't strictly need to assign the instance to a variable (<code>myScroll</code>), but it is handy to keep a reference to the iScroll (for example you could later check the scroller position).</p>
75+</div>
76+
77+<h2 id="initialization">Initialization</h2>
78+
79+The iScroll needs to be initiated when the DOM is ready. The safest bet is to start it on window `onload` event. `DOMContentLoaded` or inline initialization are also fine but remember that the script needs to know the height/width of the scrolling area. If you have images that don't have explicit width/height declaration, iScroll will most likely end up with a wrong scroller size.
80+
81+<div class="important">
82+<p>Add <code>position:relative</code> or <code>absolute</code> to the scroll container (the wrapper). That alone usually solves most of the problems with wrongly calculated wrapper dimensions.</p>
83+</div>
84+
85+To sum up, the smallest iScroll configuration is:
86+
87+ <head>
88+ ...
89+ <script type="text/javascript" src="iscroll.js"></script>
90+ <script type="text/javascript">
91+ var myScroll;
92+ function loaded() {
93+ myScroll = new IScroll('#wrapper');
94+ }
95+ </script>
96+ </head>
97+ ...
98+ <body onload="loaded()">
99+ <div id="wrapper">
100+ <ul>
101+ <li>...</li>
102+ <li>...</li>
103+ ...
104+ </ul>
105+ </div>
106+ </body>
107+
108+Refer to the [barebone example](http://lab.cubiq.org/iscroll5/demos/barebone/) for more details on the minimal CSS/HTML requirements.
109+
110+<div class="tip">
111+<p>If you have a complex DOM it is sometimes smart to add a little delay from the <code>onload</code> event to iScroll initialization. Executing the iScroll with a 100 or 200 milliseconds delay gives the browser that little rest that can save your ass.</p>
112+</div>
113+
114+<h2 id="configuring">Configuring the iScroll</h2>
115+
116+iScroll can be configured by passing a second parameter during the initialization phase.
117+
118+ var myScroll = new IScroll('#wrapper', {
119+ mouseWheel: true,
120+ scrollbars: true
121+ });
122+
123+The example above turns on mouse wheel support and scrollbars.
124+
125+After initialization you can access the *normalized* values from the `options` object. Eg:
126+
127+ console.log(myScroll.options);
128+
129+The above will return the configuration the `myScroll` instance will run on. By *normalized* I mean that if you set `useTransform:true` (for example) but the browser doesn't support CSS transforms, `useTransform` will be `false`.
130+
131+<h2 id="the-core">Understanding the core</h2>
132+
133+iScroll uses various techniques to scroll based on device/browser capability. **Normally you don't need to configure the engine**, iScroll is smart enough to pick the best for you.
134+
135+Nonetheless it is important to understand which mechanisms iScroll works on and how to configure them.
136+
137+### <small>options.</small>useTransform
138+
139+By default the engine uses the `transform` CSS property. Setting this to `false` scrolls like we were in 2007, ie: using the `top`/`left` (and thus the scroller needs to be absolutely positioned).
140+
141+This might be useful when scrolling sensitive content such as Flash, iframes and videos, but be warned: performance loss is huge.
142+
143+Default: `true`
144+
145+### <small>options.</small>useTransition
146+
147+iScroll uses CSS transition to perform animations (momentum and bounce). By setting this to `false`, `requestAnimationFrame` is used instead.
148+
149+On modern browsers the difference is barely noticeable. On older devices transitions perform better.
150+
151+Default: `true`
152+
153+### <small>options.</small>HWCompositing
154+
155+This option tries to put the scroller on the hardware layer by appending `translateZ(0)` to the transform CSS property. This greatly increases performance especially on mobile, but there are situations where you might want to disable it (notably if you have too many elements and the hardware can't catch up).
156+
157+Default: `true`
158+
159+<div class="important">
160+<p>If unsure leave iScroll decide what's the optimal config. For best performance all the above options should be set to <code>true</code> (or better leave them undefined as they are set to true automatically). You may try to play with them in case you encounter hiccups and memory leaks.</p>
161+</div>
162+
163+<h2 id="basic-features">Basic features</h2>
164+
165+### <small>options.</small>bounce
166+
167+When the scroller meets the boundary it performs a small bounce animation. Disabling bounce may help reach smoother results on old or slow devices.
168+
169+Default: `true`
170+
171+### <small>options.</small>click
172+
173+To override the native scrolling iScroll has to inhibit some default browser behaviors, such as mouse clicks. If you want your application to respond to the *click* event you have to explicitly set this option to `true`. Please note that it is suggested to use the custom `tap` event instead (see below).
174+
175+Default: `false`
176+
177+### <small>options.</small>disableMouse<br/><small>options.</small>disablePointer<br/><small>options.</small>disableTouch
178+
179+By default iScroll listens to all pointer events and reacts to the first one that occurs. It may seem a waste of resources but feature detection has proven quite unreliable and this *listen-to-all* approach is our safest bet for wide browser/device compatibility.
180+
181+If you have an internal mechanism for device detection or you know in advance where your script will run on, you may want to disable all event sets you don't need (mouse, pointer or touch events).
182+
183+For example to disable mouse and pointer events:
184+
185+ var myScroll = new IScroll('#wrapper', {
186+ disableMouse: true,
187+ disablePointer: true
188+ });
189+
190+Default: `false`
191+
192+### <small>options.</small>eventPassthrough
193+
194+Sometimes you want to preserve native vertical scroll but being able to add an horizontal iScroll (maybe a carousel). Set this to `true` and the iScroll area will react to horizontal swipes only. Vertical swipes will naturally scroll the whole page.
195+
196+See [event passthrough demo](http://lab.cubiq.org/iscroll5/demos/event-passthrough/) on a mobile device. Note that this can be set to `'horizontal'` to inverse the behavior (native horizontal scroll, vertical iScroll).
197+
198+### <small>options.</small>freeScroll
199+
200+This is useful mainly on 2D scrollers (when you need to scroll both horizontally and vertically). Normally when you start scrolling in one direction the other is locked.
201+
202+Sometimes you just want to move freely with no constrains. In these cases you can set this option to `true`. See [2D scroll demo](http://lab.cubiq.org/iscroll5/demos/2d-scroll/).
203+
204+Default: `false`
205+
206+### <small>options.</small>keyBindings
207+
208+Set this to `true` to activate keyboard (and remote controls) interaction. See the [Key bindings](#key-bindings) section below for more information.
209+
210+Default: `false`
211+
212+### <small>options.</small>invertWheelDirection
213+
214+Meaningful when mouse wheel support is activated, in which case it just inverts the scrolling direction. (ie. going down scrolls up and vice-versa).
215+
216+Default: `false`
217+
218+### <small>options.</small>momentum
219+
220+You can turn on/off the momentum animation performed when the user quickly flicks on screen. Turning this off greatly enhance performance.
221+
222+Default: `true`
223+
224+### <small>options.</small>mouseWheel
225+
226+Listen to the mouse wheel event.
227+
228+Default: `false`
229+
230+### <small>options.</small>preventDefault
231+
232+Whether or not to `preventDefault()` when events are fired. This should be left `true` unless you really know what you are doing.
233+
234+See `preventDefaultException` in the [Advanced features](#advanced-features) for more control over the preventDefault behavior.
235+
236+Default: `true`
237+
238+### <small>options.</small>scrollbars
239+
240+Wheter or not to display the default scrollbars. See more in the [Scrollbar](#scrollbar) section.
241+
242+Default: `false`.
243+
244+### <small>options.</small>scrollX<br/><small>options.</small>scrollY
245+
246+By default only vertical scrolling is enabled. If you need to scroll horizontally you have to set `scrollX` to `true`. See [horizontal demo](http://lab.cubiq.org/iscroll5/demos/horizontal/).
247+
248+See also the **freeScroll** option.
249+
250+Default: `scrollX: false`, `scrollY: true`
251+
252+<div class="important">
253+<p>Note that <code>scrollX/Y: true</code> has the same effect as <code>overflow: auto</code>. Setting one direction to <code>false</code> helps to spare some checks and thus CPU cycles.</p>
254+</div>
255+
256+### <small>options.</small>startX<br/><small>options.</small>startY
257+
258+By default iScroll starts at `0, 0` (top left) position, you can instruct the scroller to kickoff at a different location.
259+
260+Default: `0`
261+
262+### <small>options.</small>tap
263+
264+Set this to `true` to let iScroll emit a custom `tap` event when the scroll area is clicked/tapped but not scrolled.
265+
266+This is the suggested way to handle user interaction with clickable elements. To listen to the tap event you would add an event listener as you would do for a standard event. Example:
267+
268+ element.addEventListener('tap', doSomething, false); \\ Native
269+ $('#element').on('tap', doSomething); \\ jQuery
270+
271+You can also customize the event name by passing a string. Eg:
272+
273+ tap: 'myCustomTapEvent'
274+
275+In this case you'd listen to `myCustomTapEvent`.
276+
277+Default: `false`
278+
279+<h2 id="scrollbars">Scrollbars</h2>
280+
281+The scrollbars are more than just what the name suggests. In fact internally they are referenced as *indicators*.
282+
283+An indicator listens to the scroller position and normally it just shows its position in relation to whole, but what it can do is so much more.
284+
285+Let's start with the basis.
286+
287+### <small>options.</small>scrollbars
288+
289+As we mentioned in the [Basic features section](#basic-features) there's only one thing that you got to do to activate the scrollbars in all their splendor, and that one thing is:
290+
291+ var myScroll = new IScroll('#wrapper', {
292+ scrollbars: true
293+ });
294+
295+Of course the default behavior can be personalized.
296+
297+### <small>options.</small>fadeScrollbars
298+
299+When not in use the scrollbar fades away. Leave this to `false` to spare resources.
300+
301+Default: `false`
302+
303+### <small>options.</small>interactiveScrollbars
304+
305+The scrollbar becomes draggable and user can interact with it.
306+
307+Default: `false`
308+
309+### <small>options.</small>resizeScrollbars
310+
311+The scrollbar size changes based on the proportion between the wrapper and the scroller width/height. Setting this to `false` makes the scrollbar a fixed size. This might be useful in case of custom styled scrollbars ([see below](#styling-the-scrollbar)).
312+
313+Default: `true`
314+
315+### <small>options.</small>shrinkScrollbars
316+
317+When scrolling outside of the boundaries the scrollbar is shrunk by a small amount.
318+
319+Valid values are: `'clip'` and `'scale'`.
320+
321+`'clip'` just moves the indicator outside of its container, the impression is that the scrollbar shrinks but it is simply moving out of the screen. If you can live with the visual effect this option **immensely improves overall performance**.
322+
323+`'scale'` turns off `useTransition` hence all animations are served with `requestAnimationFrame`. The indicator is actually varied in size and the end result is nicer to the eye.
324+
325+Default: `false`
326+
327+<div class="tip">
328+<p>Note that resizing can't be performed by the GPU, so <code>scale</code> is all on the CPU.</p>
329+<p>If your application runs on multiple devices my suggestion would be to switch this option to <code>'scale'</code>, <code>'clip'</code> or <code>false</code> based on the platform responsiveness (eg: on older mobile devices you could set this to <code>'clip'</code> and on desktop browser to <code>'scale'</code>).</p>
330+</div>
331+
332+See the [scrollbar demo](http://lab.cubiq.org/iscroll5/demos/scrollbars/).
333+
334+<h3 id="styling-the-scrollbar">Styling the scrollbar</h3>
335+
336+So you don't like the default scrollbar styling and you think you could do better. Help yourself! iScroll makes dressing the scrollbar a snap. First of all set the `scrollbars` option to `'custom'`:
337+
338+ var myScroll = new IScroll('#wrapper', {
339+ scrollbars: 'custom'
340+ });
341+
342+Then use the following CSS classes to style the little bastards.
343+
344+* **.iScrollHorizontalScrollbar**, this is applied to the horizontal container. The element that actually hosts the scrollbar indicator.
345+* **.iScrollVerticalScrollbar**, same as above but for the vertical container.
346+* **.iScrollIndicator**, the actual scrollbar indicator.
347+* **.iScrollBothScrollbars**, this is added to the container elements when both scrollbars are shown. Normally just one (horizontal or vertical) is visible.
348+
349+The [styled scrollbars demo](http://lab.cubiq.org/iscroll5/demos/styled-scrollbars/) should make things clearer than my lousy explanation.
350+
351+If you set `resizeScrollbars: false` you could make the scrollbar of a fixed size, otherwise it would be resized based on the scroller length.
352+
353+Please keep reading to the following section for a revelation that will shake your world.
354+
355+<h2 id="indicators">Indicators</h2>
356+
357+All the scrollbar options above are in reality just wrappers to the low level `indicators` option. It looks more or less like this:
358+
359+ var myScroll = new IScroll('#wrapper', {
360+ indicators: {
361+ el: [element|element selector]
362+ fade: false,
363+ ignoreBoundaries: false,
364+ interactive: false,
365+ listenX: true,
366+ listenY: true,
367+ resize: true,
368+ shrink: false,
369+ speedRatioX: 0,
370+ speedRatioY: 0,
371+ }
372+ });
373+
374+### <small>options.indicators.</small>el
375+
376+This is a mandatory parameter which holds a reference to the scrollbar container element. The first child inside the container will be the indicator. Note that the scrollbar can be anywhere on your document, it doesn't need to be inside the scroller wrapper. Do you start perceiving the power of such tool?
377+
378+Valid syntax would be:
379+
380+ indicators: {
381+ el: document.getElementById('indicator')
382+ }
383+
384+Or simply:
385+
386+ indicators: {
387+ el: '#indicator'
388+ }
389+
390+### <small>options.indicators.</small>ignoreBoundaries
391+
392+This tells the indicator to ignore the boundaries imposed by its container. Since we can alter the speed ratio of the scrollbar, it is useful to just let the scrollbar go. Say you want the indicator to go twice as fast as the scroller, it would reach the end of its run very quickly. This option is used for [parallax scrolling](#parallax-scrolling).
393+
394+Default: `false`
395+
396+### <small>options.indicators.</small>listenX<br/><small>options.indicators.</small>listenY
397+
398+To which axis the indicator listens to. It can be just one or both.
399+
400+Default: `true`
401+
402+### <small>options.indicators.</small>speedRatioX<br/><small>options.indicators.</small>speedRatioY
403+
404+The speed the indicator moves in relation to the main scroller size. By default this is set automatically. You rarely need to alter this value.
405+
406+Default: `0`
407+
408+### <small>options.indicators.</small>fade<br/><small>options.indicators.</small>interactive<br/><small>options.indicators.</small>resize</br><small>options.indicators.</small>shrink
409+
410+These are the same options we explored in the [scrollbars section](#scrollbars), I'm not going to insult your intelligence and repeat them here.
411+
412+<div class="important">
413+<p><strong>Do not cross the streams. It would be bad!</strong> Do not mix the scrollbars syntax (<code>options.scrollbars</code>, <code>options.fadeScrollbars</code>, <code>options.interactiveScrollbars</code>, ...) with the indicators! Use one or the other.</p>
414+</div>
415+
416+Have a look at the [minimap demo](http://lab.cubiq.org/iscroll5/demos/minimap/) to get a glance at the power of the `indicators` option.
417+
418+The wittiest of you would have noticed that `indicators` is actually plural... Yes, exactly, passing an array of objects you can have a virtually infinite number of indicators. I don't what you may need them for, but hey! who am I to argue about your scrollbar preferences?
419+
420+## <span id="parallax-scrolling">Parallax scrolling</span>
421+
422+Parallax scrolling is just a *collateral damage* of the [Indicators](#indicators) functionality.
423+
424+An indicator is just a layer that follows the movement and animation applied to the main scroller. If you see it like that you'll understand the power behind this feature. To this add that you can have any number of indicators and the parallax scrolling is served.
425+
426+Please refer to the [parallax demo](http://lab.cubiq.org/iscroll5/demos/parallax/).
427+
428+## Scrolling programmatically
429+
430+You silly! Of course you can scroll programmaticaly!
431+
432+### scrollTo(x, y, time, easing)
433+
434+Say your iScroll instance resides into the `myScroll` variable. You can easily scroll to any position with the following syntax:
435+
436+ myScroll.scrollTo(0, -100);
437+
438+That would scroll down by 100 pixels. Remember: 0 is always the top left corner. To scroll you have to pass negative numbers.
439+
440+`time` and `easing` are optional. They regulates the duration (in ms) and the easing function of the animation respectively.
441+
442+The easing functions are available in the `IScroll.utils.ease` object. For example to apply a 1 second elastic easing you'd do:
443+
444+ myScroll.scrollTo(0, -100, 1000, IScroll.utils.ease.elastic);
445+
446+The available options are: `quadratic`, `circular`, `back`, `bounce`, `elastic`.
447+
448+### scrollBy(x, y, time, easing)
449+
450+Same as above but X and Y are relative to the current position.
451+
452+ myScroll.scrollBy(0, -10);
453+
454+Would scroll 10 pixels down. If you are at -100, you'll end up at -110.
455+
456+### scrollToElement(el, time, offsetX, offsetY, easing)
457+
458+You're gonna like this. Sit tight.
459+
460+The only mandatory parameter is `el`. Pass an element or a selector and iScroll will try to scroll to the top/left of that element.
461+
462+`time` is optional and sets the animation duration.
463+
464+`offsetX` and `offsetY` define an offset in pixels, so that you can scroll to that element plus a the specified offset. Not only that. If you set them to `true` the element will be centered on screen. Refer to the [scroll to element](http://lab.cubiq.org/iscroll5/demos/scroll-to-element/) example.
465+
466+`easing` works the same way as per the **scrollTo** method.
467+
468+<h2 id="snap">Snap</h2>
469+
470+iScroll can snap to fixed positions and elements.
471+
472+### <small>options.</small>snap
473+
474+The simplest snap config is as follow:
475+
476+ var myScroll = new IScroll('#wrapper', {
477+ snap: true
478+ });
479+
480+This would automatically split the scroller into pages the size of the container.
481+
482+`snap` also takes a string as a value. The string will be the selector to the elements the scroller will be snapped to. So the following
483+
484+ var myScroll = new IScroll('#wrapper', {
485+ snap: 'li'
486+ });
487+
488+would snap to each and every `LI` tag.
489+
490+To help you navigate through the snap points iScroll grants access to a series of interesting methods.
491+
492+### goToPage(x, y, time, easing)
493+
494+`x` and `y` represent the page number you want to scroll to in the horizontal or vertical axes (yeah, it's the plural of *axis*, I checked). If the scroller in mono-dimensional, just pass `0` to the axis you don't need.
495+
496+`time` is the duration of the animation, `easing` the easing function used to scroll to the point. Refer to the **option.bounceEasing** in the [Advanced features](#advanced-features). They are both optional.
497+
498+ myScroll.goToPage(10, 0, 1000);
499+
500+This would scroll to the 10th page on the horizontal axis in 1 second.
501+
502+### next()<br/>prev()
503+
504+Go to the next and previous page based on current position.
505+
506+<h2 id="zoom">Zoom</h2>
507+
508+To use the pinch/zoom functionality you better use the `iscroll-zoom.js` script.
509+
510+### <small>options.</small>zoom
511+
512+Set this to `true` to activate zoom.
513+
514+Default: `false`
515+
516+### <small>options.</small>zoomMax
517+
518+Maximum zoom level.
519+
520+Default: `4`
521+
522+### <small>options.</small>zoomMin
523+
524+Minimum zoom level.
525+
526+Default: `1`
527+
528+### <small>options.</small>zoomStart
529+
530+Starting zoom level.
531+
532+Default: `1`
533+
534+### <small>options.</small>wheelAction
535+
536+Wheel action can be set to `'zoom'` to have the wheel regulate the zoom level instead of scrolling position.
537+
538+Default: `undefined` (ie: the mouse wheel scrolls)
539+
540+To sum up, a nice zoom config would be:
541+
542+ myScroll = new IScroll('#wrapper', {
543+ zoom: true,
544+ mouseWheel: true,
545+ wheelAction: 'zoom'
546+ });
547+
548+<div class="important">
549+<p>The zoom is performed with CSS transform. iScroll can zoom only on browsers that support that.</p>
550+</div>
551+
552+<div class="tip">
553+<p>Some browsers (notably webkit based ones) take a snapshot of the zooming area as soon as they are placed on the hardware compositing layer (say as soon as you apply a transform to them). This snapshot is used as a texture for the zooming area and it can hardly be updated. This means that your texture will be based on elements at <strong>scale 1</strong> and zooming in will result in blurred, low definition text and images.</p>
554+
555+<p>A simple solution is to load content at double (or triple) its actual resolution and scale it down inside a <code>scale(0.5)</code> div. This should be enough to grant you a better result. I hope to be able to post more demos soon</p>
556+</div>
557+
558+Refer to the [zoom demo](http://lab.cubiq.org/iscroll5/demos/zoom/).
559+
560+### zoom(scale, x, y, time)
561+
562+Juicy method that lets you zoom programmatically.
563+
564+`scale` is the zoom factor.
565+
566+`x` and `y` the focus point, aka the center of the zoom. If not specified, the center of the screen will be used.
567+
568+`time` is the duration of the animation in milliseconds (optional).
569+
570+<h2 id="infinite-scrolling">Infinite scrolling</h2>
571+
572+iScroll integrates a smart caching system that allows to handle of a virtually infinite amount of data using (and reusing) just a bunch of elements.
573+
574+Infinite scrolling is in an early stage of development and although it can be considered stable, it is not ready for wide consumption.
575+
576+Please review the [infinite demo](http://lab.cubiq.org/iscroll5/demos/infinite/) and send your suggestions and bug reports.
577+
578+I will add more details as soon as the functionality evolves.
579+
580+<h2 id="advanced-options">Advanced options</h2>
581+
582+For the hardcore developer.
583+
584+### <small>options.</small>bindToWrapper
585+
586+The `move` event is normally bound to the document and not the scroll container. When you move the cursor/finger out of the wrapper the scrolling keeps going. This is usually what you want, but you can also bind the move event to wrapper itself. Doing so as soon as the pointer leaves the container the scroll stops.
587+
588+Default: `false`
589+
590+### <small>options.</small>bounceEasing
591+
592+Easing function performed during the bounce animation. Valid values are: `'quadratic'`, `'circular'`, `'back'`, `'bounce'`, `'elastic'`. See the [bounce easing demo](http://lab.cubiq.org/iscroll5/demos/bounce-easing/), drag the scroller down and release.
593+
594+`bounceEasing` is a bit smarter than that. You can also feed a custom easing function, like so:
595+
596+ bounceEasing: {
597+ style: 'cubic-bezier(0,0,1,1)',
598+ fn: function (k) { return k; }
599+ }
600+
601+The above would perform a linear easing. The `style` option is used every time the animation is executed with CSS transitions, `fn` is used with `requestAnimationFrame`. If the easing function is too complex and can't be represented by a cubic bezier just pass `''` (empty string) as `style`.
602+
603+Note that `bounce` and `elastic` can't be performed by CSS transitions.
604+
605+Default: `'circular'`
606+
607+### <small>options.</small>bounceTime
608+
609+Duration in millisecond of the bounce animation.
610+
611+Default: `600`
612+
613+### <small>options.</small>mouseWheelSpeed
614+
615+Set the speed of the mouse wheel.
616+
617+Default: `20`
618+
619+### <small>options.</small>preventDefaultException
620+
621+These are all the exceptions when `preventDefault()` would be fired anyway despite the **preventDefault** option value.
622+
623+This is a pretty powerful option, if you don't want to `preventDefault()` on all elements with *formfield* class name for example, you could pass the following:
624+
625+ preventDefaultException: { className: /(^|\s)formfield(\s|$)/ }
626+
627+Default: `{ tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ }`.
628+
629+### <small>options.</small>resizePolling
630+
631+When you resize the window iScroll has to recalculate elements position and dimension. This might be a pretty daunting task for the poor little fella. To give it some rest the polling is set to 60 milliseconds.
632+
633+By reducing this value you get better visual effect but the script becomes more aggressive on the CPU. The default value seems a good compromise.
634+
635+Default: `60`
636+
637+<h2 id="refresh">Mastering the refresh method</h2>
638+
639+iScroll needs to know the exact dimensions of both the wrapper and the scroller. They are computed at start up but if your elements change in size, we need to tell iScroll that you are messing with the DOM.
640+
641+This is achieved by calling the `refresh` method with the right timing. Please follow me closely, understanding this will save you hours of frustration.
642+
643+Every time you touch the DOM the browser renderer repaints the page. Once this repaint has happened we can safely read the new DOM properties. The repaint phase is not instantaneous and it happens only at the end of the scope that triggered it. That's why we need to give the renderer a little rest before refreshing the iScroll.
644+
645+To ensure that javascript gets the updated properties you should defer the refreh with something like this:
646+
647+ ajax('page.php', onCompletion);
648+
649+ function onCompletion () {
650+ // Update here your DOM
651+
652+ setTimeout(function () {
653+ myScroll.refresh();
654+ }, 0);
655+ };
656+
657+We have placed the `refresh()` call into a zero timeout. That is likely all you need to correctly refresh the iScroll boundaries. There are other ways to wait for the repaint, but the zero-timeout has proven pretty solid.
658+
659+<div class="tip">
660+<p>Consider that if you have a very complex HTML structure you may give the browser some more rest and raise the timeout to 100 or 200 milliseconds.</p>
661+
662+<p>This is generally true for all the tasks that have to be done on the DOM. Always give the renderer some rest.</p>
663+</div>
664+
665+<h2 id="custom-events">Custom events</h2>
666+
667+iScroll also emits some useful custom events you can hook to.
668+
669+To register them you use the `on(type, fn)` method.
670+
671+ myScroll = new IScroll('#wrapper');
672+ myScroll.on('scrollEnd', doSomething);
673+
674+The above code executes the `doSomething` function every time the content stops scrolling.
675+
676+The available types are:
677+
678+* **beforeScrollStart**, executed as soon as user touches the screen but before the scrolling has initiated.
679+* **scrollCancel**, scroll initiated but didn't happen.
680+* **scrollStart**, the scroll started.
681+* **scroll**, the content is scrolling. Available only in `scroll-probe.js` edition. See [onScroll event](#onscroll).
682+* **scrollEnd**, content stopped scrolling.
683+* **flick**, user flicked left/right.
684+* **zoomStart**, user started zooming.
685+* **zoomEnd**, zoom ended.
686+
687+<h2 id="onscroll">onScroll event</h2>
688+
689+The `scroll` event is available on **iScroll probe edition** only (`iscroll-probe.js`). The probe behavior can be altered through the `probeType` option.
690+
691+### <small>options.</small>probeType
692+
693+This regulates the probe aggressiveness or the frequency at which the `scroll` event is fired. Valid values are: `1`, `2`, `3`. The higher the number the more aggressive the probe. The more aggressive the probe the higher the impact on the CPU.
694+
695+`probeType: 1` has no impact on performance. The `scroll` event is fired only when the scroller is not busy doing its stuff.
696+
697+`probeType: 2` always executes the `scroll` event except during momentum and bounce. This resembles the native `onScroll` event.
698+
699+`probeType: 3` emits the `scroll` event with a to-the-pixel precision. Note that the scrolling is forced to `requestAnimationFrame` (ie: `useTransition:false`).
700+
701+Please see the [probe demo](http://lab.cubiq.org/iscroll5/demos/probe/).
702+
703+<h2 id="key-bindings">Key bindings</h2>
704+
705+You can activate support for keyboards and remote controls with the `keyBindings` option. By default iScroll listens to the arrow keys, page up/down, home/end but they are (wait for it) totally customizable.
706+
707+You can pass an object with the list of key codes you want iScroll to react to.
708+
709+The default values are as follow:
710+
711+ keyBindings: {
712+ pageUp: 33,
713+ pageDown: 34,
714+ end: 35,
715+ home: 36,
716+ left: 37,
717+ up: 38,
718+ right: 39,
719+ down: 40
720+ }
721+
722+You can also pass a string (eg: `pageUp: 'a'`) and iScroll will convert it for you. You could just think of a key code and iScroll would read it out of your mind.
723+
724+<h2 id="scroller-info">Useful scroller info</h2>
725+
726+iScroll stores many useful information that you can use to augment your application.
727+
728+You will probably find useful:
729+
730+* **myScroll.x/y**, current position
731+* **myScroll.directionX/Y**, last direction (-1 down/right, 0 still, 1 up/left)
732+* **myScroll.currentPage**, current snap point info
733+
734+These pieces of information may be useful when dealing with custom events. Eg:
735+
736+ myScroll = new IScroll('#wrapper');
737+ myScroll.on('scrollEnd', function () {
738+ if ( this.x < -1000 ) {
739+ // do something
740+ }
741+ });
742+
743+The above executes some code if the `x` position is lower than -1000px when the scroller stops. Note that I used `this` instead of `myScroll`, you can use both of course, but iScroll passes itself as `this` context when firing custom event functions.
744+
745+<h2 id="destroy">Destroy</h2>
746+
747+The public `destroy()` method can be used to free some memory when the iScroll is not needed anymore.
748+
749+ myScroll.destroy();
750+ myScroll = null;
751+
752+<h2 id="contributing">Contributing and CLA</h2>
753+
754+If you want to contribute to the iScroll development, before I can accept your submission I have to ask you to sign the [Contributor License Agreement](http://cubiq.org/iscroll/cla/). Unfortunately that is the only way to enforce the openness of the script.
755+
756+As an end user you have to do nothing of course. Actually the CLA ensures that nobody will even come after you asking for your first born for using the iScroll.
757+
758+Please note that pull requests may take some time to be accepted. Testing iScroll is one of the most time consuming tasks of the project. iScroll works from desktop to smartphone, from tablets to smart TVs. I do not have physical access to all the testing devices, so before I can push a change I have to make sure that the new code is working everywhere.
759+
760+Critical bugs are usually applied very quickly, but enhancements and coding style changes have to pass a longer review phase. *Remember that this is still a side project for me.*
761+
762+<h2 id="whos">Who is using iScroll</h2>
763+
764+It's impossible to track all the websites and applications that use the iScroll. It has been spotted on: Apple, Microsoft, People, LinkedIn, IKEA, Nike, Playboy, Bose, and countless others.
765+
766+<h2 id="license">License (MIT)</h2>
767+
768+
769+Copyright (c) 2014 Matteo Spinelli, http://cubiq.org/
770+
771+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
772+
773+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
774+
775+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
modified build.js +17 −2
@@ -9,7 +9,10 @@
99
1010 var releases = {
1111 lite: {
12- files: ['default/_animate.js', 'default/handleEvent.js']
12+ files: [
13+ 'default/_animate.js',
14+ 'default/handleEvent.js'
15+ ]
1316 },
1417
1518 iscroll: {
@@ -50,6 +53,18 @@
5053 'indicator/indicator.js'
5154 ],
5255 postProcessing: [ 'zoom/build.json', 'indicator/build.json', 'wheel/build.json', 'snap/build.json', 'keys/build.json' ]
56+ },
57+
58+ infinite: {
59+ files: [
60+ 'wheel/wheel.js',
61+ 'snap/snap.js',
62+ 'keys/keys.js',
63+ 'probe/_animate.js',
64+ 'infinite/infinite.js',
65+ 'default/handleEvent.js',
66+ ],
67+ postProcessing: [ 'wheel/build.json', 'snap/build.json', 'keys/build.json', 'infinite/build.json', 'probe/build.json' ]
5368 }
5469 };
5570
@@ -60,7 +75,7 @@
6075 }
6176
6277 if ( args[0] == 'dist' ) {
63- args = ['lite', 'iscroll', 'zoom', 'probe'];
78+ args = ['lite', 'iscroll', 'zoom', 'probe', 'infinite'];
6479 }
6580
6681 // Get the list of files
added build/iscroll-infinite.js +1544 −0
@@ -0,0 +1,1544 @@
1+/*! iScroll v5.1.0 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
2+(function (window, document, Math) {
3+var rAF = window.requestAnimationFrame ||
4+ window.webkitRequestAnimationFrame ||
5+ window.mozRequestAnimationFrame ||
6+ window.oRequestAnimationFrame ||
7+ window.msRequestAnimationFrame ||
8+ function (callback) { window.setTimeout(callback, 1000 / 60); };
9+
10+var utils = (function () {
11+ var me = {};
12+
13+ var _elementStyle = document.createElement('div').style;
14+ var _vendor = (function () {
15+ var vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'],
16+ transform,
17+ i = 0,
18+ l = vendors.length;
19+
20+ for ( ; i < l; i++ ) {
21+ transform = vendors[i] + 'ransform';
22+ if ( transform in _elementStyle ) return vendors[i].substr(0, vendors[i].length-1);
23+ }
24+
25+ return false;
26+ })();
27+
28+ function _prefixStyle (style) {
29+ if ( _vendor === false ) return false;
30+ if ( _vendor === '' ) return style;
31+ return _vendor + style.charAt(0).toUpperCase() + style.substr(1);
32+ }
33+
34+ me.getTime = Date.now || function getTime () { return new Date().getTime(); };
35+
36+ me.extend = function (target, obj) {
37+ for ( var i in obj ) {
38+ target[i] = obj[i];
39+ }
40+ };
41+
42+ me.addEvent = function (el, type, fn, capture) {
43+ el.addEventListener(type, fn, !!capture);
44+ };
45+
46+ me.removeEvent = function (el, type, fn, capture) {
47+ el.removeEventListener(type, fn, !!capture);
48+ };
49+
50+ me.momentum = function (current, start, time, lowerMargin, wrapperSize) {
51+ var distance = current - start,
52+ speed = Math.abs(distance) / time,
53+ destination,
54+ duration,
55+ deceleration = 0.0006;
56+
57+ destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );
58+ duration = speed / deceleration;
59+
60+ if ( destination < lowerMargin ) {
61+ destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin;
62+ distance = Math.abs(destination - current);
63+ duration = distance / speed;
64+ } else if ( destination > 0 ) {
65+ destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0;
66+ distance = Math.abs(current) + destination;
67+ duration = distance / speed;
68+ }
69+
70+ return {
71+ destination: Math.round(destination),
72+ duration: duration
73+ };
74+ };
75+
76+ var _transform = _prefixStyle('transform');
77+
78+ me.extend(me, {
79+ hasTransform: _transform !== false,
80+ hasPerspective: _prefixStyle('perspective') in _elementStyle,
81+ hasTouch: 'ontouchstart' in window,
82+ hasPointer: navigator.msPointerEnabled,
83+ hasTransition: _prefixStyle('transition') in _elementStyle
84+ });
85+
86+ // This should find all Android browsers lower than build 535.19 (both stock browser and webview)
87+ me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
88+
89+ me.extend(me.style = {}, {
90+ transform: _transform,
91+ transitionTimingFunction: _prefixStyle('transitionTimingFunction'),
92+ transitionDuration: _prefixStyle('transitionDuration'),
93+ transitionDelay: _prefixStyle('transitionDelay'),
94+ transformOrigin: _prefixStyle('transformOrigin')
95+ });
96+
97+ me.hasClass = function (e, c) {
98+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)");
99+ return re.test(e.className);
100+ };
101+
102+ me.addClass = function (e, c) {
103+ if ( me.hasClass(e, c) ) {
104+ return;
105+ }
106+
107+ var newclass = e.className.split(' ');
108+ newclass.push(c);
109+ e.className = newclass.join(' ');
110+ };
111+
112+ me.removeClass = function (e, c) {
113+ if ( !me.hasClass(e, c) ) {
114+ return;
115+ }
116+
117+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)", 'g');
118+ e.className = e.className.replace(re, ' ');
119+ };
120+
121+ me.offset = function (el) {
122+ var left = -el.offsetLeft,
123+ top = -el.offsetTop;
124+
125+ // jshint -W084
126+ while (el = el.offsetParent) {
127+ left -= el.offsetLeft;
128+ top -= el.offsetTop;
129+ }
130+ // jshint +W084
131+
132+ return {
133+ left: left,
134+ top: top
135+ };
136+ };
137+
138+ me.preventDefaultException = function (el, exceptions) {
139+ for ( var i in exceptions ) {
140+ if ( exceptions[i].test(el[i]) ) {
141+ return true;
142+ }
143+ }
144+
145+ return false;
146+ };
147+
148+ me.extend(me.eventType = {}, {
149+ touchstart: 1,
150+ touchmove: 1,
151+ touchend: 1,
152+
153+ mousedown: 2,
154+ mousemove: 2,
155+ mouseup: 2,
156+
157+ MSPointerDown: 3,
158+ MSPointerMove: 3,
159+ MSPointerUp: 3
160+ });
161+
162+ me.extend(me.ease = {}, {
163+ quadratic: {
164+ style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
165+ fn: function (k) {
166+ return k * ( 2 - k );
167+ }
168+ },
169+ circular: {
170+ 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)
171+ fn: function (k) {
172+ return Math.sqrt( 1 - ( --k * k ) );
173+ }
174+ },
175+ back: {
176+ style: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
177+ fn: function (k) {
178+ var b = 4;
179+ return ( k = k - 1 ) * k * ( ( b + 1 ) * k + b ) + 1;
180+ }
181+ },
182+ bounce: {
183+ style: '',
184+ fn: function (k) {
185+ if ( ( k /= 1 ) < ( 1 / 2.75 ) ) {
186+ return 7.5625 * k * k;
187+ } else if ( k < ( 2 / 2.75 ) ) {
188+ return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75;
189+ } else if ( k < ( 2.5 / 2.75 ) ) {
190+ return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375;
191+ } else {
192+ return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375;
193+ }
194+ }
195+ },
196+ elastic: {
197+ style: '',
198+ fn: function (k) {
199+ var f = 0.22,
200+ e = 0.4;
201+
202+ if ( k === 0 ) { return 0; }
203+ if ( k == 1 ) { return 1; }
204+
205+ return ( e * Math.pow( 2, - 10 * k ) * Math.sin( ( k - f / 4 ) * ( 2 * Math.PI ) / f ) + 1 );
206+ }
207+ }
208+ });
209+
210+ me.tap = function (e, eventName) {
211+ var ev = document.createEvent('Event');
212+ ev.initEvent(eventName, true, true);
213+ ev.pageX = e.pageX;
214+ ev.pageY = e.pageY;
215+ e.target.dispatchEvent(ev);
216+ };
217+
218+ me.click = function (e) {
219+ var target = e.target,
220+ ev;
221+
222+ if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA') {
223+ ev = document.createEvent('MouseEvents');
224+ ev.initMouseEvent('click', true, true, e.view, 1,
225+ target.screenX, target.screenY, target.clientX, target.clientY,
226+ e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
227+ 0, null);
228+
229+ ev._constructed = true;
230+ target.dispatchEvent(ev);
231+ }
232+ };
233+
234+ return me;
235+})();
236+
237+function IScroll (el, options) {
238+ this.wrapper = typeof el == 'string' ? document.querySelector(el) : el;
239+ this.scroller = this.wrapper.children[0];
240+ this.scrollerStyle = this.scroller.style; // cache style for better performance
241+
242+ this.options = {
243+
244+ mouseWheelSpeed: 20,
245+
246+ snapThreshold: 0.334,
247+
248+// INSERT POINT: OPTIONS
249+
250+ startX: 0,
251+ startY: 0,
252+ scrollY: true,
253+ directionLockThreshold: 5,
254+ momentum: true,
255+
256+ bounce: true,
257+ bounceTime: 600,
258+ bounceEasing: '',
259+
260+ preventDefault: true,
261+ preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ },
262+
263+ HWCompositing: true,
264+ useTransition: true,
265+ useTransform: true
266+ };
267+
268+ for ( var i in options ) {
269+ this.options[i] = options[i];
270+ }
271+
272+ // Normalize options
273+ this.translateZ = this.options.HWCompositing && utils.hasPerspective ? ' translateZ(0)' : '';
274+
275+ this.options.useTransition = utils.hasTransition && this.options.useTransition;
276+ this.options.useTransform = utils.hasTransform && this.options.useTransform;
277+
278+ this.options.eventPassthrough = this.options.eventPassthrough === true ? 'vertical' : this.options.eventPassthrough;
279+ this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault;
280+
281+ // If you want eventPassthrough I have to lock one of the axes
282+ this.options.scrollY = this.options.eventPassthrough == 'vertical' ? false : this.options.scrollY;
283+ this.options.scrollX = this.options.eventPassthrough == 'horizontal' ? false : this.options.scrollX;
284+
285+ // With eventPassthrough we also need lockDirection mechanism
286+ this.options.freeScroll = this.options.freeScroll && !this.options.eventPassthrough;
287+ this.options.directionLockThreshold = this.options.eventPassthrough ? 0 : this.options.directionLockThreshold;
288+
289+ this.options.bounceEasing = typeof this.options.bounceEasing == 'string' ? utils.ease[this.options.bounceEasing] || utils.ease.circular : this.options.bounceEasing;
290+
291+ this.options.resizePolling = this.options.resizePolling === undefined ? 60 : this.options.resizePolling;
292+
293+ if ( this.options.tap === true ) {
294+ this.options.tap = 'tap';
295+ }
296+
297+ this.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1;
298+
299+ if ( this.options.infiniteElements ) {
300+ this.options.probeType = 3;
301+ }
302+
303+ if ( this.options.probeType == 3 ) {
304+ this.options.useTransition = false; }
305+
306+// INSERT POINT: NORMALIZATION
307+
308+ // Some defaults
309+ this.x = 0;
310+ this.y = 0;
311+ this.directionX = 0;
312+ this.directionY = 0;
313+ this._events = {};
314+
315+// INSERT POINT: DEFAULTS
316+
317+ this._init();
318+ this.refresh();
319+
320+ this.scrollTo(this.options.startX, this.options.startY);
321+ this.enable();
322+}
323+
324+IScroll.prototype = {
325+ version: '5.1.0',
326+
327+ _init: function () {
328+ this._initEvents();
329+
330+ if ( this.options.mouseWheel ) {
331+ this._initWheel();
332+ }
333+
334+ if ( this.options.snap ) {
335+ this._initSnap();
336+ }
337+
338+ if ( this.options.keyBindings ) {
339+ this._initKeys();
340+ }
341+
342+ if ( this.options.infiniteElements ) {
343+ this._initInfinite();
344+ }
345+
346+// INSERT POINT: _init
347+
348+ },
349+
350+ destroy: function () {
351+ this._initEvents(true);
352+
353+ this._execEvent('destroy');
354+ },
355+
356+ _transitionEnd: function (e) {
357+ if ( e.target != this.scroller || !this.isInTransition ) {
358+ return;
359+ }
360+
361+ this._transitionTime();
362+ if ( !this.resetPosition(this.options.bounceTime) ) {
363+ this.isInTransition = false;
364+ this._execEvent('scrollEnd');
365+ }
366+ },
367+
368+ _start: function (e) {
369+ // React to left mouse button only
370+ if ( utils.eventType[e.type] != 1 ) {
371+ if ( e.button !== 0 ) {
372+ return;
373+ }
374+ }
375+
376+ if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) {
377+ return;
378+ }
379+
380+ if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
381+ e.preventDefault();
382+ }
383+
384+ var point = e.touches ? e.touches[0] : e,
385+ pos;
386+
387+ this.initiated = utils.eventType[e.type];
388+ this.moved = false;
389+ this.distX = 0;
390+ this.distY = 0;
391+ this.directionX = 0;
392+ this.directionY = 0;
393+ this.directionLocked = 0;
394+
395+ this._transitionTime();
396+
397+ this.startTime = utils.getTime();
398+
399+ if ( this.options.useTransition && this.isInTransition ) {
400+ this.isInTransition = false;
401+ pos = this.getComputedPosition();
402+ this._translate(Math.round(pos.x), Math.round(pos.y));
403+ this._execEvent('scrollEnd');
404+ } else if ( !this.options.useTransition && this.isAnimating ) {
405+ this.isAnimating = false;
406+ this._execEvent('scrollEnd');
407+ }
408+
409+ this.startX = this.x;
410+ this.startY = this.y;
411+ this.absStartX = this.x;
412+ this.absStartY = this.y;
413+ this.pointX = point.pageX;
414+ this.pointY = point.pageY;
415+
416+ this._execEvent('beforeScrollStart');
417+ },
418+
419+ _move: function (e) {
420+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
421+ return;
422+ }
423+
424+ if ( this.options.preventDefault ) { // increases performance on Android? TODO: check!
425+ e.preventDefault();
426+ }
427+
428+ var point = e.touches ? e.touches[0] : e,
429+ deltaX = point.pageX - this.pointX,
430+ deltaY = point.pageY - this.pointY,
431+ timestamp = utils.getTime(),
432+ newX, newY,
433+ absDistX, absDistY;
434+
435+ this.pointX = point.pageX;
436+ this.pointY = point.pageY;
437+
438+ this.distX += deltaX;
439+ this.distY += deltaY;
440+ absDistX = Math.abs(this.distX);
441+ absDistY = Math.abs(this.distY);
442+
443+ // We need to move at least 10 pixels for the scrolling to initiate
444+ if ( timestamp - this.endTime > 300 && (absDistX < 10 && absDistY < 10) ) {
445+ return;
446+ }
447+
448+ // If you are scrolling in one direction lock the other
449+ if ( !this.directionLocked && !this.options.freeScroll ) {
450+ if ( absDistX > absDistY + this.options.directionLockThreshold ) {
451+ this.directionLocked = 'h'; // lock horizontally
452+ } else if ( absDistY >= absDistX + this.options.directionLockThreshold ) {
453+ this.directionLocked = 'v'; // lock vertically
454+ } else {
455+ this.directionLocked = 'n'; // no lock
456+ }
457+ }
458+
459+ if ( this.directionLocked == 'h' ) {
460+ if ( this.options.eventPassthrough == 'vertical' ) {
461+ e.preventDefault();
462+ } else if ( this.options.eventPassthrough == 'horizontal' ) {
463+ this.initiated = false;
464+ return;
465+ }
466+
467+ deltaY = 0;
468+ } else if ( this.directionLocked == 'v' ) {
469+ if ( this.options.eventPassthrough == 'horizontal' ) {
470+ e.preventDefault();
471+ } else if ( this.options.eventPassthrough == 'vertical' ) {
472+ this.initiated = false;
473+ return;
474+ }
475+
476+ deltaX = 0;
477+ }
478+
479+ deltaX = this.hasHorizontalScroll ? deltaX : 0;
480+ deltaY = this.hasVerticalScroll ? deltaY : 0;
481+
482+ newX = this.x + deltaX;
483+ newY = this.y + deltaY;
484+
485+ // Slow down if outside of the boundaries
486+ if ( newX > 0 || newX < this.maxScrollX ) {
487+ newX = this.options.bounce ? this.x + deltaX / 3 : newX > 0 ? 0 : this.maxScrollX;
488+ }
489+ if ( newY > 0 || newY < this.maxScrollY ) {
490+ newY = this.options.bounce ? this.y + deltaY / 3 : newY > 0 ? 0 : this.maxScrollY;
491+ }
492+
493+ this.directionX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
494+ this.directionY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
495+
496+ if ( !this.moved ) {
497+ this._execEvent('scrollStart');
498+ }
499+
500+ this.moved = true;
501+
502+ this._translate(newX, newY);
503+
504+/* REPLACE START: _move */
505+ if ( timestamp - this.startTime > 300 ) {
506+ this.startTime = timestamp;
507+ this.startX = this.x;
508+ this.startY = this.y;
509+
510+ if ( this.options.probeType == 1 ) {
511+ this._execEvent('scroll');
512+ }
513+ }
514+
515+ if ( this.options.probeType > 1 ) {
516+ this._execEvent('scroll');
517+ }
518+/* REPLACE END: _move */
519+
520+ },
521+
522+ _end: function (e) {
523+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
524+ return;
525+ }
526+
527+ if ( this.options.preventDefault && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
528+ e.preventDefault();
529+ }
530+
531+ var point = e.changedTouches ? e.changedTouches[0] : e,
532+ momentumX,
533+ momentumY,
534+ duration = utils.getTime() - this.startTime,
535+ newX = Math.round(this.x),
536+ newY = Math.round(this.y),
537+ distanceX = Math.abs(newX - this.startX),
538+ distanceY = Math.abs(newY - this.startY),
539+ time = 0,
540+ easing = '';
541+
542+ this.isInTransition = 0;
543+ this.initiated = 0;
544+ this.endTime = utils.getTime();
545+
546+ // reset if we are outside of the boundaries
547+ if ( this.resetPosition(this.options.bounceTime) ) {
548+ return;
549+ }
550+
551+ this.scrollTo(newX, newY); // ensures that the last position is rounded
552+
553+ // we scrolled less than 10 pixels
554+ if ( !this.moved ) {
555+ if ( this.options.tap ) {
556+ utils.tap(e, this.options.tap);
557+ }
558+
559+ if ( this.options.click ) {
560+ utils.click(e);
561+ }
562+
563+ this._execEvent('scrollCancel');
564+ return;
565+ }
566+
567+ if ( this._events.flick && duration < 200 && distanceX < 100 && distanceY < 100 ) {
568+ this._execEvent('flick');
569+ return;
570+ }
571+
572+ // start momentum animation if needed
573+ if ( this.options.momentum && duration < 300 ) {
574+ momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0) : { destination: newX, duration: 0 };
575+ momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0) : { destination: newY, duration: 0 };
576+ newX = momentumX.destination;
577+ newY = momentumY.destination;
578+ time = Math.max(momentumX.duration, momentumY.duration);
579+ this.isInTransition = 1;
580+ }
581+
582+
583+ if ( this.options.snap ) {
584+ var snap = this._nearestSnap(newX, newY);
585+ this.currentPage = snap;
586+ time = this.options.snapSpeed || Math.max(
587+ Math.max(
588+ Math.min(Math.abs(newX - snap.x), 1000),
589+ Math.min(Math.abs(newY - snap.y), 1000)
590+ ), 300);
591+ newX = snap.x;
592+ newY = snap.y;
593+
594+ this.directionX = 0;
595+ this.directionY = 0;
596+ easing = this.options.bounceEasing;
597+ }
598+
599+// INSERT POINT: _end
600+
601+ if ( newX != this.x || newY != this.y ) {
602+ // change easing function when scroller goes out of the boundaries
603+ if ( newX > 0 || newX < this.maxScrollX || newY > 0 || newY < this.maxScrollY ) {
604+ easing = utils.ease.quadratic;
605+ }
606+
607+ this.scrollTo(newX, newY, time, easing);
608+ return;
609+ }
610+
611+ this._execEvent('scrollEnd');
612+ },
613+
614+ _resize: function () {
615+ var that = this;
616+
617+ clearTimeout(this.resizeTimeout);
618+
619+ this.resizeTimeout = setTimeout(function () {
620+ that.refresh();
621+ }, this.options.resizePolling);
622+ },
623+
624+ resetPosition: function (time) {
625+ var x = this.x,
626+ y = this.y;
627+
628+ time = time || 0;
629+
630+ if ( !this.hasHorizontalScroll || this.x > 0 ) {
631+ x = 0;
632+ } else if ( this.x < this.maxScrollX ) {
633+ x = this.maxScrollX;
634+ }
635+
636+ if ( !this.hasVerticalScroll || this.y > 0 ) {
637+ y = 0;
638+ } else if ( this.y < this.maxScrollY ) {
639+ y = this.maxScrollY;
640+ }
641+
642+ if ( x == this.x && y == this.y ) {
643+ return false;
644+ }
645+
646+ this.scrollTo(x, y, time, this.options.bounceEasing);
647+
648+ return true;
649+ },
650+
651+ disable: function () {
652+ this.enabled = false;
653+ },
654+
655+ enable: function () {
656+ this.enabled = true;
657+ },
658+
659+ refresh: function () {
660+ var rf = this.wrapper.offsetHeight; // Force reflow
661+
662+ this.wrapperWidth = this.wrapper.clientWidth;
663+ this.wrapperHeight = this.wrapper.clientHeight;
664+
665+/* REPLACE START: refresh */
666+ this.scrollerWidth = this.scroller.offsetWidth;
667+ this.scrollerHeight = this.scroller.offsetHeight;
668+
669+ this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
670+
671+ var limit;
672+ if ( this.options.infiniteElements ) {
673+ this.options.infiniteLimit = this.options.infiniteLimit || Math.floor(2147483645 / this.infiniteElementHeight);
674+ limit = -this.options.infiniteLimit * this.infiniteElementHeight + this.wrapperHeight;
675+ }
676+ this.maxScrollY = limit !== undefined ? limit : this.wrapperHeight - this.scrollerHeight;
677+/* REPLACE END: refresh */
678+
679+ this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
680+ this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
681+
682+ if ( !this.hasHorizontalScroll ) {
683+ this.maxScrollX = 0;
684+ this.scrollerWidth = this.wrapperWidth;
685+ }
686+
687+ if ( !this.hasVerticalScroll ) {
688+ this.maxScrollY = 0;
689+ this.scrollerHeight = this.wrapperHeight;
690+ }
691+
692+ this.endTime = 0;
693+ this.directionX = 0;
694+ this.directionY = 0;
695+
696+ this.wrapperOffset = utils.offset(this.wrapper);
697+
698+ this._execEvent('refresh');
699+
700+ this.resetPosition();
701+
702+// INSERT POINT: _refresh
703+
704+ },
705+
706+ on: function (type, fn) {
707+ if ( !this._events[type] ) {
708+ this._events[type] = [];
709+ }
710+
711+ this._events[type].push(fn);
712+ },
713+
714+ _execEvent: function (type) {
715+ if ( !this._events[type] ) {
716+ return;
717+ }
718+
719+ var i = 0,
720+ l = this._events[type].length;
721+
722+ if ( !l ) {
723+ return;
724+ }
725+
726+ for ( ; i < l; i++ ) {
727+ this._events[type][i].apply(this, [].slice.call(arguments, 1));
728+ }
729+ },
730+
731+ scrollBy: function (x, y, time, easing) {
732+ x = this.x + x;
733+ y = this.y + y;
734+ time = time || 0;
735+
736+ this.scrollTo(x, y, time, easing);
737+ },
738+
739+ scrollTo: function (x, y, time, easing) {
740+ easing = easing || utils.ease.circular;
741+
742+ this.isInTransition = this.options.useTransition && time > 0;
743+
744+ if ( !time || (this.options.useTransition && easing.style) ) {
745+ this._transitionTimingFunction(easing.style);
746+ this._transitionTime(time);
747+ this._translate(x, y);
748+ } else {
749+ this._animate(x, y, time, easing.fn);
750+ }
751+ },
752+
753+ scrollToElement: function (el, time, offsetX, offsetY, easing) {
754+ el = el.nodeType ? el : this.scroller.querySelector(el);
755+
756+ if ( !el ) {
757+ return;
758+ }
759+
760+ var pos = utils.offset(el);
761+
762+ pos.left -= this.wrapperOffset.left;
763+ pos.top -= this.wrapperOffset.top;
764+
765+ // if offsetX/Y are true we center the element to the screen
766+ if ( offsetX === true ) {
767+ offsetX = Math.round(el.offsetWidth / 2 - this.wrapper.offsetWidth / 2);
768+ }
769+ if ( offsetY === true ) {
770+ offsetY = Math.round(el.offsetHeight / 2 - this.wrapper.offsetHeight / 2);
771+ }
772+
773+ pos.left -= offsetX || 0;
774+ pos.top -= offsetY || 0;
775+
776+ pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left;
777+ pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top;
778+
779+ time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(this.x-pos.left), Math.abs(this.y-pos.top)) : time;
780+
781+ this.scrollTo(pos.left, pos.top, time, easing);
782+ },
783+
784+ _transitionTime: function (time) {
785+ time = time || 0;
786+
787+ this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';
788+
789+ if ( !time && utils.isBadAndroid ) {
790+ this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
791+ }
792+
793+// INSERT POINT: _transitionTime
794+
795+ },
796+
797+ _transitionTimingFunction: function (easing) {
798+ this.scrollerStyle[utils.style.transitionTimingFunction] = easing;
799+
800+// INSERT POINT: _transitionTimingFunction
801+
802+ },
803+
804+ _translate: function (x, y) {
805+ if ( this.options.useTransform ) {
806+
807+/* REPLACE START: _translate */
808+
809+ this.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.translateZ;
810+
811+/* REPLACE END: _translate */
812+
813+ } else {
814+ x = Math.round(x);
815+ y = Math.round(y);
816+ this.scrollerStyle.left = x + 'px';
817+ this.scrollerStyle.top = y + 'px';
818+ }
819+
820+ this.x = x;
821+ this.y = y;
822+
823+// INSERT POINT: _translate
824+
825+ },
826+
827+ _initEvents: function (remove) {
828+ var eventType = remove ? utils.removeEvent : utils.addEvent,
829+ target = this.options.bindToWrapper ? this.wrapper : window;
830+
831+ eventType(window, 'orientationchange', this);
832+ eventType(window, 'resize', this);
833+
834+ if ( this.options.click ) {
835+ eventType(this.wrapper, 'click', this, true);
836+ }
837+
838+ if ( !this.options.disableMouse ) {
839+ eventType(this.wrapper, 'mousedown', this);
840+ eventType(target, 'mousemove', this);
841+ eventType(target, 'mousecancel', this);
842+ eventType(target, 'mouseup', this);
843+ }
844+
845+ if ( utils.hasPointer && !this.options.disablePointer ) {
846+ eventType(this.wrapper, 'MSPointerDown', this);
847+ eventType(target, 'MSPointerMove', this);
848+ eventType(target, 'MSPointerCancel', this);
849+ eventType(target, 'MSPointerUp', this);
850+ }
851+
852+ if ( utils.hasTouch && !this.options.disableTouch ) {
853+ eventType(this.wrapper, 'touchstart', this);
854+ eventType(target, 'touchmove', this);
855+ eventType(target, 'touchcancel', this);
856+ eventType(target, 'touchend', this);
857+ }
858+
859+ eventType(this.scroller, 'transitionend', this);
860+ eventType(this.scroller, 'webkitTransitionEnd', this);
861+ eventType(this.scroller, 'oTransitionEnd', this);
862+ eventType(this.scroller, 'MSTransitionEnd', this);
863+ },
864+
865+ getComputedPosition: function () {
866+ var matrix = window.getComputedStyle(this.scroller, null),
867+ x, y;
868+
869+ if ( this.options.useTransform ) {
870+ matrix = matrix[utils.style.transform].split(')')[0].split(', ');
871+ x = +(matrix[12] || matrix[4]);
872+ y = +(matrix[13] || matrix[5]);
873+ } else {
874+ x = +matrix.left.replace(/[^-\d.]/g, '');
875+ y = +matrix.top.replace(/[^-\d.]/g, '');
876+ }
877+
878+ return { x: x, y: y };
879+ },
880+
881+ _initWheel: function () {
882+ utils.addEvent(this.wrapper, 'wheel', this);
883+ utils.addEvent(this.wrapper, 'mousewheel', this);
884+ utils.addEvent(this.wrapper, 'DOMMouseScroll', this);
885+
886+ this.on('destroy', function () {
887+ utils.removeEvent(this.wrapper, 'wheel', this);
888+ utils.removeEvent(this.wrapper, 'mousewheel', this);
889+ utils.removeEvent(this.wrapper, 'DOMMouseScroll', this);
890+ });
891+ },
892+
893+ _wheel: function (e) {
894+ if ( !this.enabled ) {
895+ return;
896+ }
897+
898+ e.preventDefault();
899+ e.stopPropagation();
900+
901+ var wheelDeltaX, wheelDeltaY,
902+ newX, newY,
903+ that = this;
904+
905+ if ( this.wheelTimeout === undefined ) {
906+ that._execEvent('scrollStart');
907+ }
908+
909+ // Execute the scrollEnd event after 400ms the wheel stopped scrolling
910+ clearTimeout(this.wheelTimeout);
911+ this.wheelTimeout = setTimeout(function () {
912+ that._execEvent('scrollEnd');
913+ that.wheelTimeout = undefined;
914+ }, 400);
915+
916+ if ( 'deltaX' in e ) {
917+ wheelDeltaX = -e.deltaX;
918+ wheelDeltaY = -e.deltaY;
919+ } else if ( 'wheelDeltaX' in e ) {
920+ wheelDeltaX = e.wheelDeltaX / 120 * this.options.mouseWheelSpeed;
921+ wheelDeltaY = e.wheelDeltaY / 120 * this.options.mouseWheelSpeed;
922+ } else if ( 'wheelDelta' in e ) {
923+ wheelDeltaX = wheelDeltaY = e.wheelDelta / 120 * this.options.mouseWheelSpeed;
924+ } else if ( 'detail' in e ) {
925+ wheelDeltaX = wheelDeltaY = -e.detail / 3 * this.options.mouseWheelSpeed;
926+ } else {
927+ return;
928+ }
929+
930+ wheelDeltaX *= this.options.invertWheelDirection;
931+ wheelDeltaY *= this.options.invertWheelDirection;
932+
933+ if ( !this.hasVerticalScroll ) {
934+ wheelDeltaX = wheelDeltaY;
935+ wheelDeltaY = 0;
936+ }
937+
938+ if ( this.options.snap ) {
939+ newX = this.currentPage.pageX;
940+ newY = this.currentPage.pageY;
941+
942+ if ( wheelDeltaX > 0 ) {
943+ newX--;
944+ } else if ( wheelDeltaX < 0 ) {
945+ newX++;
946+ }
947+
948+ if ( wheelDeltaY > 0 ) {
949+ newY--;
950+ } else if ( wheelDeltaY < 0 ) {
951+ newY++;
952+ }
953+
954+ this.goToPage(newX, newY);
955+
956+ return;
957+ }
958+
959+ newX = this.x + Math.round(this.hasHorizontalScroll ? wheelDeltaX : 0);
960+ newY = this.y + Math.round(this.hasVerticalScroll ? wheelDeltaY : 0);
961+
962+ if ( newX > 0 ) {
963+ newX = 0;
964+ } else if ( newX < this.maxScrollX ) {
965+ newX = this.maxScrollX;
966+ }
967+
968+ if ( newY > 0 ) {
969+ newY = 0;
970+ } else if ( newY < this.maxScrollY ) {
971+ newY = this.maxScrollY;
972+ }
973+
974+ this.scrollTo(newX, newY, 0);
975+
976+ if ( this.options.probeType > 1 ) {
977+ this._execEvent('scroll');
978+ }
979+
980+// INSERT POINT: _wheel
981+ },
982+
983+ _initSnap: function () {
984+ this.currentPage = {};
985+
986+ if ( typeof this.options.snap == 'string' ) {
987+ this.options.snap = this.scroller.querySelectorAll(this.options.snap);
988+ }
989+
990+ this.on('refresh', function () {
991+ var i = 0, l,
992+ m = 0, n,
993+ cx, cy,
994+ x = 0, y,
995+ stepX = this.options.snapStepX || this.wrapperWidth,
996+ stepY = this.options.snapStepY || this.wrapperHeight,
997+ el;
998+
999+ this.pages = [];
1000+
1001+ if ( !this.wrapperWidth || !this.wrapperHeight || !this.scrollerWidth || !this.scrollerHeight ) {
1002+ return;
1003+ }
1004+
1005+ if ( this.options.snap === true ) {
1006+ cx = Math.round( stepX / 2 );
1007+ cy = Math.round( stepY / 2 );
1008+
1009+ while ( x > -this.scrollerWidth ) {
1010+ this.pages[i] = [];
1011+ l = 0;
1012+ y = 0;
1013+
1014+ while ( y > -this.scrollerHeight ) {
1015+ this.pages[i][l] = {
1016+ x: Math.max(x, this.maxScrollX),
1017+ y: Math.max(y, this.maxScrollY),
1018+ width: stepX,
1019+ height: stepY,
1020+ cx: x - cx,
1021+ cy: y - cy
1022+ };
1023+
1024+ y -= stepY;
1025+ l++;
1026+ }
1027+
1028+ x -= stepX;
1029+ i++;
1030+ }
1031+ } else {
1032+ el = this.options.snap;
1033+ l = el.length;
1034+ n = -1;
1035+
1036+ for ( ; i < l; i++ ) {
1037+ if ( i === 0 || el[i].offsetLeft <= el[i-1].offsetLeft ) {
1038+ m = 0;
1039+ n++;
1040+ }
1041+
1042+ if ( !this.pages[m] ) {
1043+ this.pages[m] = [];
1044+ }
1045+
1046+ x = Math.max(-el[i].offsetLeft, this.maxScrollX);
1047+ y = Math.max(-el[i].offsetTop, this.maxScrollY);
1048+ cx = x - Math.round(el[i].offsetWidth / 2);
1049+ cy = y - Math.round(el[i].offsetHeight / 2);
1050+
1051+ this.pages[m][n] = {
1052+ x: x,
1053+ y: y,
1054+ width: el[i].offsetWidth,
1055+ height: el[i].offsetHeight,
1056+ cx: cx,
1057+ cy: cy
1058+ };
1059+
1060+ if ( x > this.maxScrollX ) {
1061+ m++;
1062+ }
1063+ }
1064+ }
1065+
1066+ this.goToPage(this.currentPage.pageX || 0, this.currentPage.pageY || 0, 0);
1067+
1068+ // Update snap threshold if needed
1069+ if ( this.options.snapThreshold % 1 === 0 ) {
1070+ this.snapThresholdX = this.options.snapThreshold;
1071+ this.snapThresholdY = this.options.snapThreshold;
1072+ } else {
1073+ this.snapThresholdX = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width * this.options.snapThreshold);
1074+ this.snapThresholdY = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height * this.options.snapThreshold);
1075+ }
1076+ });
1077+
1078+ this.on('flick', function () {
1079+ var time = this.options.snapSpeed || Math.max(
1080+ Math.max(
1081+ Math.min(Math.abs(this.x - this.startX), 1000),
1082+ Math.min(Math.abs(this.y - this.startY), 1000)
1083+ ), 300);
1084+
1085+ this.goToPage(
1086+ this.currentPage.pageX + this.directionX,
1087+ this.currentPage.pageY + this.directionY,
1088+ time
1089+ );
1090+ });
1091+ },
1092+
1093+ _nearestSnap: function (x, y) {
1094+ if ( !this.pages.length ) {
1095+ return { x: 0, y: 0, pageX: 0, pageY: 0 };
1096+ }
1097+
1098+ var i = 0,
1099+ l = this.pages.length,
1100+ m = 0;
1101+
1102+ // Check if we exceeded the snap threshold
1103+ if ( Math.abs(x - this.absStartX) < this.snapThresholdX &&
1104+ Math.abs(y - this.absStartY) < this.snapThresholdY ) {
1105+ return this.currentPage;
1106+ }
1107+
1108+ if ( x > 0 ) {
1109+ x = 0;
1110+ } else if ( x < this.maxScrollX ) {
1111+ x = this.maxScrollX;
1112+ }
1113+
1114+ if ( y > 0 ) {
1115+ y = 0;
1116+ } else if ( y < this.maxScrollY ) {
1117+ y = this.maxScrollY;
1118+ }
1119+
1120+ for ( ; i < l; i++ ) {
1121+ if ( x >= this.pages[i][0].cx ) {
1122+ x = this.pages[i][0].x;
1123+ break;
1124+ }
1125+ }
1126+
1127+ l = this.pages[i].length;
1128+
1129+ for ( ; m < l; m++ ) {
1130+ if ( y >= this.pages[0][m].cy ) {
1131+ y = this.pages[0][m].y;
1132+ break;
1133+ }
1134+ }
1135+
1136+ if ( i == this.currentPage.pageX ) {
1137+ i += this.directionX;
1138+
1139+ if ( i < 0 ) {
1140+ i = 0;
1141+ } else if ( i >= this.pages.length ) {
1142+ i = this.pages.length - 1;
1143+ }
1144+
1145+ x = this.pages[i][0].x;
1146+ }
1147+
1148+ if ( m == this.currentPage.pageY ) {
1149+ m += this.directionY;
1150+
1151+ if ( m < 0 ) {
1152+ m = 0;
1153+ } else if ( m >= this.pages[0].length ) {
1154+ m = this.pages[0].length - 1;
1155+ }
1156+
1157+ y = this.pages[0][m].y;
1158+ }
1159+
1160+ return {
1161+ x: x,
1162+ y: y,
1163+ pageX: i,
1164+ pageY: m
1165+ };
1166+ },
1167+
1168+ goToPage: function (x, y, time, easing) {
1169+ easing = easing || this.options.bounceEasing;
1170+
1171+ if ( x >= this.pages.length ) {
1172+ x = this.pages.length - 1;
1173+ } else if ( x < 0 ) {
1174+ x = 0;
1175+ }
1176+
1177+ if ( y >= this.pages[x].length ) {
1178+ y = this.pages[x].length - 1;
1179+ } else if ( y < 0 ) {
1180+ y = 0;
1181+ }
1182+
1183+ var posX = this.pages[x][y].x,
1184+ posY = this.pages[x][y].y;
1185+
1186+ time = time === undefined ? this.options.snapSpeed || Math.max(
1187+ Math.max(
1188+ Math.min(Math.abs(posX - this.x), 1000),
1189+ Math.min(Math.abs(posY - this.y), 1000)
1190+ ), 300) : time;
1191+
1192+ this.currentPage = {
1193+ x: posX,
1194+ y: posY,
1195+ pageX: x,
1196+ pageY: y
1197+ };
1198+
1199+ this.scrollTo(posX, posY, time, easing);
1200+ },
1201+
1202+ next: function (time, easing) {
1203+ var x = this.currentPage.pageX,
1204+ y = this.currentPage.pageY;
1205+
1206+ x++;
1207+
1208+ if ( x >= this.pages.length && this.hasVerticalScroll ) {
1209+ x = 0;
1210+ y++;
1211+ }
1212+
1213+ this.goToPage(x, y, time, easing);
1214+ },
1215+
1216+ prev: function (time, easing) {
1217+ var x = this.currentPage.pageX,
1218+ y = this.currentPage.pageY;
1219+
1220+ x--;
1221+
1222+ if ( x < 0 && this.hasVerticalScroll ) {
1223+ x = 0;
1224+ y--;
1225+ }
1226+
1227+ this.goToPage(x, y, time, easing);
1228+ },
1229+
1230+ _initKeys: function (e) {
1231+ // default key bindings
1232+ var keys = {
1233+ pageUp: 33,
1234+ pageDown: 34,
1235+ end: 35,
1236+ home: 36,
1237+ left: 37,
1238+ up: 38,
1239+ right: 39,
1240+ down: 40
1241+ };
1242+ var i;
1243+
1244+ // if you give me characters I give you keycode
1245+ if ( typeof this.options.keyBindings == 'object' ) {
1246+ for ( i in this.options.keyBindings ) {
1247+ if ( typeof this.options.keyBindings[i] == 'string' ) {
1248+ this.options.keyBindings[i] = this.options.keyBindings[i].toUpperCase().charCodeAt(0);
1249+ }
1250+ }
1251+ } else {
1252+ this.options.keyBindings = {};
1253+ }
1254+
1255+ for ( i in keys ) {
1256+ this.options.keyBindings[i] = this.options.keyBindings[i] || keys[i];
1257+ }
1258+
1259+ utils.addEvent(window, 'keydown', this);
1260+
1261+ this.on('destroy', function () {
1262+ utils.removeEvent(window, 'keydown', this);
1263+ });
1264+ },
1265+
1266+ _key: function (e) {
1267+ if ( !this.enabled ) {
1268+ return;
1269+ }
1270+
1271+ var snap = this.options.snap, // we are using this alot, better to cache it
1272+ newX = snap ? this.currentPage.pageX : this.x,
1273+ newY = snap ? this.currentPage.pageY : this.y,
1274+ now = utils.getTime(),
1275+ prevTime = this.keyTime || 0,
1276+ acceleration = 0.250,
1277+ pos;
1278+
1279+ if ( this.options.useTransition && this.isInTransition ) {
1280+ pos = this.getComputedPosition();
1281+
1282+ this._translate(Math.round(pos.x), Math.round(pos.y));
1283+ this.isInTransition = false;
1284+ }
1285+
1286+ this.keyAcceleration = now - prevTime < 200 ? Math.min(this.keyAcceleration + acceleration, 50) : 0;
1287+
1288+ switch ( e.keyCode ) {
1289+ case this.options.keyBindings.pageUp:
1290+ if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
1291+ newX += snap ? 1 : this.wrapperWidth;
1292+ } else {
1293+ newY += snap ? 1 : this.wrapperHeight;
1294+ }
1295+ break;
1296+ case this.options.keyBindings.pageDown:
1297+ if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
1298+ newX -= snap ? 1 : this.wrapperWidth;
1299+ } else {
1300+ newY -= snap ? 1 : this.wrapperHeight;
1301+ }
1302+ break;
1303+ case this.options.keyBindings.end:
1304+ newX = snap ? this.pages.length-1 : this.maxScrollX;
1305+ newY = snap ? this.pages[0].length-1 : this.maxScrollY;
1306+ break;
1307+ case this.options.keyBindings.home:
1308+ newX = 0;
1309+ newY = 0;
1310+ break;
1311+ case this.options.keyBindings.left:
1312+ newX += snap ? -1 : 5 + this.keyAcceleration>>0;
1313+ break;
1314+ case this.options.keyBindings.up:
1315+ newY += snap ? 1 : 5 + this.keyAcceleration>>0;
1316+ break;
1317+ case this.options.keyBindings.right:
1318+ newX -= snap ? -1 : 5 + this.keyAcceleration>>0;
1319+ break;
1320+ case this.options.keyBindings.down:
1321+ newY -= snap ? 1 : 5 + this.keyAcceleration>>0;
1322+ break;
1323+ default:
1324+ return;
1325+ }
1326+
1327+ if ( snap ) {
1328+ this.goToPage(newX, newY);
1329+ return;
1330+ }
1331+
1332+ if ( newX > 0 ) {
1333+ newX = 0;
1334+ this.keyAcceleration = 0;
1335+ } else if ( newX < this.maxScrollX ) {
1336+ newX = this.maxScrollX;
1337+ this.keyAcceleration = 0;
1338+ }
1339+
1340+ if ( newY > 0 ) {
1341+ newY = 0;
1342+ this.keyAcceleration = 0;
1343+ } else if ( newY < this.maxScrollY ) {
1344+ newY = this.maxScrollY;
1345+ this.keyAcceleration = 0;
1346+ }
1347+
1348+ this.scrollTo(newX, newY, 0);
1349+
1350+ this.keyTime = now;
1351+ },
1352+
1353+ _animate: function (destX, destY, duration, easingFn) {
1354+ var that = this,
1355+ startX = this.x,
1356+ startY = this.y,
1357+ startTime = utils.getTime(),
1358+ destTime = startTime + duration;
1359+
1360+ function step () {
1361+ var now = utils.getTime(),
1362+ newX, newY,
1363+ easing;
1364+
1365+ if ( now >= destTime ) {
1366+ that.isAnimating = false;
1367+ that._translate(destX, destY);
1368+
1369+ if ( !that.resetPosition(that.options.bounceTime) ) {
1370+ that._execEvent('scrollEnd');
1371+ }
1372+
1373+ return;
1374+ }
1375+
1376+ now = ( now - startTime ) / duration;
1377+ easing = easingFn(now);
1378+ newX = ( destX - startX ) * easing + startX;
1379+ newY = ( destY - startY ) * easing + startY;
1380+ that._translate(newX, newY);
1381+
1382+ if ( that.isAnimating ) {
1383+ rAF(step);
1384+ }
1385+
1386+ if ( that.options.probeType == 3 ) {
1387+ that._execEvent('scroll');
1388+ }
1389+ }
1390+
1391+ this.isAnimating = true;
1392+ step();
1393+ },
1394+
1395+ _initInfinite: function () {
1396+ var el = this.options.infiniteElements;
1397+
1398+ this.infiniteElements = typeof el == 'string' ? document.querySelectorAll(el) : el;
1399+ this.infiniteLength = this.infiniteElements.length;
1400+ this.infiniteMaster = this.infiniteElements[0];
1401+ this.infiniteElementHeight = this.infiniteMaster.offsetHeight;
1402+ this.infiniteHeight = this.infiniteLength * this.infiniteElementHeight;
1403+
1404+ this.options.cacheSize = this.options.cacheSize || 1000;
1405+ this.infiniteCacheBuffer = Math.round(this.options.cacheSize / 4);
1406+
1407+ //this.infiniteCache = {};
1408+ this.options.dataset.call(this, 0, this.options.cacheSize);
1409+
1410+ this.on('refresh', function () {
1411+ var elementsPerPage = Math.ceil(this.wrapperHeight / this.infiniteElementHeight);
1412+ this.infiniteUpperBufferSize = Math.floor((this.infiniteLength - elementsPerPage) / 2);
1413+ this.reorderInfinite();
1414+ });
1415+
1416+ this.on('scroll', this.reorderInfinite);
1417+ },
1418+
1419+ // TO-DO: clean up the mess
1420+ reorderInfinite: function () {
1421+ var center = -this.y + this.wrapperHeight / 2;
1422+
1423+ var minorPhase = Math.max(Math.floor(-this.y / this.infiniteElementHeight) - this.infiniteUpperBufferSize, 0),
1424+ majorPhase = Math.floor(minorPhase / this.infiniteLength),
1425+ phase = minorPhase - majorPhase * this.infiniteLength;
1426+
1427+ var top = 0;
1428+ var i = 0;
1429+ var update = [];
1430+
1431+ //var cachePhase = Math.floor((minorPhase + this.infiniteLength / 2) / this.infiniteCacheBuffer);
1432+ var cachePhase = Math.floor(minorPhase / this.infiniteCacheBuffer);
1433+
1434+ while ( i < this.infiniteLength ) {
1435+ top = i * this.infiniteElementHeight + majorPhase * this.infiniteHeight;
1436+
1437+ if ( phase > i ) {
1438+ top += this.infiniteElementHeight * this.infiniteLength;
1439+ }
1440+
1441+ if ( this.infiniteElements[i]._top !== top ) {
1442+ this.infiniteElements[i]._phase = top / this.infiniteElementHeight;
1443+
1444+ if ( this.infiniteElements[i]._phase < this.options.infiniteLimit ) {
1445+ this.infiniteElements[i]._top = top;
1446+ this.infiniteElements[i].style.top = top + 'px';
1447+ update.push(this.infiniteElements[i]);
1448+ }
1449+ }
1450+
1451+ i++;
1452+ }
1453+
1454+ if ( this.cachePhase != cachePhase && (cachePhase === 0 || minorPhase - this.infiniteCacheBuffer > 0) ) {
1455+ this.options.dataset.call(this, Math.max(cachePhase * this.infiniteCacheBuffer - this.infiniteCacheBuffer, 0), this.options.cacheSize);
1456+ }
1457+
1458+ this.cachePhase = cachePhase;
1459+
1460+ this.updateContent(update);
1461+ },
1462+
1463+ updateContent: function (els) {
1464+ if ( this.infiniteCache === undefined ) {
1465+ return;
1466+ }
1467+
1468+ for ( var i = 0, l = els.length; i < l; i++ ) {
1469+ this.options.dataFiller.call(this, els[i], this.infiniteCache[els[i]._phase]);
1470+ }
1471+ },
1472+
1473+ updateCache: function (start, data) {
1474+ var firstRun = this.infiniteCache === undefined;
1475+
1476+ this.infiniteCache = {};
1477+
1478+ for ( var i = 0, l = data.length; i < l; i++ ) {
1479+ this.infiniteCache[start++] = data[i];
1480+ }
1481+
1482+ if ( firstRun ) {
1483+ this.updateContent(this.infiniteElements);
1484+ }
1485+
1486+ },
1487+
1488+
1489+ handleEvent: function (e) {
1490+ switch ( e.type ) {
1491+ case 'touchstart':
1492+ case 'MSPointerDown':
1493+ case 'mousedown':
1494+ this._start(e);
1495+ break;
1496+ case 'touchmove':
1497+ case 'MSPointerMove':
1498+ case 'mousemove':
1499+ this._move(e);
1500+ break;
1501+ case 'touchend':
1502+ case 'MSPointerUp':
1503+ case 'mouseup':
1504+ case 'touchcancel':
1505+ case 'MSPointerCancel':
1506+ case 'mousecancel':
1507+ this._end(e);
1508+ break;
1509+ case 'orientationchange':
1510+ case 'resize':
1511+ this._resize();
1512+ break;
1513+ case 'transitionend':
1514+ case 'webkitTransitionEnd':
1515+ case 'oTransitionEnd':
1516+ case 'MSTransitionEnd':
1517+ this._transitionEnd(e);
1518+ break;
1519+ case 'wheel':
1520+ case 'DOMMouseScroll':
1521+ case 'mousewheel':
1522+ this._wheel(e);
1523+ break;
1524+ case 'keydown':
1525+ this._key(e);
1526+ break;
1527+ case 'click':
1528+ if ( !e._constructed ) {
1529+ e.preventDefault();
1530+ e.stopPropagation();
1531+ }
1532+ break;
1533+ }
1534+ }
1535+};
1536+IScroll.utils = utils;
1537+
1538+if ( typeof module != 'undefined' && module.exports ) {
1539+ module.exports = IScroll;
1540+} else {
1541+ window.IScroll = IScroll;
1542+}
1543+
1544+})(window, document, Math);
No newline at the end of the file
modified build/iscroll-lite.js +6 −6
@@ -1,4 +1,4 @@
1-/*! iScroll v5.0.9 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
1+/*! iScroll v5.1.0 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
22 (function (window, document, Math) {
33 var rAF = window.requestAnimationFrame ||
44 window.webkitRequestAnimationFrame ||
@@ -84,7 +84,7 @@
8484 });
8585
8686 // This should find all Android browsers lower than build 535.19 (both stock browser and webview)
87- me.isBadAndroid = /Android/.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
87+ me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
8888
8989 me.extend(me.style = {}, {
9090 transform: _transform,
@@ -309,7 +309,7 @@
309309 }
310310
311311 IScroll.prototype = {
312- version: '5.0.9',
312+ version: '5.1.0',
313313
314314 _init: function () {
315315 this._initEvents();
@@ -615,11 +615,11 @@
615615 this.scrollerWidth = this.scroller.offsetWidth;
616616 this.scrollerHeight = this.scroller.offsetHeight;
617617
618-/* REPLACE END: refresh */
619-
620618 this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
621619 this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
622620
621+/* REPLACE END: refresh */
622+
623623 this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
624624 this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
625625
@@ -668,7 +668,7 @@
668668 }
669669
670670 for ( ; i < l; i++ ) {
671- this._events[type][i].call(this);
671+ this._events[type][i].apply(this, [].slice.call(arguments, 1));
672672 }
673673 },
674674
modified build/iscroll-probe.js +9 −9
@@ -1,4 +1,4 @@
1-/*! iScroll v5.0.9 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
1+/*! iScroll v5.1.0 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
22 (function (window, document, Math) {
33 var rAF = window.requestAnimationFrame ||
44 window.webkitRequestAnimationFrame ||
@@ -84,7 +84,7 @@
8484 });
8585
8686 // This should find all Android browsers lower than build 535.19 (both stock browser and webview)
87- me.isBadAndroid = /Android/.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
87+ me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
8888
8989 me.extend(me.style = {}, {
9090 transform: _transform,
@@ -241,7 +241,7 @@
241241
242242 this.options = {
243243
244- resizeIndicator: true,
244+ resizeScrollbars: true,
245245
246246 mouseWheelSpeed: 20,
247247
@@ -324,7 +324,7 @@
324324 }
325325
326326 IScroll.prototype = {
327- version: '5.0.9',
327+ version: '5.1.0',
328328
329329 _init: function () {
330330 this._initEvents();
@@ -669,11 +669,11 @@
669669 this.scrollerWidth = this.scroller.offsetWidth;
670670 this.scrollerHeight = this.scroller.offsetHeight;
671671
672-/* REPLACE END: refresh */
673-
674672 this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
675673 this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
676674
675+/* REPLACE END: refresh */
676+
677677 this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
678678 this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
679679
@@ -722,7 +722,7 @@
722722 }
723723
724724 for ( ; i < l; i++ ) {
725- this._events[type][i].call(this);
725+ this._events[type][i].apply(this, [].slice.call(arguments, 1));
726726 }
727727 },
728728
@@ -919,7 +919,7 @@
919919 interactive: interactive,
920920 defaultScrollbars: true,
921921 customStyle: customStyle,
922- resize: this.options.resizeIndicator,
922+ resize: this.options.resizeScrollbars,
923923 shrink: this.options.shrinkScrollbars,
924924 fade: this.options.fadeScrollbars,
925925 listenX: false
@@ -936,7 +936,7 @@
936936 interactive: interactive,
937937 defaultScrollbars: true,
938938 customStyle: customStyle,
939- resize: this.options.resizeIndicator,
939+ resize: this.options.resizeScrollbars,
940940 shrink: this.options.shrinkScrollbars,
941941 fade: this.options.fadeScrollbars,
942942 listenY: false
modified build/iscroll-zoom.js +10 −10
@@ -1,4 +1,4 @@
1-/*! iScroll v5.0.9 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
1+/*! iScroll v5.1.0 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
22 (function (window, document, Math) {
33 var rAF = window.requestAnimationFrame ||
44 window.webkitRequestAnimationFrame ||
@@ -84,7 +84,7 @@
8484 });
8585
8686 // This should find all Android browsers lower than build 535.19 (both stock browser and webview)
87- me.isBadAndroid = /Android/.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
87+ me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
8888
8989 me.extend(me.style = {}, {
9090 transform: _transform,
@@ -244,7 +244,7 @@
244244 zoomMin: 1,
245245 zoomMax: 4, startZoom: 1,
246246
247- resizeIndicator: true,
247+ resizeScrollbars: true,
248248
249249 mouseWheelSpeed: 20,
250250
@@ -326,7 +326,7 @@
326326 }
327327
328328 IScroll.prototype = {
329- version: '5.0.9',
329+ version: '5.1.0',
330330
331331 _init: function () {
332332 this._initEvents();
@@ -667,10 +667,10 @@
667667 /* REPLACE START: refresh */
668668 this.scrollerWidth = Math.round(this.scroller.offsetWidth * this.scale);
669669 this.scrollerHeight = Math.round(this.scroller.offsetHeight * this.scale);
670-/* REPLACE END: refresh */
671670
672- this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
673- this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
671+ this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
672+ this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
673+/* REPLACE END: refresh */
674674
675675 this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
676676 this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
@@ -720,7 +720,7 @@
720720 }
721721
722722 for ( ; i < l; i++ ) {
723- this._events[type][i].call(this);
723+ this._events[type][i].apply(this, [].slice.call(arguments, 1));
724724 }
725725 },
726726
@@ -913,7 +913,7 @@
913913 interactive: interactive,
914914 defaultScrollbars: true,
915915 customStyle: customStyle,
916- resize: this.options.resizeIndicator,
916+ resize: this.options.resizeScrollbars,
917917 shrink: this.options.shrinkScrollbars,
918918 fade: this.options.fadeScrollbars,
919919 listenX: false
@@ -930,7 +930,7 @@
930930 interactive: interactive,
931931 defaultScrollbars: true,
932932 customStyle: customStyle,
933- resize: this.options.resizeIndicator,
933+ resize: this.options.resizeScrollbars,
934934 shrink: this.options.shrinkScrollbars,
935935 fade: this.options.fadeScrollbars,
936936 listenY: false
modified build/iscroll.js +9 −9
@@ -1,4 +1,4 @@
1-/*! iScroll v5.0.9 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
1+/*! iScroll v5.1.0 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
22 (function (window, document, Math) {
33 var rAF = window.requestAnimationFrame ||
44 window.webkitRequestAnimationFrame ||
@@ -84,7 +84,7 @@
8484 });
8585
8686 // This should find all Android browsers lower than build 535.19 (both stock browser and webview)
87- me.isBadAndroid = /Android/.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
87+ me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
8888
8989 me.extend(me.style = {}, {
9090 transform: _transform,
@@ -241,7 +241,7 @@
241241
242242 this.options = {
243243
244- resizeIndicator: true,
244+ resizeScrollbars: true,
245245
246246 mouseWheelSpeed: 20,
247247
@@ -321,7 +321,7 @@
321321 }
322322
323323 IScroll.prototype = {
324- version: '5.0.9',
324+ version: '5.1.0',
325325
326326 _init: function () {
327327 this._initEvents();
@@ -660,11 +660,11 @@
660660 this.scrollerWidth = this.scroller.offsetWidth;
661661 this.scrollerHeight = this.scroller.offsetHeight;
662662
663-/* REPLACE END: refresh */
664-
665663 this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
666664 this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
667665
666+/* REPLACE END: refresh */
667+
668668 this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
669669 this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
670670
@@ -713,7 +713,7 @@
713713 }
714714
715715 for ( ; i < l; i++ ) {
716- this._events[type][i].call(this);
716+ this._events[type][i].apply(this, [].slice.call(arguments, 1));
717717 }
718718 },
719719
@@ -910,7 +910,7 @@
910910 interactive: interactive,
911911 defaultScrollbars: true,
912912 customStyle: customStyle,
913- resize: this.options.resizeIndicator,
913+ resize: this.options.resizeScrollbars,
914914 shrink: this.options.shrinkScrollbars,
915915 fade: this.options.fadeScrollbars,
916916 listenX: false
@@ -927,7 +927,7 @@
927927 interactive: interactive,
928928 defaultScrollbars: true,
929929 customStyle: customStyle,
930- resize: this.options.resizeIndicator,
930+ resize: this.options.resizeScrollbars,
931931 shrink: this.options.shrinkScrollbars,
932932 fade: this.options.fadeScrollbars,
933933 listenY: false
added demos/infinite/dataset.php +14 −0
@@ -0,0 +1,14 @@
1+<?php
2+//header('Cache-Control: no-cache, must-revalidate');
3+//header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
4+header('Content-type: application/json');
5+
6+$start = isset($_GET['start']) ? (int)$_GET['start'] : 0;
7+$count = isset($_GET['count']) ? min((int)$_GET['count'], 2000) : 100;
8+
9+$data = array();
10+for ( $i = $start; $i < $start+$count; $i++ ) {
11+ $data[] = $i;
12+}
13+
14+echo json_encode($data);
added demos/infinite/index.html +248 −0
@@ -0,0 +1,248 @@
1+<!DOCTYPE html>
2+<html>
3+<head>
4+<meta charset="utf-8">
5+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
6+
7+<title>iScroll demo: infinite scrolling</title>
8+
9+<script type="text/javascript" src="../../build/iscroll-infinite.js"></script>
10+
11+<script type="text/javascript">
12+/******************************************************************************
13+ *
14+ * For the sake of keeping the script dependecy free I'm including a custom
15+ * AJAX function. You should probably use a third party plugin
16+ *
17+ */
18+function ajax (url, parms) {
19+ parms = parms || {};
20+ var req = new XMLHttpRequest(),
21+ post = parms.post || null,
22+ callback = parms.callback || null,
23+ timeout = parms.timeout || null;
24+
25+ req.onreadystatechange = function () {
26+ if ( req.readyState != 4 ) return;
27+
28+ // Error
29+ if ( req.status != 200 && req.status != 304 ) {
30+ if ( callback ) callback(false);
31+ return;
32+ }
33+
34+ if ( callback ) callback(req.responseText);
35+ };
36+
37+ if ( post ) {
38+ req.open('POST', url, true);
39+ req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
40+ } else {
41+ req.open('GET', url, true);
42+ }
43+
44+ req.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
45+
46+ req.send(post);
47+
48+ if ( timeout ) {
49+ setTimeout(function () {
50+ req.onreadystatechange = function () {};
51+ req.abort();
52+ if ( callback ) callback(false);
53+ }, timeout);
54+ }
55+}
56+/*
57+ *****************************************************************************/
58+
59+var myScroll;
60+
61+function loaded () {
62+ myScroll = new IScroll('#wrapper', {
63+ mouseWheel: true,
64+ infiniteElements: '#scroller .row',
65+ //infiniteLimit: 2000,
66+ dataset: requestData,
67+ dataFiller: updateContent,
68+ cacheSize: 1000
69+ });
70+ console.log(myScroll.options)
71+}
72+
73+function requestData (start, count) {
74+ ajax('dataset.php?start=' + +start + '&count=' + +count, {
75+ callback: function (data) {
76+ data = JSON.parse(data);
77+ myScroll.updateCache(start, data);
78+ }
79+ });
80+}
81+
82+function updateContent (el, data) {
83+ el.innerHTML = data;
84+}
85+
86+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
87+
88+</script>
89+
90+<style type="text/css">
91+* {
92+ -webkit-box-sizing: border-box;
93+ -moz-box-sizing: border-box;
94+ box-sizing: border-box;
95+}
96+
97+html {
98+ -ms-touch-action: none;
99+}
100+
101+body,ul,li {
102+ padding: 0;
103+ margin: 0;
104+ border: 0;
105+}
106+
107+body {
108+ font-size: 12px;
109+ font-family: ubuntu, helvetica, arial;
110+ overflow: hidden; /* this is important to prevent the whole page to bounce */
111+}
112+
113+#header {
114+ position: absolute;
115+ z-index: 2;
116+ top: 0;
117+ left: 0;
118+ width: 100%;
119+ height: 45px;
120+ line-height: 45px;
121+ background: #CD235C;
122+ padding: 0;
123+ color: #eee;
124+ font-size: 20px;
125+ text-align: center;
126+ font-weight: bold;
127+}
128+
129+#footer {
130+ position: absolute;
131+ z-index: 2;
132+ bottom: 0;
133+ left: 0;
134+ width: 100%;
135+ height: 48px;
136+ background: #444;
137+ padding: 0;
138+ border-top: 1px solid #444;
139+}
140+
141+#wrapper {
142+ position: absolute;
143+ z-index: 1;
144+ top: 45px;
145+ bottom: 48px;
146+ left: 0;
147+ width: 100%;
148+ background: #ccc;
149+ overflow: hidden;
150+}
151+
152+#scroller {
153+ position: absolute;
154+ z-index: 1;
155+ -webkit-tap-highlight-color: rgba(0,0,0,0);
156+ width: 100%;
157+ -webkit-transform: translateZ(0);
158+ -moz-transform: translateZ(0);
159+ -ms-transform: translateZ(0);
160+ -o-transform: translateZ(0);
161+ transform: translateZ(0);
162+ -webkit-touch-callout: none;
163+ -webkit-user-select: none;
164+ -moz-user-select: none;
165+ -ms-user-select: none;
166+ user-select: none;
167+ -webkit-text-size-adjust: none;
168+ -moz-text-size-adjust: none;
169+ -ms-text-size-adjust: none;
170+ -o-text-size-adjust: none;
171+ text-size-adjust: none;
172+}
173+
174+#scroller ul {
175+ list-style: none;
176+ padding: 0;
177+ margin: 0;
178+ width: 100%;
179+ text-align: left;
180+ position: relative;
181+}
182+
183+#scroller li {
184+ position: absolute;
185+ width: 100%;
186+ top: 0;
187+ left: 0;
188+ -webkit-transform: translateZ(0);
189+ -moz-transform: translateZ(0);
190+ -ms-transform: translateZ(0);
191+ -o-transform: translateZ(0);
192+ transform: translateZ(0);
193+ padding: 0 10px;
194+ height: 40px;
195+ line-height: 40px;
196+ border-bottom: 1px solid #ccc;
197+ border-top: 1px solid #fff;
198+ background-color: #fafafa;
199+ font-size: 16px;
200+}
201+
202+</style>
203+</head>
204+<body onload="loaded()">
205+<div id="header">iScroll</div>
206+
207+<div id="wrapper">
208+ <div id="scroller">
209+ <ul>
210+ <li class="row">Row 1</li>
211+ <li class="row">Row 2</li>
212+ <li class="row">Row 3</li>
213+ <li class="row">Row 4</li>
214+ <li class="row">Row 5</li>
215+ <li class="row">Row 6</li>
216+ <li class="row">Row 7</li>
217+ <li class="row">Row 8</li>
218+ <li class="row">Row 9</li>
219+ <li class="row">Row 10</li>
220+ <li class="row">Row 11</li>
221+ <li class="row">Row 12</li>
222+ <li class="row">Row 13</li>
223+ <li class="row">Row 14</li>
224+ <li class="row">Row 15</li>
225+
226+ <li class="row">Row 16</li>
227+ <li class="row">Row 17</li>
228+ <li class="row">Row 18</li>
229+ <li class="row">Row 19</li>
230+ <li class="row">Row 20</li>
231+ <li class="row">Row 21</li>
232+ <li class="row">Row 22</li>
233+ <li class="row">Row 23</li>
234+ <li class="row">Row 24</li>
235+ <li class="row">Row 25</li>
236+ <li class="row">Row 26</li>
237+ <li class="row">Row 27</li>
238+ <li class="row">Row 28</li>
239+ <li class="row">Row 29</li>
240+ <li class="row">Row 30</li>
241+ </ul>
242+ </div>
243+</div>
244+
245+<div id="footer"></div>
246+
247+</body>
248+</html>
No newline at the end of the file
added dist/iscroll-infinite-min.js +2 −0
@@ -0,0 +1,2 @@
1+/*! iScroll v5.1.0 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
2+!function(t,i,e){function s(t,e){this.wrapper="string"==typeof t?i.querySelector(t):t,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={mouseWheelSpeed:20,snapThreshold:.334,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};for(var s in e)this.options[s]=e[s];this.translateZ=this.options.HWCompositing&&o.hasPerspective?" translateZ(0)":"",this.options.useTransition=o.hasTransition&&this.options.useTransition,this.options.useTransform=o.hasTransform&&this.options.useTransform,this.options.eventPassthrough=this.options.eventPassthrough===!0?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"==this.options.eventPassthrough?!1:this.options.scrollY,this.options.scrollX="horizontal"==this.options.eventPassthrough?!1: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?o.ease[this.options.bounceEasing]||o.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,this.options.tap===!0&&(this.options.tap="tap"),this.options.invertWheelDirection=this.options.invertWheelDirection?-1:1,this.options.infiniteElements&&(this.options.probeType=3),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()}var n=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(i){t.setTimeout(i,1e3/60)},o=function(){function s(t){return h===!1?!1:""===h?t:h+t.charAt(0).toUpperCase()+t.substr(1)}var n={},o=i.createElement("div").style,h=function(){for(var t,i=["t","webkitT","MozT","msT","OT"],e=0,s=i.length;s>e;e++)if(t=i[e]+"ransform",t in o)return i[e].substr(0,i[e].length-1);return!1}();n.getTime=Date.now||function(){return(new Date).getTime()},n.extend=function(t,i){for(var e in i)t[e]=i[e]},n.addEvent=function(t,i,e,s){t.addEventListener(i,e,!!s)},n.removeEvent=function(t,i,e,s){t.removeEventListener(i,e,!!s)},n.momentum=function(t,i,s,n,o){var h,r,a=t-i,l=e.abs(a)/s,c=6e-4;return h=t+l*l/(2*c)*(0>a?-1:1),r=l/c,n>h?(h=o?n-o/2.5*(l/8):n,a=e.abs(h-t),r=a/l):h>0&&(h=o?o/2.5*(l/8):0,a=e.abs(t)+h,r=a/l),{destination:e.round(h),duration:r}};var r=s("transform");return n.extend(n,{hasTransform:r!==!1,hasPerspective:s("perspective")in o,hasTouch:"ontouchstart"in t,hasPointer:navigator.msPointerEnabled,hasTransition:s("transition")in o}),n.isBadAndroid=/Android /.test(t.navigator.appVersion)&&!/Chrome\/\d/.test(t.navigator.appVersion),n.extend(n.style={},{transform:r,transitionTimingFunction:s("transitionTimingFunction"),transitionDuration:s("transitionDuration"),transitionDelay:s("transitionDelay"),transformOrigin:s("transformOrigin")}),n.hasClass=function(t,i){var e=new RegExp("(^|\\s)"+i+"(\\s|$)");return e.test(t.className)},n.addClass=function(t,i){if(!n.hasClass(t,i)){var e=t.className.split(" ");e.push(i),t.className=e.join(" ")}},n.removeClass=function(t,i){if(n.hasClass(t,i)){var e=new RegExp("(^|\\s)"+i+"(\\s|$)","g");t.className=t.className.replace(e," ")}},n.offset=function(t){for(var i=-t.offsetLeft,e=-t.offsetTop;t=t.offsetParent;)i-=t.offsetLeft,e-=t.offsetTop;return{left:i,top:e}},n.preventDefaultException=function(t,i){for(var e in i)if(i[e].test(t[e]))return!0;return!1},n.extend(n.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),n.extend(n.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 e.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){var i=4;return(t-=1)*t*((i+1)*t+i)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){var i=.22,s=.4;return 0===t?0:1==t?1:s*e.pow(2,-10*t)*e.sin(2*(t-i/4)*e.PI/i)+1}}}),n.tap=function(t,e){var s=i.createEvent("Event");s.initEvent(e,!0,!0),s.pageX=t.pageX,s.pageY=t.pageY,t.target.dispatchEvent(s)},n.click=function(t){var e,s=t.target;"SELECT"!=s.tagName&&"INPUT"!=s.tagName&&"TEXTAREA"!=s.tagName&&(e=i.createEvent("MouseEvents"),e.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),e._constructed=!0,s.dispatchEvent(e))},n}();s.prototype={version:"5.1.0",_init:function(){this._initEvents(),this.options.mouseWheel&&this._initWheel(),this.options.snap&&this._initSnap(),this.options.keyBindings&&this._initKeys(),this.options.infiniteElements&&this._initInfinite()},destroy:function(){this._initEvents(!0),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!=o.eventType[t.type]&&0!==t.button||!this.enabled||this.initiated&&o.eventType[t.type]!==this.initiated)){!this.options.preventDefault||o.isBadAndroid||o.preventDefaultException(t.target,this.options.preventDefaultException)||t.preventDefault();var i,s=t.touches?t.touches[0]:t;this.initiated=o.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this._transitionTime(),this.startTime=o.getTime(),this.options.useTransition&&this.isInTransition?(this.isInTransition=!1,i=this.getComputedPosition(),this._translate(e.round(i.x),e.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&&o.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,s,n,h,r=t.touches?t.touches[0]:t,a=r.pageX-this.pointX,l=r.pageY-this.pointY,c=o.getTime();if(this.pointX=r.pageX,this.pointY=r.pageY,this.distX+=a,this.distY+=l,n=e.abs(this.distX),h=e.abs(this.distY),!(c-this.endTime>300&&10>n&&10>h)){if(this.directionLocked||this.options.freeScroll||(this.directionLocked=n>h+this.options.directionLockThreshold?"h":h>=n+this.options.directionLockThreshold?"v":"n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return this.initiated=!1,void 0;l=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return this.initiated=!1,void 0;a=0}a=this.hasHorizontalScroll?a:0,l=this.hasVerticalScroll?l:0,i=this.x+a,s=this.y+l,(i>0||i<this.maxScrollX)&&(i=this.options.bounce?this.x+a/3:i>0?0:this.maxScrollX),(s>0||s<this.maxScrollY)&&(s=this.options.bounce?this.y+l/3:s>0?0:this.maxScrollY),this.directionX=a>0?-1:0>a?1:0,this.directionY=l>0?-1:0>l?1:0,this.moved||this._execEvent("scrollStart"),this.moved=!0,this._translate(i,s),c-this.startTime>300&&(this.startTime=c,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&&o.eventType[t.type]===this.initiated){this.options.preventDefault&&!o.preventDefaultException(t.target,this.options.preventDefaultException)&&t.preventDefault();var i,s,n=(t.changedTouches?t.changedTouches[0]:t,o.getTime()-this.startTime),h=e.round(this.x),r=e.round(this.y),a=e.abs(h-this.startX),l=e.abs(r-this.startY),c=0,p="";if(this.isInTransition=0,this.initiated=0,this.endTime=o.getTime(),!this.resetPosition(this.options.bounceTime)){if(this.scrollTo(h,r),!this.moved)return this.options.tap&&o.tap(t,this.options.tap),this.options.click&&o.click(t),this._execEvent("scrollCancel"),void 0;if(this._events.flick&&200>n&&100>a&&100>l)return this._execEvent("flick"),void 0;if(this.options.momentum&&300>n&&(i=this.hasHorizontalScroll?o.momentum(this.x,this.startX,n,this.maxScrollX,this.options.bounce?this.wrapperWidth:0):{destination:h,duration:0},s=this.hasVerticalScroll?o.momentum(this.y,this.startY,n,this.maxScrollY,this.options.bounce?this.wrapperHeight:0):{destination:r,duration:0},h=i.destination,r=s.destination,c=e.max(i.duration,s.duration),this.isInTransition=1),this.options.snap){var u=this._nearestSnap(h,r);this.currentPage=u,c=this.options.snapSpeed||e.max(e.max(e.min(e.abs(h-u.x),1e3),e.min(e.abs(r-u.y),1e3)),300),h=u.x,r=u.y,this.directionX=0,this.directionY=0,p=this.options.bounceEasing}return h!=this.x||r!=this.y?((h>0||h<this.maxScrollX||r>0||r<this.maxScrollY)&&(p=o.ease.quadratic),this.scrollTo(h,r,c,p),void 0):(this._execEvent("scrollEnd"),void 0)}}},_resize:function(){var t=this;clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(function(){t.refresh()},this.options.resizePolling)},resetPosition:function(t){var i=this.x,e=this.y;return t=t||0,!this.hasHorizontalScroll||this.x>0?i=0:this.x<this.maxScrollX&&(i=this.maxScrollX),!this.hasVerticalScroll||this.y>0?e=0:this.y<this.maxScrollY&&(e=this.maxScrollY),i==this.x&&e==this.y?!1:(this.scrollTo(i,e,t,this.options.bounceEasing),!0)},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){this.wrapper.offsetHeight;this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight,this.scrollerWidth=this.scroller.offsetWidth,this.scrollerHeight=this.scroller.offsetHeight,this.maxScrollX=this.wrapperWidth-this.scrollerWidth;var t;this.options.infiniteElements&&(this.options.infiniteLimit=this.options.infiniteLimit||e.floor(2147483645/this.infiniteElementHeight),t=-this.options.infiniteLimit*this.infiniteElementHeight+this.wrapperHeight),this.maxScrollY=void 0!==t?t: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,this.wrapperOffset=o.offset(this.wrapper),this._execEvent("refresh"),this.resetPosition()},on:function(t,i){this._events[t]||(this._events[t]=[]),this._events[t].push(i)},_execEvent:function(t){if(this._events[t]){var i=0,e=this._events[t].length;if(e)for(;e>i;i++)this._events[t][i].apply(this,[].slice.call(arguments,1))}},scrollBy:function(t,i,e,s){t=this.x+t,i=this.y+i,e=e||0,this.scrollTo(t,i,e,s)},scrollTo:function(t,i,e,s){s=s||o.ease.circular,this.isInTransition=this.options.useTransition&&e>0,!e||this.options.useTransition&&s.style?(this._transitionTimingFunction(s.style),this._transitionTime(e),this._translate(t,i)):this._animate(t,i,e,s.fn)},scrollToElement:function(t,i,s,n,h){if(t=t.nodeType?t:this.scroller.querySelector(t)){var r=o.offset(t);r.left-=this.wrapperOffset.left,r.top-=this.wrapperOffset.top,s===!0&&(s=e.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),n===!0&&(n=e.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),r.left-=s||0,r.top-=n||0,r.left=r.left>0?0:r.left<this.maxScrollX?this.maxScrollX:r.left,r.top=r.top>0?0:r.top<this.maxScrollY?this.maxScrollY:r.top,i=void 0===i||null===i||"auto"===i?e.max(e.abs(this.x-r.left),e.abs(this.y-r.top)):i,this.scrollTo(r.left,r.top,i,h)}},_transitionTime:function(t){t=t||0,this.scrollerStyle[o.style.transitionDuration]=t+"ms",!t&&o.isBadAndroid&&(this.scrollerStyle[o.style.transitionDuration]="0.001s")},_transitionTimingFunction:function(t){this.scrollerStyle[o.style.transitionTimingFunction]=t},_translate:function(t,i){this.options.useTransform?this.scrollerStyle[o.style.transform]="translate("+t+"px,"+i+"px)"+this.translateZ:(t=e.round(t),i=e.round(i),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=i+"px"),this.x=t,this.y=i},_initEvents:function(i){var e=i?o.removeEvent:o.addEvent,s=this.options.bindToWrapper?this.wrapper:t;e(t,"orientationchange",this),e(t,"resize",this),this.options.click&&e(this.wrapper,"click",this,!0),this.options.disableMouse||(e(this.wrapper,"mousedown",this),e(s,"mousemove",this),e(s,"mousecancel",this),e(s,"mouseup",this)),o.hasPointer&&!this.options.disablePointer&&(e(this.wrapper,"MSPointerDown",this),e(s,"MSPointerMove",this),e(s,"MSPointerCancel",this),e(s,"MSPointerUp",this)),o.hasTouch&&!this.options.disableTouch&&(e(this.wrapper,"touchstart",this),e(s,"touchmove",this),e(s,"touchcancel",this),e(s,"touchend",this)),e(this.scroller,"transitionend",this),e(this.scroller,"webkitTransitionEnd",this),e(this.scroller,"oTransitionEnd",this),e(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var i,e,s=t.getComputedStyle(this.scroller,null);return this.options.useTransform?(s=s[o.style.transform].split(")")[0].split(", "),i=+(s[12]||s[4]),e=+(s[13]||s[5])):(i=+s.left.replace(/[^-\d.]/g,""),e=+s.top.replace(/[^-\d.]/g,"")),{x:i,y:e}},_initWheel:function(){o.addEvent(this.wrapper,"wheel",this),o.addEvent(this.wrapper,"mousewheel",this),o.addEvent(this.wrapper,"DOMMouseScroll",this),this.on("destroy",function(){o.removeEvent(this.wrapper,"wheel",this),o.removeEvent(this.wrapper,"mousewheel",this),o.removeEvent(this.wrapper,"DOMMouseScroll",this)})},_wheel:function(t){if(this.enabled){t.preventDefault(),t.stopPropagation();var i,s,n,o,h=this;if(void 0===this.wheelTimeout&&h._execEvent("scrollStart"),clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout(function(){h._execEvent("scrollEnd"),h.wheelTimeout=void 0},400),"deltaX"in t)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 n=this.currentPage.pageX,o=this.currentPage.pageY,i>0?n--:0>i&&n++,s>0?o--:0>s&&o++,this.goToPage(n,o),void 0;n=this.x+e.round(this.hasHorizontalScroll?i:0),o=this.y+e.round(this.hasVerticalScroll?s:0),n>0?n=0:n<this.maxScrollX&&(n=this.maxScrollX),o>0?o=0:o<this.maxScrollY&&(o=this.maxScrollY),this.scrollTo(n,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,n,o,h,r=0,a=0,l=0,c=this.options.snapStepX||this.wrapperWidth,p=this.options.snapStepY||this.wrapperHeight;if(this.pages=[],this.wrapperWidth&&this.wrapperHeight&&this.scrollerWidth&&this.scrollerHeight){if(this.options.snap===!0)for(s=e.round(c/2),n=e.round(p/2);l>-this.scrollerWidth;){for(this.pages[r]=[],t=0,o=0;o>-this.scrollerHeight;)this.pages[r][t]={x:e.max(l,this.maxScrollX),y:e.max(o,this.maxScrollY),width:c,height:p,cx:l-s,cy:o-n},o-=p,t++;l-=c,r++}else for(h=this.options.snap,t=h.length,i=-1;t>r;r++)(0===r||h[r].offsetLeft<=h[r-1].offsetLeft)&&(a=0,i++),this.pages[a]||(this.pages[a]=[]),l=e.max(-h[r].offsetLeft,this.maxScrollX),o=e.max(-h[r].offsetTop,this.maxScrollY),s=l-e.round(h[r].offsetWidth/2),n=o-e.round(h[r].offsetHeight/2),this.pages[a][i]={x:l,y:o,width:h[r].offsetWidth,height:h[r].offsetHeight,cx:s,cy:n},l>this.maxScrollX&&a++;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=e.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*this.options.snapThreshold),this.snapThresholdY=e.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold))}}),this.on("flick",function(){var t=this.options.snapSpeed||e.max(e.max(e.min(e.abs(this.x-this.startX),1e3),e.min(e.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,n=this.pages.length,o=0;if(e.abs(t-this.absStartX)<this.snapThresholdX&&e.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);n>s;s++)if(t>=this.pages[s][0].cx){t=this.pages[s][0].x;break}for(n=this.pages[s].length;n>o;o++)if(i>=this.pages[0][o].cy){i=this.pages[0][o].y;break}return s==this.currentPage.pageX&&(s+=this.directionX,0>s?s=0:s>=this.pages.length&&(s=this.pages.length-1),t=this.pages[s][0].x),o==this.currentPage.pageY&&(o+=this.directionY,0>o?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,n){n=n||this.options.bounceEasing,t>=this.pages.length?t=this.pages.length-1:0>t&&(t=0),i>=this.pages[t].length?i=this.pages[t].length-1:0>i&&(i=0);var o=this.pages[t][i].x,h=this.pages[t][i].y;s=void 0===s?this.options.snapSpeed||e.max(e.max(e.min(e.abs(o-this.x),1e3),e.min(e.abs(h-this.y),1e3)),300):s,this.currentPage={x:o,y:h,pageX:t,pageY:i},this.scrollTo(o,h,s,n)},next:function(t,i){var e=this.currentPage.pageX,s=this.currentPage.pageY;e++,e>=this.pages.length&&this.hasVerticalScroll&&(e=0,s++),this.goToPage(e,s,t,i)},prev:function(t,i){var e=this.currentPage.pageX,s=this.currentPage.pageY;e--,0>e&&this.hasVerticalScroll&&(e=0,s--),this.goToPage(e,s,t,i)},_initKeys:function(){var i,e={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40};if("object"==typeof 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 e)this.options.keyBindings[i]=this.options.keyBindings[i]||e[i];o.addEvent(t,"keydown",this),this.on("destroy",function(){o.removeEvent(t,"keydown",this)})},_key:function(t){if(this.enabled){var i,s=this.options.snap,n=s?this.currentPage.pageX:this.x,h=s?this.currentPage.pageY:this.y,r=o.getTime(),a=this.keyTime||0,l=.25;switch(this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(e.round(i.x),e.round(i.y)),this.isInTransition=!1),this.keyAcceleration=200>r-a?e.min(this.keyAcceleration+l,50):0,t.keyCode){case this.options.keyBindings.pageUp:this.hasHorizontalScroll&&!this.hasVerticalScroll?n+=s?1:this.wrapperWidth:h+=s?1:this.wrapperHeight;break;case this.options.keyBindings.pageDown:this.hasHorizontalScroll&&!this.hasVerticalScroll?n-=s?1:this.wrapperWidth:h-=s?1:this.wrapperHeight;break;case this.options.keyBindings.end:n=s?this.pages.length-1:this.maxScrollX,h=s?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:n=0,h=0;break;case this.options.keyBindings.left:n+=s?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.up:h+=s?1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.right:n-=s?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.down:h-=s?1:5+this.keyAcceleration>>0;break;default:return}if(s)return this.goToPage(n,h),void 0;n>0?(n=0,this.keyAcceleration=0):n<this.maxScrollX&&(n=this.maxScrollX,this.keyAcceleration=0),h>0?(h=0,this.keyAcceleration=0):h<this.maxScrollY&&(h=this.maxScrollY,this.keyAcceleration=0),this.scrollTo(n,h,0),this.keyTime=r}},_animate:function(t,i,e,s){function h(){var u,f,d,g=o.getTime();return g>=p?(r.isAnimating=!1,r._translate(t,i),r.resetPosition(r.options.bounceTime)||r._execEvent("scrollEnd"),void 0):(g=(g-c)/e,d=s(g),u=(t-a)*d+a,f=(i-l)*d+l,r._translate(u,f),r.isAnimating&&n(h),3==r.options.probeType&&r._execEvent("scroll"),void 0)}var r=this,a=this.x,l=this.y,c=o.getTime(),p=c+e;this.isAnimating=!0,h()},_initInfinite:function(){var t=this.options.infiniteElements;this.infiniteElements="string"==typeof t?i.querySelectorAll(t):t,this.infiniteLength=this.infiniteElements.length,this.infiniteMaster=this.infiniteElements[0],this.infiniteElementHeight=this.infiniteMaster.offsetHeight,this.infiniteHeight=this.infiniteLength*this.infiniteElementHeight,this.options.cacheSize=this.options.cacheSize||1e3,this.infiniteCacheBuffer=e.round(this.options.cacheSize/4),this.options.dataset.call(this,0,this.options.cacheSize),this.on("refresh",function(){var t=e.ceil(this.wrapperHeight/this.infiniteElementHeight);this.infiniteUpperBufferSize=e.floor((this.infiniteLength-t)/2),this.reorderInfinite()}),this.on("scroll",this.reorderInfinite)},reorderInfinite:function(){for(var t=(-this.y+this.wrapperHeight/2,e.max(e.floor(-this.y/this.infiniteElementHeight)-this.infiniteUpperBufferSize,0)),i=e.floor(t/this.infiniteLength),s=t-i*this.infiniteLength,n=0,o=0,h=[],r=e.floor(t/this.infiniteCacheBuffer);o<this.infiniteLength;)n=o*this.infiniteElementHeight+i*this.infiniteHeight,s>o&&(n+=this.infiniteElementHeight*this.infiniteLength),this.infiniteElements[o]._top!==n&&(this.infiniteElements[o]._phase=n/this.infiniteElementHeight,this.infiniteElements[o]._phase<this.options.infiniteLimit&&(this.infiniteElements[o]._top=n,this.infiniteElements[o].style.top=n+"px",h.push(this.infiniteElements[o]))),o++;this.cachePhase!=r&&(0===r||t-this.infiniteCacheBuffer>0)&&this.options.dataset.call(this,e.max(r*this.infiniteCacheBuffer-this.infiniteCacheBuffer,0),this.options.cacheSize),this.cachePhase=r,this.updateContent(h)},updateContent:function(t){if(void 0!==this.infiniteCache)for(var i=0,e=t.length;e>i;i++)this.options.dataFiller.call(this,t[i],this.infiniteCache[t[i]._phase])},updateCache:function(t,i){var e=void 0===this.infiniteCache;this.infiniteCache={};for(var s=0,n=i.length;n>s;s++)this.infiniteCache[t++]=i[s];e&&this.updateContent(this.infiniteElements)},handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":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":t._constructed||(t.preventDefault(),t.stopPropagation())}}},s.utils=o,"undefined"!=typeof module&&module.exports?module.exports=s:t.IScroll=s}(window,document,Math);
No newline at the end of the file
deleted dist/iscroll-lite-min.js +0 −2
@@ -1,2 +0,0 @@
1-/*! iScroll v5.0.9 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
2-!function(t,i,s){function e(t,s){this.wrapper="string"==typeof t?i.querySelector(t):t,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={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};for(var e in s)this.options[e]=s[e];this.translateZ=this.options.HWCompositing&&n.hasPerspective?" translateZ(0)":"",this.options.useTransition=n.hasTransition&&this.options.useTransition,this.options.useTransform=n.hasTransform&&this.options.useTransform,this.options.eventPassthrough=this.options.eventPassthrough===!0?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"==this.options.eventPassthrough?!1:this.options.scrollY,this.options.scrollX="horizontal"==this.options.eventPassthrough?!1: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?n.ease[this.options.bounceEasing]||n.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,this.options.tap===!0&&(this.options.tap="tap"),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()}var o=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(i){t.setTimeout(i,1e3/60)},n=function(){function e(t){return r===!1?!1:""===r?t:r+t.charAt(0).toUpperCase()+t.substr(1)}var o={},n=i.createElement("div").style,r=function(){for(var t,i=["t","webkitT","MozT","msT","OT"],s=0,e=i.length;e>s;s++)if(t=i[s]+"ransform",t in n)return i[s].substr(0,i[s].length-1);return!1}();o.getTime=Date.now||function(){return(new Date).getTime()},o.extend=function(t,i){for(var s in i)t[s]=i[s]},o.addEvent=function(t,i,s,e){t.addEventListener(i,s,!!e)},o.removeEvent=function(t,i,s,e){t.removeEventListener(i,s,!!e)},o.momentum=function(t,i,e,o,n){var r,h,a=t-i,l=s.abs(a)/e,c=6e-4;return r=t+l*l/(2*c)*(0>a?-1:1),h=l/c,o>r?(r=n?o-n/2.5*(l/8):o,a=s.abs(r-t),h=a/l):r>0&&(r=n?n/2.5*(l/8):0,a=s.abs(t)+r,h=a/l),{destination:s.round(r),duration:h}};var h=e("transform");return o.extend(o,{hasTransform:h!==!1,hasPerspective:e("perspective")in n,hasTouch:"ontouchstart"in t,hasPointer:navigator.msPointerEnabled,hasTransition:e("transition")in n}),o.isBadAndroid=/Android/.test(t.navigator.appVersion)&&!/Chrome\/\d/.test(t.navigator.appVersion),o.extend(o.style={},{transform:h,transitionTimingFunction:e("transitionTimingFunction"),transitionDuration:e("transitionDuration"),transitionDelay:e("transitionDelay"),transformOrigin:e("transformOrigin")}),o.hasClass=function(t,i){var s=new RegExp("(^|\\s)"+i+"(\\s|$)");return s.test(t.className)},o.addClass=function(t,i){if(!o.hasClass(t,i)){var s=t.className.split(" ");s.push(i),t.className=s.join(" ")}},o.removeClass=function(t,i){if(o.hasClass(t,i)){var s=new RegExp("(^|\\s)"+i+"(\\s|$)","g");t.className=t.className.replace(s," ")}},o.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}},o.preventDefaultException=function(t,i){for(var s in i)if(i[s].test(t[s]))return!0;return!1},o.extend(o.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),o.extend(o.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 s.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){var i=4;return(t-=1)*t*((i+1)*t+i)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){var i=.22,e=.4;return 0===t?0:1==t?1:e*s.pow(2,-10*t)*s.sin(2*(t-i/4)*s.PI/i)+1}}}),o.tap=function(t,s){var e=i.createEvent("Event");e.initEvent(s,!0,!0),e.pageX=t.pageX,e.pageY=t.pageY,t.target.dispatchEvent(e)},o.click=function(t){var s,e=t.target;"SELECT"!=e.tagName&&"INPUT"!=e.tagName&&"TEXTAREA"!=e.tagName&&(s=i.createEvent("MouseEvents"),s.initMouseEvent("click",!0,!0,t.view,1,e.screenX,e.screenY,e.clientX,e.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,null),s._constructed=!0,e.dispatchEvent(s))},o}();e.prototype={version:"5.0.9",_init:function(){this._initEvents()},destroy:function(){this._initEvents(!0),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!=n.eventType[t.type]&&0!==t.button||!this.enabled||this.initiated&&n.eventType[t.type]!==this.initiated)){!this.options.preventDefault||n.isBadAndroid||n.preventDefaultException(t.target,this.options.preventDefaultException)||t.preventDefault();var i,e=t.touches?t.touches[0]:t;this.initiated=n.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this._transitionTime(),this.startTime=n.getTime(),this.options.useTransition&&this.isInTransition?(this.isInTransition=!1,i=this.getComputedPosition(),this._translate(s.round(i.x),s.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=e.pageX,this.pointY=e.pageY,this._execEvent("beforeScrollStart")}},_move:function(t){if(this.enabled&&n.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o,r,h=t.touches?t.touches[0]:t,a=h.pageX-this.pointX,l=h.pageY-this.pointY,c=n.getTime();if(this.pointX=h.pageX,this.pointY=h.pageY,this.distX+=a,this.distY+=l,o=s.abs(this.distX),r=s.abs(this.distY),!(c-this.endTime>300&&10>o&&10>r)){if(this.directionLocked||this.options.freeScroll||(this.directionLocked=o>r+this.options.directionLockThreshold?"h":r>=o+this.options.directionLockThreshold?"v":"n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return this.initiated=!1,void 0;l=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return this.initiated=!1,void 0;a=0}a=this.hasHorizontalScroll?a:0,l=this.hasVerticalScroll?l:0,i=this.x+a,e=this.y+l,(i>0||i<this.maxScrollX)&&(i=this.options.bounce?this.x+a/3:i>0?0:this.maxScrollX),(e>0||e<this.maxScrollY)&&(e=this.options.bounce?this.y+l/3:e>0?0:this.maxScrollY),this.directionX=a>0?-1:0>a?1:0,this.directionY=l>0?-1:0>l?1:0,this.moved||this._execEvent("scrollStart"),this.moved=!0,this._translate(i,e),c-this.startTime>300&&(this.startTime=c,this.startX=this.x,this.startY=this.y)}}},_end:function(t){if(this.enabled&&n.eventType[t.type]===this.initiated){this.options.preventDefault&&!n.preventDefaultException(t.target,this.options.preventDefaultException)&&t.preventDefault();var i,e,o=(t.changedTouches?t.changedTouches[0]:t,n.getTime()-this.startTime),r=s.round(this.x),h=s.round(this.y),a=s.abs(r-this.startX),l=s.abs(h-this.startY),c=0,p="";if(this.isInTransition=0,this.initiated=0,this.endTime=n.getTime(),!this.resetPosition(this.options.bounceTime))return this.scrollTo(r,h),this.moved?this._events.flick&&200>o&&100>a&&100>l?(this._execEvent("flick"),void 0):(this.options.momentum&&300>o&&(i=this.hasHorizontalScroll?n.momentum(this.x,this.startX,o,this.maxScrollX,this.options.bounce?this.wrapperWidth:0):{destination:r,duration:0},e=this.hasVerticalScroll?n.momentum(this.y,this.startY,o,this.maxScrollY,this.options.bounce?this.wrapperHeight:0):{destination:h,duration:0},r=i.destination,h=e.destination,c=s.max(i.duration,e.duration),this.isInTransition=1),r!=this.x||h!=this.y?((r>0||r<this.maxScrollX||h>0||h<this.maxScrollY)&&(p=n.ease.quadratic),this.scrollTo(r,h,c,p),void 0):(this._execEvent("scrollEnd"),void 0)):(this.options.tap&&n.tap(t,this.options.tap),this.options.click&&n.click(t),this._execEvent("scrollCancel"),void 0)}},_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;return 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?!1:(this.scrollTo(i,s,t,this.options.bounceEasing),!0)},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){this.wrapper.offsetHeight;this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight,this.scrollerWidth=this.scroller.offsetWidth,this.scrollerHeight=this.scroller.offsetHeight,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,this.wrapperOffset=n.offset(this.wrapper),this._execEvent("refresh"),this.resetPosition()},on:function(t,i){this._events[t]||(this._events[t]=[]),this._events[t].push(i)},_execEvent:function(t){if(this._events[t]){var i=0,s=this._events[t].length;if(s)for(;s>i;i++)this._events[t][i].call(this)}},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||n.ease.circular,this.isInTransition=this.options.useTransition&&s>0,!s||this.options.useTransition&&e.style?(this._transitionTimingFunction(e.style),this._transitionTime(s),this._translate(t,i)):this._animate(t,i,s,e.fn)},scrollToElement:function(t,i,e,o,r){if(t=t.nodeType?t:this.scroller.querySelector(t)){var h=n.offset(t);h.left-=this.wrapperOffset.left,h.top-=this.wrapperOffset.top,e===!0&&(e=s.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),o===!0&&(o=s.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),h.left-=e||0,h.top-=o||0,h.left=h.left>0?0:h.left<this.maxScrollX?this.maxScrollX:h.left,h.top=h.top>0?0:h.top<this.maxScrollY?this.maxScrollY:h.top,i=void 0===i||null===i||"auto"===i?s.max(s.abs(this.x-h.left),s.abs(this.y-h.top)):i,this.scrollTo(h.left,h.top,i,r)}},_transitionTime:function(t){t=t||0,this.scrollerStyle[n.style.transitionDuration]=t+"ms",!t&&n.isBadAndroid&&(this.scrollerStyle[n.style.transitionDuration]="0.001s")},_transitionTimingFunction:function(t){this.scrollerStyle[n.style.transitionTimingFunction]=t},_translate:function(t,i){this.options.useTransform?this.scrollerStyle[n.style.transform]="translate("+t+"px,"+i+"px)"+this.translateZ:(t=s.round(t),i=s.round(i),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=i+"px"),this.x=t,this.y=i},_initEvents:function(i){var s=i?n.removeEvent:n.addEvent,e=this.options.bindToWrapper?this.wrapper:t;s(t,"orientationchange",this),s(t,"resize",this),this.options.click&&s(this.wrapper,"click",this,!0),this.options.disableMouse||(s(this.wrapper,"mousedown",this),s(e,"mousemove",this),s(e,"mousecancel",this),s(e,"mouseup",this)),n.hasPointer&&!this.options.disablePointer&&(s(this.wrapper,"MSPointerDown",this),s(e,"MSPointerMove",this),s(e,"MSPointerCancel",this),s(e,"MSPointerUp",this)),n.hasTouch&&!this.options.disableTouch&&(s(this.wrapper,"touchstart",this),s(e,"touchmove",this),s(e,"touchcancel",this),s(e,"touchend",this)),s(this.scroller,"transitionend",this),s(this.scroller,"webkitTransitionEnd",this),s(this.scroller,"oTransitionEnd",this),s(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var i,s,e=t.getComputedStyle(this.scroller,null);return this.options.useTransform?(e=e[n.style.transform].split(")")[0].split(", "),i=+(e[12]||e[4]),s=+(e[13]||e[5])):(i=+e.left.replace(/[^-\d.]/g,""),s=+e.top.replace(/[^-\d.]/g,"")),{x:i,y:s}},_animate:function(t,i,s,e){function r(){var u,d,f,m=n.getTime();return m>=p?(h.isAnimating=!1,h._translate(t,i),h.resetPosition(h.options.bounceTime)||h._execEvent("scrollEnd"),void 0):(m=(m-c)/s,f=e(m),u=(t-a)*f+a,d=(i-l)*f+l,h._translate(u,d),h.isAnimating&&o(r),void 0)}var h=this,a=this.x,l=this.y,c=n.getTime(),p=c+s;this.isAnimating=!0,r()},handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":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":t._constructed||(t.preventDefault(),t.stopPropagation())}}},e.utils=n,"undefined"!=typeof module&&module.exports?module.exports=e:t.IScroll=e}(window,document,Math);
No newline at the end of the file
deleted dist/iscroll-min.js +0 −2
@@ -1,2 +0,0 @@
1-/*! iScroll v5.0.9 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
2-!function(t,i,s){function e(t,s){this.wrapper="string"==typeof t?i.querySelector(t):t,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={resizeIndicator:!0,mouseWheelSpeed:20,snapThreshold:.334,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};for(var e in s)this.options[e]=s[e];this.translateZ=this.options.HWCompositing&&h.hasPerspective?" translateZ(0)":"",this.options.useTransition=h.hasTransition&&this.options.useTransition,this.options.useTransform=h.hasTransform&&this.options.useTransform,this.options.eventPassthrough=this.options.eventPassthrough===!0?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"==this.options.eventPassthrough?!1:this.options.scrollY,this.options.scrollX="horizontal"==this.options.eventPassthrough?!1: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?h.ease[this.options.bounceEasing]||h.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,this.options.tap===!0&&(this.options.tap="tap"),"scale"==this.options.shrinkScrollbars&&(this.options.useTransition=!1),this.options.invertWheelDirection=this.options.invertWheelDirection?-1: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 o(t,s,e){var o=i.createElement("div"),n=i.createElement("div");return e===!0&&(o.style.cssText="position:absolute;z-index:9999",n.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"),n.className="iScrollIndicator","h"==t?(e===!0&&(o.style.cssText+=";height:7px;left:2px;right:2px;bottom:0",n.style.height="100%"),o.className="iScrollHorizontalScrollbar"):(e===!0&&(o.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px",n.style.width="100%"),o.className="iScrollVerticalScrollbar"),o.style.cssText+=";overflow:hidden",s||(o.style.pointerEvents="none"),o.appendChild(n),o}function n(s,e){this.wrapper="string"==typeof e.el?i.querySelector(e.el):e.el,this.wrapperStyle=this.wrapper.style,this.indicator=this.wrapper.children[0],this.indicatorStyle=this.indicator.style,this.scroller=s,this.options={listenX:!0,listenY:!0,interactive:!1,resize:!0,defaultScrollbars:!1,shrink:!1,fade:!1,speedRatioX:0,speedRatioY:0};for(var o in e)this.options[o]=e[o];this.sizeRatioX=1,this.sizeRatioY=1,this.maxPosX=0,this.maxPosY=0,this.options.interactive&&(this.options.disableTouch||(h.addEvent(this.indicator,"touchstart",this),h.addEvent(t,"touchend",this)),this.options.disablePointer||(h.addEvent(this.indicator,"MSPointerDown",this),h.addEvent(t,"MSPointerUp",this)),this.options.disableMouse||(h.addEvent(this.indicator,"mousedown",this),h.addEvent(t,"mouseup",this))),this.options.fade&&(this.wrapperStyle[h.style.transform]=this.scroller.translateZ,this.wrapperStyle[h.style.transitionDuration]=h.isBadAndroid?"0.001s":"0ms",this.wrapperStyle.opacity="0")}var r=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(i){t.setTimeout(i,1e3/60)},h=function(){function e(t){return r===!1?!1:""===r?t:r+t.charAt(0).toUpperCase()+t.substr(1)}var o={},n=i.createElement("div").style,r=function(){for(var t,i=["t","webkitT","MozT","msT","OT"],s=0,e=i.length;e>s;s++)if(t=i[s]+"ransform",t in n)return i[s].substr(0,i[s].length-1);return!1}();o.getTime=Date.now||function(){return(new Date).getTime()},o.extend=function(t,i){for(var s in i)t[s]=i[s]},o.addEvent=function(t,i,s,e){t.addEventListener(i,s,!!e)},o.removeEvent=function(t,i,s,e){t.removeEventListener(i,s,!!e)},o.momentum=function(t,i,e,o,n){var r,h,a=t-i,l=s.abs(a)/e,c=6e-4;return r=t+l*l/(2*c)*(0>a?-1:1),h=l/c,o>r?(r=n?o-n/2.5*(l/8):o,a=s.abs(r-t),h=a/l):r>0&&(r=n?n/2.5*(l/8):0,a=s.abs(t)+r,h=a/l),{destination:s.round(r),duration:h}};var h=e("transform");return o.extend(o,{hasTransform:h!==!1,hasPerspective:e("perspective")in n,hasTouch:"ontouchstart"in t,hasPointer:navigator.msPointerEnabled,hasTransition:e("transition")in n}),o.isBadAndroid=/Android/.test(t.navigator.appVersion)&&!/Chrome\/\d/.test(t.navigator.appVersion),o.extend(o.style={},{transform:h,transitionTimingFunction:e("transitionTimingFunction"),transitionDuration:e("transitionDuration"),transitionDelay:e("transitionDelay"),transformOrigin:e("transformOrigin")}),o.hasClass=function(t,i){var s=new RegExp("(^|\\s)"+i+"(\\s|$)");return s.test(t.className)},o.addClass=function(t,i){if(!o.hasClass(t,i)){var s=t.className.split(" ");s.push(i),t.className=s.join(" ")}},o.removeClass=function(t,i){if(o.hasClass(t,i)){var s=new RegExp("(^|\\s)"+i+"(\\s|$)","g");t.className=t.className.replace(s," ")}},o.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}},o.preventDefaultException=function(t,i){for(var s in i)if(i[s].test(t[s]))return!0;return!1},o.extend(o.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),o.extend(o.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 s.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){var i=4;return(t-=1)*t*((i+1)*t+i)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){var i=.22,e=.4;return 0===t?0:1==t?1:e*s.pow(2,-10*t)*s.sin(2*(t-i/4)*s.PI/i)+1}}}),o.tap=function(t,s){var e=i.createEvent("Event");e.initEvent(s,!0,!0),e.pageX=t.pageX,e.pageY=t.pageY,t.target.dispatchEvent(e)},o.click=function(t){var s,e=t.target;"SELECT"!=e.tagName&&"INPUT"!=e.tagName&&"TEXTAREA"!=e.tagName&&(s=i.createEvent("MouseEvents"),s.initMouseEvent("click",!0,!0,t.view,1,e.screenX,e.screenY,e.clientX,e.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,null),s._constructed=!0,e.dispatchEvent(s))},o}();e.prototype={version:"5.0.9",_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),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!=h.eventType[t.type]&&0!==t.button||!this.enabled||this.initiated&&h.eventType[t.type]!==this.initiated)){!this.options.preventDefault||h.isBadAndroid||h.preventDefaultException(t.target,this.options.preventDefaultException)||t.preventDefault();var i,e=t.touches?t.touches[0]:t;this.initiated=h.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this._transitionTime(),this.startTime=h.getTime(),this.options.useTransition&&this.isInTransition?(this.isInTransition=!1,i=this.getComputedPosition(),this._translate(s.round(i.x),s.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=e.pageX,this.pointY=e.pageY,this._execEvent("beforeScrollStart")}},_move:function(t){if(this.enabled&&h.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o,n,r=t.touches?t.touches[0]:t,a=r.pageX-this.pointX,l=r.pageY-this.pointY,c=h.getTime();if(this.pointX=r.pageX,this.pointY=r.pageY,this.distX+=a,this.distY+=l,o=s.abs(this.distX),n=s.abs(this.distY),!(c-this.endTime>300&&10>o&&10>n)){if(this.directionLocked||this.options.freeScroll||(this.directionLocked=o>n+this.options.directionLockThreshold?"h":n>=o+this.options.directionLockThreshold?"v":"n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return this.initiated=!1,void 0;l=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return this.initiated=!1,void 0;a=0}a=this.hasHorizontalScroll?a:0,l=this.hasVerticalScroll?l:0,i=this.x+a,e=this.y+l,(i>0||i<this.maxScrollX)&&(i=this.options.bounce?this.x+a/3:i>0?0:this.maxScrollX),(e>0||e<this.maxScrollY)&&(e=this.options.bounce?this.y+l/3:e>0?0:this.maxScrollY),this.directionX=a>0?-1:0>a?1:0,this.directionY=l>0?-1:0>l?1:0,this.moved||this._execEvent("scrollStart"),this.moved=!0,this._translate(i,e),c-this.startTime>300&&(this.startTime=c,this.startX=this.x,this.startY=this.y)}}},_end:function(t){if(this.enabled&&h.eventType[t.type]===this.initiated){this.options.preventDefault&&!h.preventDefaultException(t.target,this.options.preventDefaultException)&&t.preventDefault();var i,e,o=(t.changedTouches?t.changedTouches[0]:t,h.getTime()-this.startTime),n=s.round(this.x),r=s.round(this.y),a=s.abs(n-this.startX),l=s.abs(r-this.startY),c=0,p="";if(this.isInTransition=0,this.initiated=0,this.endTime=h.getTime(),!this.resetPosition(this.options.bounceTime)){if(this.scrollTo(n,r),!this.moved)return this.options.tap&&h.tap(t,this.options.tap),this.options.click&&h.click(t),this._execEvent("scrollCancel"),void 0;if(this._events.flick&&200>o&&100>a&&100>l)return this._execEvent("flick"),void 0;if(this.options.momentum&&300>o&&(i=this.hasHorizontalScroll?h.momentum(this.x,this.startX,o,this.maxScrollX,this.options.bounce?this.wrapperWidth:0):{destination:n,duration:0},e=this.hasVerticalScroll?h.momentum(this.y,this.startY,o,this.maxScrollY,this.options.bounce?this.wrapperHeight:0):{destination:r,duration:0},n=i.destination,r=e.destination,c=s.max(i.duration,e.duration),this.isInTransition=1),this.options.snap){var d=this._nearestSnap(n,r);this.currentPage=d,c=this.options.snapSpeed||s.max(s.max(s.min(s.abs(n-d.x),1e3),s.min(s.abs(r-d.y),1e3)),300),n=d.x,r=d.y,this.directionX=0,this.directionY=0,p=this.options.bounceEasing}return n!=this.x||r!=this.y?((n>0||n<this.maxScrollX||r>0||r<this.maxScrollY)&&(p=h.ease.quadratic),this.scrollTo(n,r,c,p),void 0):(this._execEvent("scrollEnd"),void 0)}}},_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;return 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?!1:(this.scrollTo(i,s,t,this.options.bounceEasing),!0)},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){this.wrapper.offsetHeight;this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight,this.scrollerWidth=this.scroller.offsetWidth,this.scrollerHeight=this.scroller.offsetHeight,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,this.wrapperOffset=h.offset(this.wrapper),this._execEvent("refresh"),this.resetPosition()},on:function(t,i){this._events[t]||(this._events[t]=[]),this._events[t].push(i)},_execEvent:function(t){if(this._events[t]){var i=0,s=this._events[t].length;if(s)for(;s>i;i++)this._events[t][i].call(this)}},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||h.ease.circular,this.isInTransition=this.options.useTransition&&s>0,!s||this.options.useTransition&&e.style?(this._transitionTimingFunction(e.style),this._transitionTime(s),this._translate(t,i)):this._animate(t,i,s,e.fn)},scrollToElement:function(t,i,e,o,n){if(t=t.nodeType?t:this.scroller.querySelector(t)){var r=h.offset(t);r.left-=this.wrapperOffset.left,r.top-=this.wrapperOffset.top,e===!0&&(e=s.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),o===!0&&(o=s.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),r.left-=e||0,r.top-=o||0,r.left=r.left>0?0:r.left<this.maxScrollX?this.maxScrollX:r.left,r.top=r.top>0?0:r.top<this.maxScrollY?this.maxScrollY:r.top,i=void 0===i||null===i||"auto"===i?s.max(s.abs(this.x-r.left),s.abs(this.y-r.top)):i,this.scrollTo(r.left,r.top,i,n)}},_transitionTime:function(t){if(t=t||0,this.scrollerStyle[h.style.transitionDuration]=t+"ms",!t&&h.isBadAndroid&&(this.scrollerStyle[h.style.transitionDuration]="0.001s"),this.indicators)for(var i=this.indicators.length;i--;)this.indicators[i].transitionTime(t)},_transitionTimingFunction:function(t){if(this.scrollerStyle[h.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[h.style.transform]="translate("+t+"px,"+i+"px)"+this.translateZ:(t=s.round(t),i=s.round(i),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=i+"px"),this.x=t,this.y=i,this.indicators)for(var e=this.indicators.length;e--;)this.indicators[e].updatePosition()},_initEvents:function(i){var s=i?h.removeEvent:h.addEvent,e=this.options.bindToWrapper?this.wrapper:t;s(t,"orientationchange",this),s(t,"resize",this),this.options.click&&s(this.wrapper,"click",this,!0),this.options.disableMouse||(s(this.wrapper,"mousedown",this),s(e,"mousemove",this),s(e,"mousecancel",this),s(e,"mouseup",this)),h.hasPointer&&!this.options.disablePointer&&(s(this.wrapper,"MSPointerDown",this),s(e,"MSPointerMove",this),s(e,"MSPointerCancel",this),s(e,"MSPointerUp",this)),h.hasTouch&&!this.options.disableTouch&&(s(this.wrapper,"touchstart",this),s(e,"touchmove",this),s(e,"touchcancel",this),s(e,"touchend",this)),s(this.scroller,"transitionend",this),s(this.scroller,"webkitTransitionEnd",this),s(this.scroller,"oTransitionEnd",this),s(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var i,s,e=t.getComputedStyle(this.scroller,null);return this.options.useTransform?(e=e[h.style.transform].split(")")[0].split(", "),i=+(e[12]||e[4]),s=+(e[13]||e[5])):(i=+e.left.replace(/[^-\d.]/g,""),s=+e.top.replace(/[^-\d.]/g,"")),{x:i,y:s}},_initIndicators:function(){function t(t){for(var i=h.indicators.length;i--;)t.call(h.indicators[i])}var i,s=this.options.interactiveScrollbars,e=("object"!=typeof this.options.scrollbars,"string"!=typeof this.options.scrollbars),r=[],h=this;this.indicators=[],this.options.scrollbars&&(this.options.scrollY&&(i={el:o("v",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,customStyle:e,resize:this.options.resizeIndicator,shrink:this.options.shrinkScrollbars,fade:this.options.fadeScrollbars,listenX:!1},this.wrapper.appendChild(i.el),r.push(i)),this.options.scrollX&&(i={el:o("h",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,customStyle:e,resize:this.options.resizeIndicator,shrink:this.options.shrinkScrollbars,fade:this.options.fadeScrollbars,listenY:!1},this.wrapper.appendChild(i.el),r.push(i))),this.options.indicators&&(r=r.concat(this.options.indicators));for(var a=r.length;a--;)this.indicators.push(new n(this,r[a]));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(){h.addEvent(this.wrapper,"wheel",this),h.addEvent(this.wrapper,"mousewheel",this),h.addEvent(this.wrapper,"DOMMouseScroll",this),this.on("destroy",function(){h.removeEvent(this.wrapper,"wheel",this),h.removeEvent(this.wrapper,"mousewheel",this),h.removeEvent(this.wrapper,"DOMMouseScroll",this)})},_wheel:function(t){if(this.enabled){t.preventDefault(),t.stopPropagation();var i,e,o,n,r=this;if(void 0===this.wheelTimeout&&r._execEvent("scrollStart"),clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout(function(){r._execEvent("scrollEnd"),r.wheelTimeout=void 0},400),"deltaX"in t)i=-t.deltaX,e=-t.deltaY;else if("wheelDeltaX"in t)i=t.wheelDeltaX/120*this.options.mouseWheelSpeed,e=t.wheelDeltaY/120*this.options.mouseWheelSpeed;else if("wheelDelta"in t)i=e=t.wheelDelta/120*this.options.mouseWheelSpeed;else{if(!("detail"in t))return;i=e=-t.detail/3*this.options.mouseWheelSpeed}if(i*=this.options.invertWheelDirection,e*=this.options.invertWheelDirection,this.hasVerticalScroll||(i=e,e=0),this.options.snap)return o=this.currentPage.pageX,n=this.currentPage.pageY,i>0?o--:0>i&&o++,e>0?n--:0>e&&n++,this.goToPage(o,n),void 0;o=this.x+s.round(this.hasHorizontalScroll?i:0),n=this.y+s.round(this.hasVerticalScroll?e:0),o>0?o=0:o<this.maxScrollX&&(o=this.maxScrollX),n>0?n=0:n<this.maxScrollY&&(n=this.maxScrollY),this.scrollTo(o,n,0)}},_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,e,o,n,r,h=0,a=0,l=0,c=this.options.snapStepX||this.wrapperWidth,p=this.options.snapStepY||this.wrapperHeight;if(this.pages=[],this.wrapperWidth&&this.wrapperHeight&&this.scrollerWidth&&this.scrollerHeight){if(this.options.snap===!0)for(e=s.round(c/2),o=s.round(p/2);l>-this.scrollerWidth;){for(this.pages[h]=[],t=0,n=0;n>-this.scrollerHeight;)this.pages[h][t]={x:s.max(l,this.maxScrollX),y:s.max(n,this.maxScrollY),width:c,height:p,cx:l-e,cy:n-o},n-=p,t++;l-=c,h++}else for(r=this.options.snap,t=r.length,i=-1;t>h;h++)(0===h||r[h].offsetLeft<=r[h-1].offsetLeft)&&(a=0,i++),this.pages[a]||(this.pages[a]=[]),l=s.max(-r[h].offsetLeft,this.maxScrollX),n=s.max(-r[h].offsetTop,this.maxScrollY),e=l-s.round(r[h].offsetWidth/2),o=n-s.round(r[h].offsetHeight/2),this.pages[a][i]={x:l,y:n,width:r[h].offsetWidth,height:r[h].offsetHeight,cx:e,cy:o},l>this.maxScrollX&&a++;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=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*this.options.snapThreshold),this.snapThresholdY=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold))}}),this.on("flick",function(){var t=this.options.snapSpeed||s.max(s.max(s.min(s.abs(this.x-this.startX),1e3),s.min(s.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 e=0,o=this.pages.length,n=0;if(s.abs(t-this.absStartX)<this.snapThresholdX&&s.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);o>e;e++)if(t>=this.pages[e][0].cx){t=this.pages[e][0].x;break}for(o=this.pages[e].length;o>n;n++)if(i>=this.pages[0][n].cy){i=this.pages[0][n].y;break}return e==this.currentPage.pageX&&(e+=this.directionX,0>e?e=0:e>=this.pages.length&&(e=this.pages.length-1),t=this.pages[e][0].x),n==this.currentPage.pageY&&(n+=this.directionY,0>n?n=0:n>=this.pages[0].length&&(n=this.pages[0].length-1),i=this.pages[0][n].y),{x:t,y:i,pageX:e,pageY:n}},goToPage:function(t,i,e,o){o=o||this.options.bounceEasing,t>=this.pages.length?t=this.pages.length-1:0>t&&(t=0),i>=this.pages[t].length?i=this.pages[t].length-1:0>i&&(i=0);var n=this.pages[t][i].x,r=this.pages[t][i].y;e=void 0===e?this.options.snapSpeed||s.max(s.max(s.min(s.abs(n-this.x),1e3),s.min(s.abs(r-this.y),1e3)),300):e,this.currentPage={x:n,y:r,pageX:t,pageY:i},this.scrollTo(n,r,e,o)},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--,0>s&&this.hasVerticalScroll&&(s=0,e--),this.goToPage(s,e,t,i)},_initKeys:function(){var i,s={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40};if("object"==typeof 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];h.addEvent(t,"keydown",this),this.on("destroy",function(){h.removeEvent(t,"keydown",this)})},_key:function(t){if(this.enabled){var i,e=this.options.snap,o=e?this.currentPage.pageX:this.x,n=e?this.currentPage.pageY:this.y,r=h.getTime(),a=this.keyTime||0,l=.25;switch(this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.keyAcceleration=200>r-a?s.min(this.keyAcceleration+l,50):0,t.keyCode){case this.options.keyBindings.pageUp:this.hasHorizontalScroll&&!this.hasVerticalScroll?o+=e?1:this.wrapperWidth:n+=e?1:this.wrapperHeight;break;case this.options.keyBindings.pageDown:this.hasHorizontalScroll&&!this.hasVerticalScroll?o-=e?1:this.wrapperWidth:n-=e?1:this.wrapperHeight;break;case this.options.keyBindings.end:o=e?this.pages.length-1:this.maxScrollX,n=e?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:o=0,n=0;break;case this.options.keyBindings.left:o+=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.up:n+=e?1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.right:o-=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.down:n-=e?1:5+this.keyAcceleration>>0;break;default:return}if(e)return this.goToPage(o,n),void 0;o>0?(o=0,this.keyAcceleration=0):o<this.maxScrollX&&(o=this.maxScrollX,this.keyAcceleration=0),n>0?(n=0,this.keyAcceleration=0):n<this.maxScrollY&&(n=this.maxScrollY,this.keyAcceleration=0),this.scrollTo(o,n,0),this.keyTime=r}},_animate:function(t,i,s,e){function o(){var d,u,m,f=h.getTime();return f>=p?(n.isAnimating=!1,n._translate(t,i),n.resetPosition(n.options.bounceTime)||n._execEvent("scrollEnd"),void 0):(f=(f-c)/s,m=e(f),d=(t-a)*m+a,u=(i-l)*m+l,n._translate(d,u),n.isAnimating&&r(o),void 0)}var n=this,a=this.x,l=this.y,c=h.getTime(),p=c+s;this.isAnimating=!0,o()},handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":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":t._constructed||(t.preventDefault(),t.stopPropagation())}}},n.prototype={handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t)}},destroy:function(){this.options.interactive&&(h.removeEvent(this.indicator,"touchstart",this),h.removeEvent(this.indicator,"MSPointerDown",this),h.removeEvent(this.indicator,"mousedown",this),h.removeEvent(t,"touchmove",this),h.removeEvent(t,"MSPointerMove",this),h.removeEvent(t,"mousemove",this),h.removeEvent(t,"touchend",this),h.removeEvent(t,"MSPointerUp",this),h.removeEvent(t,"mouseup",this)),this.options.defaultScrollbars&&this.wrapper.parentNode.removeChild(this.wrapper)},_start:function(i){var s=i.touches?i.touches[0]:i;i.preventDefault(),i.stopPropagation(),this.transitionTime(),this.initiated=!0,this.moved=!1,this.lastPointX=s.pageX,this.lastPointY=s.pageY,this.startTime=h.getTime(),this.options.disableTouch||h.addEvent(t,"touchmove",this),this.options.disablePointer||h.addEvent(t,"MSPointerMove",this),this.options.disableMouse||h.addEvent(t,"mousemove",this),this.scroller._execEvent("beforeScrollStart")},_move:function(t){{var i,s,e,o,n=t.touches?t.touches[0]:t;h.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),t.preventDefault(),t.stopPropagation()},_end:function(i){if(this.initiated){if(this.initiated=!1,i.preventDefault(),i.stopPropagation(),h.removeEvent(t,"touchmove",this),h.removeEvent(t,"MSPointerMove",this),h.removeEvent(t,"mousemove",this),this.scroller.options.snap){var e=this.scroller._nearestSnap(this.scroller.x,this.scroller.y),o=this.options.snapSpeed||s.max(s.max(s.min(s.abs(this.scroller.x-e.x),1e3),s.min(s.abs(this.scroller.y-e.y),1e3)),300);(this.scroller.x!=e.x||this.scroller.y!=e.y)&&(this.scroller.directionX=0,this.scroller.directionY=0,this.scroller.currentPage=e,this.scroller.scrollTo(e.x,e.y,o,this.scroller.options.bounceEasing))}this.moved&&this.scroller._execEvent("scrollEnd")}},transitionTime:function(t){t=t||0,this.indicatorStyle[h.style.transitionDuration]=t+"ms",!t&&h.isBadAndroid&&(this.indicatorStyle[h.style.transitionDuration]="0.001s")},transitionTimingFunction:function(t){this.indicatorStyle[h.style.transitionTimingFunction]=t},refresh:function(){this.transitionTime(),this.indicatorStyle.display=this.options.listenX&&!this.options.listenY?this.scroller.hasHorizontalScroll?"block":"none":this.options.listenY&&!this.options.listenX?this.scroller.hasVerticalScroll?"block":"none":this.scroller.hasHorizontalScroll||this.scroller.hasVerticalScroll?"block":"none",this.scroller.hasHorizontalScroll&&this.scroller.hasVerticalScroll?(h.addClass(this.wrapper,"iScrollBothScrollbars"),h.removeClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&this.options.customStyle&&(this.options.listenX?this.wrapper.style.right="8px":this.wrapper.style.bottom="8px")):(h.removeClass(this.wrapper,"iScrollBothScrollbars"),h.addClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&this.options.customStyle&&(this.options.listenX?this.wrapper.style.right="2px":this.wrapper.style.bottom="2px"));this.wrapper.offsetHeight;this.options.listenX&&(this.wrapperWidth=this.wrapper.clientWidth,this.options.resize?(this.indicatorWidth=s.max(s.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=-this.indicatorWidth+8,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=s.max(s.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=-this.indicatorHeight+8,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&&s.round(this.sizeRatioX*this.scroller.x)||0,i=this.options.listenY&&s.round(this.sizeRatioY*this.scroller.y)||0;this.options.ignoreBoundaries||(t<this.minBoundaryX?("scale"==this.options.shrink&&(this.width=s.max(this.indicatorWidth+t,8),this.indicatorStyle.width=this.width+"px"),t=this.minBoundaryX):t>this.maxBoundaryX?"scale"==this.options.shrink?(this.width=s.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=s.max(this.indicatorHeight+3*i,8),this.indicatorStyle.height=this.height+"px"),i=this.minBoundaryY):i>this.maxBoundaryY?"scale"==this.options.shrink?(this.height=s.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[h.style.transform]="translate("+t+"px,"+i+"px)"+this.scroller.translateZ:(this.indicatorStyle.left=t+"px",this.indicatorStyle.top=i+"px")},_pos:function(t,i){0>t?t=0:t>this.maxPosX&&(t=this.maxPosX),0>i?i=0:i>this.maxPosY&&(i=this.maxPosY),t=this.options.listenX?s.round(t/this.sizeRatioX):this.scroller.x,i=this.options.listenY?s.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[h.style.transitionDuration]=s+"ms",this.fadeTimeout=setTimeout(function(t){this.wrapperStyle.opacity=t,this.visible=+t}.bind(this,t),e)}}},e.utils=h,"undefined"!=typeof module&&module.exports?module.exports=e:t.IScroll=e}(window,document,Math);
No newline at the end of the file
deleted dist/iscroll-probe-min.js +0 −2
@@ -1,2 +0,0 @@
1-/*! iScroll v5.0.9 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
2-!function(t,i,s){function e(t,s){this.wrapper="string"==typeof t?i.querySelector(t):t,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={resizeIndicator:!0,mouseWheelSpeed:20,snapThreshold:.334,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};for(var e in s)this.options[e]=s[e];this.translateZ=this.options.HWCompositing&&h.hasPerspective?" translateZ(0)":"",this.options.useTransition=h.hasTransition&&this.options.useTransition,this.options.useTransform=h.hasTransform&&this.options.useTransform,this.options.eventPassthrough=this.options.eventPassthrough===!0?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"==this.options.eventPassthrough?!1:this.options.scrollY,this.options.scrollX="horizontal"==this.options.eventPassthrough?!1: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?h.ease[this.options.bounceEasing]||h.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,this.options.tap===!0&&(this.options.tap="tap"),"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 o(t,s,e){var o=i.createElement("div"),n=i.createElement("div");return e===!0&&(o.style.cssText="position:absolute;z-index:9999",n.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"),n.className="iScrollIndicator","h"==t?(e===!0&&(o.style.cssText+=";height:7px;left:2px;right:2px;bottom:0",n.style.height="100%"),o.className="iScrollHorizontalScrollbar"):(e===!0&&(o.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px",n.style.width="100%"),o.className="iScrollVerticalScrollbar"),o.style.cssText+=";overflow:hidden",s||(o.style.pointerEvents="none"),o.appendChild(n),o}function n(s,e){this.wrapper="string"==typeof e.el?i.querySelector(e.el):e.el,this.wrapperStyle=this.wrapper.style,this.indicator=this.wrapper.children[0],this.indicatorStyle=this.indicator.style,this.scroller=s,this.options={listenX:!0,listenY:!0,interactive:!1,resize:!0,defaultScrollbars:!1,shrink:!1,fade:!1,speedRatioX:0,speedRatioY:0};for(var o in e)this.options[o]=e[o];this.sizeRatioX=1,this.sizeRatioY=1,this.maxPosX=0,this.maxPosY=0,this.options.interactive&&(this.options.disableTouch||(h.addEvent(this.indicator,"touchstart",this),h.addEvent(t,"touchend",this)),this.options.disablePointer||(h.addEvent(this.indicator,"MSPointerDown",this),h.addEvent(t,"MSPointerUp",this)),this.options.disableMouse||(h.addEvent(this.indicator,"mousedown",this),h.addEvent(t,"mouseup",this))),this.options.fade&&(this.wrapperStyle[h.style.transform]=this.scroller.translateZ,this.wrapperStyle[h.style.transitionDuration]=h.isBadAndroid?"0.001s":"0ms",this.wrapperStyle.opacity="0")}var r=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(i){t.setTimeout(i,1e3/60)},h=function(){function e(t){return r===!1?!1:""===r?t:r+t.charAt(0).toUpperCase()+t.substr(1)}var o={},n=i.createElement("div").style,r=function(){for(var t,i=["t","webkitT","MozT","msT","OT"],s=0,e=i.length;e>s;s++)if(t=i[s]+"ransform",t in n)return i[s].substr(0,i[s].length-1);return!1}();o.getTime=Date.now||function(){return(new Date).getTime()},o.extend=function(t,i){for(var s in i)t[s]=i[s]},o.addEvent=function(t,i,s,e){t.addEventListener(i,s,!!e)},o.removeEvent=function(t,i,s,e){t.removeEventListener(i,s,!!e)},o.momentum=function(t,i,e,o,n){var r,h,a=t-i,l=s.abs(a)/e,c=6e-4;return r=t+l*l/(2*c)*(0>a?-1:1),h=l/c,o>r?(r=n?o-n/2.5*(l/8):o,a=s.abs(r-t),h=a/l):r>0&&(r=n?n/2.5*(l/8):0,a=s.abs(t)+r,h=a/l),{destination:s.round(r),duration:h}};var h=e("transform");return o.extend(o,{hasTransform:h!==!1,hasPerspective:e("perspective")in n,hasTouch:"ontouchstart"in t,hasPointer:navigator.msPointerEnabled,hasTransition:e("transition")in n}),o.isBadAndroid=/Android/.test(t.navigator.appVersion)&&!/Chrome\/\d/.test(t.navigator.appVersion),o.extend(o.style={},{transform:h,transitionTimingFunction:e("transitionTimingFunction"),transitionDuration:e("transitionDuration"),transitionDelay:e("transitionDelay"),transformOrigin:e("transformOrigin")}),o.hasClass=function(t,i){var s=new RegExp("(^|\\s)"+i+"(\\s|$)");return s.test(t.className)},o.addClass=function(t,i){if(!o.hasClass(t,i)){var s=t.className.split(" ");s.push(i),t.className=s.join(" ")}},o.removeClass=function(t,i){if(o.hasClass(t,i)){var s=new RegExp("(^|\\s)"+i+"(\\s|$)","g");t.className=t.className.replace(s," ")}},o.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}},o.preventDefaultException=function(t,i){for(var s in i)if(i[s].test(t[s]))return!0;return!1},o.extend(o.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),o.extend(o.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 s.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){var i=4;return(t-=1)*t*((i+1)*t+i)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){var i=.22,e=.4;return 0===t?0:1==t?1:e*s.pow(2,-10*t)*s.sin(2*(t-i/4)*s.PI/i)+1}}}),o.tap=function(t,s){var e=i.createEvent("Event");e.initEvent(s,!0,!0),e.pageX=t.pageX,e.pageY=t.pageY,t.target.dispatchEvent(e)},o.click=function(t){var s,e=t.target;"SELECT"!=e.tagName&&"INPUT"!=e.tagName&&"TEXTAREA"!=e.tagName&&(s=i.createEvent("MouseEvents"),s.initMouseEvent("click",!0,!0,t.view,1,e.screenX,e.screenY,e.clientX,e.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,null),s._constructed=!0,e.dispatchEvent(s))},o}();e.prototype={version:"5.0.9",_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),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!=h.eventType[t.type]&&0!==t.button||!this.enabled||this.initiated&&h.eventType[t.type]!==this.initiated)){!this.options.preventDefault||h.isBadAndroid||h.preventDefaultException(t.target,this.options.preventDefaultException)||t.preventDefault();var i,e=t.touches?t.touches[0]:t;this.initiated=h.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this._transitionTime(),this.startTime=h.getTime(),this.options.useTransition&&this.isInTransition?(this.isInTransition=!1,i=this.getComputedPosition(),this._translate(s.round(i.x),s.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=e.pageX,this.pointY=e.pageY,this._execEvent("beforeScrollStart")}},_move:function(t){if(this.enabled&&h.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o,n,r=t.touches?t.touches[0]:t,a=r.pageX-this.pointX,l=r.pageY-this.pointY,c=h.getTime();if(this.pointX=r.pageX,this.pointY=r.pageY,this.distX+=a,this.distY+=l,o=s.abs(this.distX),n=s.abs(this.distY),!(c-this.endTime>300&&10>o&&10>n)){if(this.directionLocked||this.options.freeScroll||(this.directionLocked=o>n+this.options.directionLockThreshold?"h":n>=o+this.options.directionLockThreshold?"v":"n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return this.initiated=!1,void 0;l=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return this.initiated=!1,void 0;a=0}a=this.hasHorizontalScroll?a:0,l=this.hasVerticalScroll?l:0,i=this.x+a,e=this.y+l,(i>0||i<this.maxScrollX)&&(i=this.options.bounce?this.x+a/3:i>0?0:this.maxScrollX),(e>0||e<this.maxScrollY)&&(e=this.options.bounce?this.y+l/3:e>0?0:this.maxScrollY),this.directionX=a>0?-1:0>a?1:0,this.directionY=l>0?-1:0>l?1:0,this.moved||this._execEvent("scrollStart"),this.moved=!0,this._translate(i,e),c-this.startTime>300&&(this.startTime=c,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&&h.eventType[t.type]===this.initiated){this.options.preventDefault&&!h.preventDefaultException(t.target,this.options.preventDefaultException)&&t.preventDefault();var i,e,o=(t.changedTouches?t.changedTouches[0]:t,h.getTime()-this.startTime),n=s.round(this.x),r=s.round(this.y),a=s.abs(n-this.startX),l=s.abs(r-this.startY),c=0,p="";if(this.isInTransition=0,this.initiated=0,this.endTime=h.getTime(),!this.resetPosition(this.options.bounceTime)){if(this.scrollTo(n,r),!this.moved)return this.options.tap&&h.tap(t,this.options.tap),this.options.click&&h.click(t),this._execEvent("scrollCancel"),void 0;if(this._events.flick&&200>o&&100>a&&100>l)return this._execEvent("flick"),void 0;if(this.options.momentum&&300>o&&(i=this.hasHorizontalScroll?h.momentum(this.x,this.startX,o,this.maxScrollX,this.options.bounce?this.wrapperWidth:0):{destination:n,duration:0},e=this.hasVerticalScroll?h.momentum(this.y,this.startY,o,this.maxScrollY,this.options.bounce?this.wrapperHeight:0):{destination:r,duration:0},n=i.destination,r=e.destination,c=s.max(i.duration,e.duration),this.isInTransition=1),this.options.snap){var d=this._nearestSnap(n,r);this.currentPage=d,c=this.options.snapSpeed||s.max(s.max(s.min(s.abs(n-d.x),1e3),s.min(s.abs(r-d.y),1e3)),300),n=d.x,r=d.y,this.directionX=0,this.directionY=0,p=this.options.bounceEasing}return n!=this.x||r!=this.y?((n>0||n<this.maxScrollX||r>0||r<this.maxScrollY)&&(p=h.ease.quadratic),this.scrollTo(n,r,c,p),void 0):(this._execEvent("scrollEnd"),void 0)}}},_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;return 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?!1:(this.scrollTo(i,s,t,this.options.bounceEasing),!0)},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){this.wrapper.offsetHeight;this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight,this.scrollerWidth=this.scroller.offsetWidth,this.scrollerHeight=this.scroller.offsetHeight,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,this.wrapperOffset=h.offset(this.wrapper),this._execEvent("refresh"),this.resetPosition()},on:function(t,i){this._events[t]||(this._events[t]=[]),this._events[t].push(i)},_execEvent:function(t){if(this._events[t]){var i=0,s=this._events[t].length;if(s)for(;s>i;i++)this._events[t][i].call(this)}},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||h.ease.circular,this.isInTransition=this.options.useTransition&&s>0,!s||this.options.useTransition&&e.style?(this._transitionTimingFunction(e.style),this._transitionTime(s),this._translate(t,i)):this._animate(t,i,s,e.fn)},scrollToElement:function(t,i,e,o,n){if(t=t.nodeType?t:this.scroller.querySelector(t)){var r=h.offset(t);r.left-=this.wrapperOffset.left,r.top-=this.wrapperOffset.top,e===!0&&(e=s.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),o===!0&&(o=s.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),r.left-=e||0,r.top-=o||0,r.left=r.left>0?0:r.left<this.maxScrollX?this.maxScrollX:r.left,r.top=r.top>0?0:r.top<this.maxScrollY?this.maxScrollY:r.top,i=void 0===i||null===i||"auto"===i?s.max(s.abs(this.x-r.left),s.abs(this.y-r.top)):i,this.scrollTo(r.left,r.top,i,n)}},_transitionTime:function(t){if(t=t||0,this.scrollerStyle[h.style.transitionDuration]=t+"ms",!t&&h.isBadAndroid&&(this.scrollerStyle[h.style.transitionDuration]="0.001s"),this.indicators)for(var i=this.indicators.length;i--;)this.indicators[i].transitionTime(t)},_transitionTimingFunction:function(t){if(this.scrollerStyle[h.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[h.style.transform]="translate("+t+"px,"+i+"px)"+this.translateZ:(t=s.round(t),i=s.round(i),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=i+"px"),this.x=t,this.y=i,this.indicators)for(var e=this.indicators.length;e--;)this.indicators[e].updatePosition()},_initEvents:function(i){var s=i?h.removeEvent:h.addEvent,e=this.options.bindToWrapper?this.wrapper:t;s(t,"orientationchange",this),s(t,"resize",this),this.options.click&&s(this.wrapper,"click",this,!0),this.options.disableMouse||(s(this.wrapper,"mousedown",this),s(e,"mousemove",this),s(e,"mousecancel",this),s(e,"mouseup",this)),h.hasPointer&&!this.options.disablePointer&&(s(this.wrapper,"MSPointerDown",this),s(e,"MSPointerMove",this),s(e,"MSPointerCancel",this),s(e,"MSPointerUp",this)),h.hasTouch&&!this.options.disableTouch&&(s(this.wrapper,"touchstart",this),s(e,"touchmove",this),s(e,"touchcancel",this),s(e,"touchend",this)),s(this.scroller,"transitionend",this),s(this.scroller,"webkitTransitionEnd",this),s(this.scroller,"oTransitionEnd",this),s(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var i,s,e=t.getComputedStyle(this.scroller,null);return this.options.useTransform?(e=e[h.style.transform].split(")")[0].split(", "),i=+(e[12]||e[4]),s=+(e[13]||e[5])):(i=+e.left.replace(/[^-\d.]/g,""),s=+e.top.replace(/[^-\d.]/g,"")),{x:i,y:s}},_initIndicators:function(){function t(t){for(var i=h.indicators.length;i--;)t.call(h.indicators[i])}var i,s=this.options.interactiveScrollbars,e=("object"!=typeof this.options.scrollbars,"string"!=typeof this.options.scrollbars),r=[],h=this;this.indicators=[],this.options.scrollbars&&(this.options.scrollY&&(i={el:o("v",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,customStyle:e,resize:this.options.resizeIndicator,shrink:this.options.shrinkScrollbars,fade:this.options.fadeScrollbars,listenX:!1},this.wrapper.appendChild(i.el),r.push(i)),this.options.scrollX&&(i={el:o("h",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,customStyle:e,resize:this.options.resizeIndicator,shrink:this.options.shrinkScrollbars,fade:this.options.fadeScrollbars,listenY:!1},this.wrapper.appendChild(i.el),r.push(i))),this.options.indicators&&(r=r.concat(this.options.indicators));for(var a=r.length;a--;)this.indicators.push(new n(this,r[a]));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(){h.addEvent(this.wrapper,"wheel",this),h.addEvent(this.wrapper,"mousewheel",this),h.addEvent(this.wrapper,"DOMMouseScroll",this),this.on("destroy",function(){h.removeEvent(this.wrapper,"wheel",this),h.removeEvent(this.wrapper,"mousewheel",this),h.removeEvent(this.wrapper,"DOMMouseScroll",this)})},_wheel:function(t){if(this.enabled){t.preventDefault(),t.stopPropagation();var i,e,o,n,r=this;if(void 0===this.wheelTimeout&&r._execEvent("scrollStart"),clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout(function(){r._execEvent("scrollEnd"),r.wheelTimeout=void 0},400),"deltaX"in t)i=-t.deltaX,e=-t.deltaY;else if("wheelDeltaX"in t)i=t.wheelDeltaX/120*this.options.mouseWheelSpeed,e=t.wheelDeltaY/120*this.options.mouseWheelSpeed;else if("wheelDelta"in t)i=e=t.wheelDelta/120*this.options.mouseWheelSpeed;else{if(!("detail"in t))return;i=e=-t.detail/3*this.options.mouseWheelSpeed}if(i*=this.options.invertWheelDirection,e*=this.options.invertWheelDirection,this.hasVerticalScroll||(i=e,e=0),this.options.snap)return o=this.currentPage.pageX,n=this.currentPage.pageY,i>0?o--:0>i&&o++,e>0?n--:0>e&&n++,this.goToPage(o,n),void 0;o=this.x+s.round(this.hasHorizontalScroll?i:0),n=this.y+s.round(this.hasVerticalScroll?e:0),o>0?o=0:o<this.maxScrollX&&(o=this.maxScrollX),n>0?n=0:n<this.maxScrollY&&(n=this.maxScrollY),this.scrollTo(o,n,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,e,o,n,r,h=0,a=0,l=0,c=this.options.snapStepX||this.wrapperWidth,p=this.options.snapStepY||this.wrapperHeight;if(this.pages=[],this.wrapperWidth&&this.wrapperHeight&&this.scrollerWidth&&this.scrollerHeight){if(this.options.snap===!0)for(e=s.round(c/2),o=s.round(p/2);l>-this.scrollerWidth;){for(this.pages[h]=[],t=0,n=0;n>-this.scrollerHeight;)this.pages[h][t]={x:s.max(l,this.maxScrollX),y:s.max(n,this.maxScrollY),width:c,height:p,cx:l-e,cy:n-o},n-=p,t++;l-=c,h++}else for(r=this.options.snap,t=r.length,i=-1;t>h;h++)(0===h||r[h].offsetLeft<=r[h-1].offsetLeft)&&(a=0,i++),this.pages[a]||(this.pages[a]=[]),l=s.max(-r[h].offsetLeft,this.maxScrollX),n=s.max(-r[h].offsetTop,this.maxScrollY),e=l-s.round(r[h].offsetWidth/2),o=n-s.round(r[h].offsetHeight/2),this.pages[a][i]={x:l,y:n,width:r[h].offsetWidth,height:r[h].offsetHeight,cx:e,cy:o},l>this.maxScrollX&&a++;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=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*this.options.snapThreshold),this.snapThresholdY=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold))}}),this.on("flick",function(){var t=this.options.snapSpeed||s.max(s.max(s.min(s.abs(this.x-this.startX),1e3),s.min(s.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 e=0,o=this.pages.length,n=0;if(s.abs(t-this.absStartX)<this.snapThresholdX&&s.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);o>e;e++)if(t>=this.pages[e][0].cx){t=this.pages[e][0].x;break}for(o=this.pages[e].length;o>n;n++)if(i>=this.pages[0][n].cy){i=this.pages[0][n].y;break}return e==this.currentPage.pageX&&(e+=this.directionX,0>e?e=0:e>=this.pages.length&&(e=this.pages.length-1),t=this.pages[e][0].x),n==this.currentPage.pageY&&(n+=this.directionY,0>n?n=0:n>=this.pages[0].length&&(n=this.pages[0].length-1),i=this.pages[0][n].y),{x:t,y:i,pageX:e,pageY:n}},goToPage:function(t,i,e,o){o=o||this.options.bounceEasing,t>=this.pages.length?t=this.pages.length-1:0>t&&(t=0),i>=this.pages[t].length?i=this.pages[t].length-1:0>i&&(i=0);var n=this.pages[t][i].x,r=this.pages[t][i].y;e=void 0===e?this.options.snapSpeed||s.max(s.max(s.min(s.abs(n-this.x),1e3),s.min(s.abs(r-this.y),1e3)),300):e,this.currentPage={x:n,y:r,pageX:t,pageY:i},this.scrollTo(n,r,e,o)},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--,0>s&&this.hasVerticalScroll&&(s=0,e--),this.goToPage(s,e,t,i)},_initKeys:function(){var i,s={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40};if("object"==typeof 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];h.addEvent(t,"keydown",this),this.on("destroy",function(){h.removeEvent(t,"keydown",this)})},_key:function(t){if(this.enabled){var i,e=this.options.snap,o=e?this.currentPage.pageX:this.x,n=e?this.currentPage.pageY:this.y,r=h.getTime(),a=this.keyTime||0,l=.25;switch(this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.keyAcceleration=200>r-a?s.min(this.keyAcceleration+l,50):0,t.keyCode){case this.options.keyBindings.pageUp:this.hasHorizontalScroll&&!this.hasVerticalScroll?o+=e?1:this.wrapperWidth:n+=e?1:this.wrapperHeight;break;case this.options.keyBindings.pageDown:this.hasHorizontalScroll&&!this.hasVerticalScroll?o-=e?1:this.wrapperWidth:n-=e?1:this.wrapperHeight;break;case this.options.keyBindings.end:o=e?this.pages.length-1:this.maxScrollX,n=e?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:o=0,n=0;break;case this.options.keyBindings.left:o+=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.up:n+=e?1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.right:o-=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.down:n-=e?1:5+this.keyAcceleration>>0;break;default:return}if(e)return this.goToPage(o,n),void 0;o>0?(o=0,this.keyAcceleration=0):o<this.maxScrollX&&(o=this.maxScrollX,this.keyAcceleration=0),n>0?(n=0,this.keyAcceleration=0):n<this.maxScrollY&&(n=this.maxScrollY,this.keyAcceleration=0),this.scrollTo(o,n,0),this.keyTime=r}},_animate:function(t,i,s,e){function o(){var d,u,m,f=h.getTime();return f>=p?(n.isAnimating=!1,n._translate(t,i),n.resetPosition(n.options.bounceTime)||n._execEvent("scrollEnd"),void 0):(f=(f-c)/s,m=e(f),d=(t-a)*m+a,u=(i-l)*m+l,n._translate(d,u),n.isAnimating&&r(o),3==n.options.probeType&&n._execEvent("scroll"),void 0)}var n=this,a=this.x,l=this.y,c=h.getTime(),p=c+s;this.isAnimating=!0,o()},handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":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":t._constructed||(t.preventDefault(),t.stopPropagation())}}},n.prototype={handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t)}},destroy:function(){this.options.interactive&&(h.removeEvent(this.indicator,"touchstart",this),h.removeEvent(this.indicator,"MSPointerDown",this),h.removeEvent(this.indicator,"mousedown",this),h.removeEvent(t,"touchmove",this),h.removeEvent(t,"MSPointerMove",this),h.removeEvent(t,"mousemove",this),h.removeEvent(t,"touchend",this),h.removeEvent(t,"MSPointerUp",this),h.removeEvent(t,"mouseup",this)),this.options.defaultScrollbars&&this.wrapper.parentNode.removeChild(this.wrapper)},_start:function(i){var s=i.touches?i.touches[0]:i;i.preventDefault(),i.stopPropagation(),this.transitionTime(),this.initiated=!0,this.moved=!1,this.lastPointX=s.pageX,this.lastPointY=s.pageY,this.startTime=h.getTime(),this.options.disableTouch||h.addEvent(t,"touchmove",this),this.options.disablePointer||h.addEvent(t,"MSPointerMove",this),this.options.disableMouse||h.addEvent(t,"mousemove",this),this.scroller._execEvent("beforeScrollStart")},_move:function(t){var i,s,e,o,n=t.touches?t.touches[0]:t,r=h.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(i){if(this.initiated){if(this.initiated=!1,i.preventDefault(),i.stopPropagation(),h.removeEvent(t,"touchmove",this),h.removeEvent(t,"MSPointerMove",this),h.removeEvent(t,"mousemove",this),this.scroller.options.snap){var e=this.scroller._nearestSnap(this.scroller.x,this.scroller.y),o=this.options.snapSpeed||s.max(s.max(s.min(s.abs(this.scroller.x-e.x),1e3),s.min(s.abs(this.scroller.y-e.y),1e3)),300);(this.scroller.x!=e.x||this.scroller.y!=e.y)&&(this.scroller.directionX=0,this.scroller.directionY=0,this.scroller.currentPage=e,this.scroller.scrollTo(e.x,e.y,o,this.scroller.options.bounceEasing))}this.moved&&this.scroller._execEvent("scrollEnd")}},transitionTime:function(t){t=t||0,this.indicatorStyle[h.style.transitionDuration]=t+"ms",!t&&h.isBadAndroid&&(this.indicatorStyle[h.style.transitionDuration]="0.001s")},transitionTimingFunction:function(t){this.indicatorStyle[h.style.transitionTimingFunction]=t},refresh:function(){this.transitionTime(),this.indicatorStyle.display=this.options.listenX&&!this.options.listenY?this.scroller.hasHorizontalScroll?"block":"none":this.options.listenY&&!this.options.listenX?this.scroller.hasVerticalScroll?"block":"none":this.scroller.hasHorizontalScroll||this.scroller.hasVerticalScroll?"block":"none",this.scroller.hasHorizontalScroll&&this.scroller.hasVerticalScroll?(h.addClass(this.wrapper,"iScrollBothScrollbars"),h.removeClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&this.options.customStyle&&(this.options.listenX?this.wrapper.style.right="8px":this.wrapper.style.bottom="8px")):(h.removeClass(this.wrapper,"iScrollBothScrollbars"),h.addClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&this.options.customStyle&&(this.options.listenX?this.wrapper.style.right="2px":this.wrapper.style.bottom="2px"));this.wrapper.offsetHeight;this.options.listenX&&(this.wrapperWidth=this.wrapper.clientWidth,this.options.resize?(this.indicatorWidth=s.max(s.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=-this.indicatorWidth+8,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=s.max(s.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=-this.indicatorHeight+8,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&&s.round(this.sizeRatioX*this.scroller.x)||0,i=this.options.listenY&&s.round(this.sizeRatioY*this.scroller.y)||0;this.options.ignoreBoundaries||(t<this.minBoundaryX?("scale"==this.options.shrink&&(this.width=s.max(this.indicatorWidth+t,8),this.indicatorStyle.width=this.width+"px"),t=this.minBoundaryX):t>this.maxBoundaryX?"scale"==this.options.shrink?(this.width=s.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=s.max(this.indicatorHeight+3*i,8),this.indicatorStyle.height=this.height+"px"),i=this.minBoundaryY):i>this.maxBoundaryY?"scale"==this.options.shrink?(this.height=s.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[h.style.transform]="translate("+t+"px,"+i+"px)"+this.scroller.translateZ:(this.indicatorStyle.left=t+"px",this.indicatorStyle.top=i+"px")},_pos:function(t,i){0>t?t=0:t>this.maxPosX&&(t=this.maxPosX),0>i?i=0:i>this.maxPosY&&(i=this.maxPosY),t=this.options.listenX?s.round(t/this.sizeRatioX):this.scroller.x,i=this.options.listenY?s.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[h.style.transitionDuration]=s+"ms",this.fadeTimeout=setTimeout(function(t){this.wrapperStyle.opacity=t,this.visible=+t}.bind(this,t),e)}}},e.utils=h,"undefined"!=typeof module&&module.exports?module.exports=e:t.IScroll=e}(window,document,Math);
No newline at the end of the file
deleted dist/iscroll-zoom-min.js +0 −3
@@ -1,3 +0,0 @@
1-/*! iScroll v5.0.9 ~ (c) 2008-2013 Matteo Spinelli ~ http://cubiq.org/license */
2-!function(t,i,s){function e(t,e){this.wrapper="string"==typeof t?i.querySelector(t):t,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={zoomMin:1,zoomMax:4,startZoom:1,resizeIndicator:!0,mouseWheelSpeed:20,snapThreshold:.334,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};for(var o in e)this.options[o]=e[o];this.translateZ=this.options.HWCompositing&&r.hasPerspective?" translateZ(0)":"",this.options.useTransition=r.hasTransition&&this.options.useTransition,this.options.useTransform=r.hasTransform&&this.options.useTransform,this.options.eventPassthrough=this.options.eventPassthrough===!0?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"==this.options.eventPassthrough?!1:this.options.scrollY,this.options.scrollX="horizontal"==this.options.eventPassthrough?!1: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?r.ease[this.options.bounceEasing]||r.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,this.options.tap===!0&&(this.options.tap="tap"),"scale"==this.options.shrinkScrollbars&&(this.options.useTransition=!1),this.options.invertWheelDirection=this.options.invertWheelDirection?-1:1,this.x=0,this.y=0,this.directionX=0,this.directionY=0,this._events={},this.scale=s.min(s.max(this.options.startZoom,this.options.zoomMin),this.options.zoomMax),this._init(),this.refresh(),this.scrollTo(this.options.startX,this.options.startY),this.enable()}function o(t,s,e){var o=i.createElement("div"),n=i.createElement("div");return e===!0&&(o.style.cssText="position:absolute;z-index:9999",n.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"),n.className="iScrollIndicator","h"==t?(e===!0&&(o.style.cssText+=";height:7px;left:2px;right:2px;bottom:0",n.style.height="100%"),o.className="iScrollHorizontalScrollbar"):(e===!0&&(o.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px",n.style.width="100%"),o.className="iScrollVerticalScrollbar"),o.style.cssText+=";overflow:hidden",s||(o.style.pointerEvents="none"),o.appendChild(n),o}function n(s,e){this.wrapper="string"==typeof e.el?i.querySelector(e.el):e.el,this.wrapperStyle=this.wrapper.style,this.indicator=this.wrapper.children[0],this.indicatorStyle=this.indicator.style,this.scroller=s,this.options={listenX:!0,listenY:!0,interactive:!1,resize:!0,defaultScrollbars:!1,shrink:!1,fade:!1,speedRatioX:0,speedRatioY:0};for(var o in e)this.options[o]=e[o];this.sizeRatioX=1,this.sizeRatioY=1,this.maxPosX=0,this.maxPosY=0,this.options.interactive&&(this.options.disableTouch||(r.addEvent(this.indicator,"touchstart",this),r.addEvent(t,"touchend",this)),this.options.disablePointer||(r.addEvent(this.indicator,"MSPointerDown",this),r.addEvent(t,"MSPointerUp",this)),this.options.disableMouse||(r.addEvent(this.indicator,"mousedown",this),r.addEvent(t,"mouseup",this))),this.options.fade&&(this.wrapperStyle[r.style.transform]=this.scroller.translateZ,this.wrapperStyle[r.style.transitionDuration]=r.isBadAndroid?"0.001s":"0ms",this.wrapperStyle.opacity="0")}var h=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(i){t.setTimeout(i,1e3/60)},r=function(){function e(t){return h===!1?!1:""===h?t:h+t.charAt(0).toUpperCase()+t.substr(1)}var o={},n=i.createElement("div").style,h=function(){for(var t,i=["t","webkitT","MozT","msT","OT"],s=0,e=i.length;e>s;s++)if(t=i[s]+"ransform",t in n)return i[s].substr(0,i[s].length-1);return!1}();o.getTime=Date.now||function(){return(new Date).getTime()},o.extend=function(t,i){for(var s in i)t[s]=i[s]},o.addEvent=function(t,i,s,e){t.addEventListener(i,s,!!e)},o.removeEvent=function(t,i,s,e){t.removeEventListener(i,s,!!e)},o.momentum=function(t,i,e,o,n){var h,r,a=t-i,l=s.abs(a)/e,c=6e-4;return h=t+l*l/(2*c)*(0>a?-1:1),r=l/c,o>h?(h=n?o-n/2.5*(l/8):o,a=s.abs(h-t),r=a/l):h>0&&(h=n?n/2.5*(l/8):0,a=s.abs(t)+h,r=a/l),{destination:s.round(h),duration:r}};var r=e("transform");return o.extend(o,{hasTransform:r!==!1,hasPerspective:e("perspective")in n,hasTouch:"ontouchstart"in t,hasPointer:navigator.msPointerEnabled,hasTransition:e("transition")in n}),o.isBadAndroid=/Android/.test(t.navigator.appVersion)&&!/Chrome\/\d/.test(t.navigator.appVersion),o.extend(o.style={},{transform:r,transitionTimingFunction:e("transitionTimingFunction"),transitionDuration:e("transitionDuration"),transitionDelay:e("transitionDelay"),transformOrigin:e("transformOrigin")}),o.hasClass=function(t,i){var s=new RegExp("(^|\\s)"+i+"(\\s|$)");return s.test(t.className)},o.addClass=function(t,i){if(!o.hasClass(t,i)){var s=t.className.split(" ");s.push(i),t.className=s.join(" ")}},o.removeClass=function(t,i){if(o.hasClass(t,i)){var s=new RegExp("(^|\\s)"+i+"(\\s|$)","g");t.className=t.className.replace(s," ")}},o.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}},o.preventDefaultException=function(t,i){for(var s in i)if(i[s].test(t[s]))return!0;return!1},o.extend(o.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),o.extend(o.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 s.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){var i=4;return(t-=1)*t*((i+1)*t+i)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){var i=.22,e=.4;return 0===t?0:1==t?1:e*s.pow(2,-10*t)*s.sin(2*(t-i/4)*s.PI/i)+1}}}),o.tap=function(t,s){var e=i.createEvent("Event");e.initEvent(s,!0,!0),e.pageX=t.pageX,e.pageY=t.pageY,t.target.dispatchEvent(e)},o.click=function(t){var s,e=t.target;"SELECT"!=e.tagName&&"INPUT"!=e.tagName&&"TEXTAREA"!=e.tagName&&(s=i.createEvent("MouseEvents"),s.initMouseEvent("click",!0,!0,t.view,1,e.screenX,e.screenY,e.clientX,e.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,null),s._constructed=!0,e.dispatchEvent(s))},o}();e.prototype={version:"5.0.9",_init:function(){this._initEvents(),this.options.zoom&&this._initZoom(),(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),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!=r.eventType[t.type]&&0!==t.button||!this.enabled||this.initiated&&r.eventType[t.type]!==this.initiated)){!this.options.preventDefault||r.isBadAndroid||r.preventDefaultException(t.target,this.options.preventDefaultException)||t.preventDefault();var i,e=t.touches?t.touches[0]:t;this.initiated=r.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this._transitionTime(),this.startTime=r.getTime(),this.options.useTransition&&this.isInTransition?(this.isInTransition=!1,i=this.getComputedPosition(),this._translate(s.round(i.x),s.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=e.pageX,this.pointY=e.pageY,this._execEvent("beforeScrollStart")}},_move:function(t){if(this.enabled&&r.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o,n,h=t.touches?t.touches[0]:t,a=h.pageX-this.pointX,l=h.pageY-this.pointY,c=r.getTime();if(this.pointX=h.pageX,this.pointY=h.pageY,this.distX+=a,this.distY+=l,o=s.abs(this.distX),n=s.abs(this.distY),!(c-this.endTime>300&&10>o&&10>n)){if(this.directionLocked||this.options.freeScroll||(this.directionLocked=o>n+this.options.directionLockThreshold?"h":n>=o+this.options.directionLockThreshold?"v":"n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return this.initiated=!1,void 0;l=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return this.initiated=!1,void 0;a=0}a=this.hasHorizontalScroll?a:0,l=this.hasVerticalScroll?l:0,i=this.x+a,e=this.y+l,(i>0||i<this.maxScrollX)&&(i=this.options.bounce?this.x+a/3:i>0?0:this.maxScrollX),(e>0||e<this.maxScrollY)&&(e=this.options.bounce?this.y+l/3:e>0?0:this.maxScrollY),this.directionX=a>0?-1:0>a?1:0,this.directionY=l>0?-1:0>l?1:0,this.moved||this._execEvent("scrollStart"),this.moved=!0,this._translate(i,e),c-this.startTime>300&&(this.startTime=c,this.startX=this.x,this.startY=this.y)}}},_end:function(t){if(this.enabled&&r.eventType[t.type]===this.initiated){this.options.preventDefault&&!r.preventDefaultException(t.target,this.options.preventDefaultException)&&t.preventDefault();var i,e,o=(t.changedTouches?t.changedTouches[0]:t,r.getTime()-this.startTime),n=s.round(this.x),h=s.round(this.y),a=s.abs(n-this.startX),l=s.abs(h-this.startY),c=0,p="";if(this.isInTransition=0,this.initiated=0,this.endTime=r.getTime(),!this.resetPosition(this.options.bounceTime)){if(this.scrollTo(n,h),!this.moved)return this.options.tap&&r.tap(t,this.options.tap),this.options.click&&r.click(t),this._execEvent("scrollCancel"),void 0;if(this._events.flick&&200>o&&100>a&&100>l)return this._execEvent("flick"),void 0;if(this.options.momentum&&300>o&&(i=this.hasHorizontalScroll?r.momentum(this.x,this.startX,o,this.maxScrollX,this.options.bounce?this.wrapperWidth:0):{destination:n,duration:0},e=this.hasVerticalScroll?r.momentum(this.y,this.startY,o,this.maxScrollY,this.options.bounce?this.wrapperHeight:0):{destination:h,duration:0},n=i.destination,h=e.destination,c=s.max(i.duration,e.duration),this.isInTransition=1),this.options.snap){var d=this._nearestSnap(n,h);this.currentPage=d,c=this.options.snapSpeed||s.max(s.max(s.min(s.abs(n-d.x),1e3),s.min(s.abs(h-d.y),1e3)),300),n=d.x,h=d.y,this.directionX=0,this.directionY=0,p=this.options.bounceEasing}return n!=this.x||h!=this.y?((n>0||n<this.maxScrollX||h>0||h<this.maxScrollY)&&(p=r.ease.quadratic),this.scrollTo(n,h,c,p),void 0):(this._execEvent("scrollEnd"),void 0)}}},_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;return 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?!1:(this.scrollTo(i,s,t,this.options.bounceEasing),!0)},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){this.wrapper.offsetHeight;this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight,this.scrollerWidth=s.round(this.scroller.offsetWidth*this.scale),this.scrollerHeight=s.round(this.scroller.offsetHeight*this.scale),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,this.wrapperOffset=r.offset(this.wrapper),this._execEvent("refresh"),this.resetPosition()},on:function(t,i){this._events[t]||(this._events[t]=[]),this._events[t].push(i)},_execEvent:function(t){if(this._events[t]){var i=0,s=this._events[t].length;if(s)for(;s>i;i++)this._events[t][i].call(this)}},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||r.ease.circular,this.isInTransition=this.options.useTransition&&s>0,!s||this.options.useTransition&&e.style?(this._transitionTimingFunction(e.style),this._transitionTime(s),this._translate(t,i)):this._animate(t,i,s,e.fn)},scrollToElement:function(t,i,e,o,n){if(t=t.nodeType?t:this.scroller.querySelector(t)){var h=r.offset(t);h.left-=this.wrapperOffset.left,h.top-=this.wrapperOffset.top,e===!0&&(e=s.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),o===!0&&(o=s.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),h.left-=e||0,h.top-=o||0,h.left=h.left>0?0:h.left<this.maxScrollX?this.maxScrollX:h.left,h.top=h.top>0?0:h.top<this.maxScrollY?this.maxScrollY:h.top,i=void 0===i||null===i||"auto"===i?s.max(s.abs(this.x-h.left),s.abs(this.y-h.top)):i,this.scrollTo(h.left,h.top,i,n)}},_transitionTime:function(t){if(t=t||0,this.scrollerStyle[r.style.transitionDuration]=t+"ms",!t&&r.isBadAndroid&&(this.scrollerStyle[r.style.transitionDuration]="0.001s"),this.indicators)for(var i=this.indicators.length;i--;)this.indicators[i].transitionTime(t)},_transitionTimingFunction:function(t){if(this.scrollerStyle[r.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[r.style.transform]="translate("+t+"px,"+i+"px) scale("+this.scale+") "+this.translateZ:(t=s.round(t),i=s.round(i),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=i+"px"),this.x=t,this.y=i,this.indicators)for(var e=this.indicators.length;e--;)this.indicators[e].updatePosition()},_initEvents:function(i){var s=i?r.removeEvent:r.addEvent,e=this.options.bindToWrapper?this.wrapper:t;s(t,"orientationchange",this),s(t,"resize",this),this.options.click&&s(this.wrapper,"click",this,!0),this.options.disableMouse||(s(this.wrapper,"mousedown",this),s(e,"mousemove",this),s(e,"mousecancel",this),s(e,"mouseup",this)),r.hasPointer&&!this.options.disablePointer&&(s(this.wrapper,"MSPointerDown",this),s(e,"MSPointerMove",this),s(e,"MSPointerCancel",this),s(e,"MSPointerUp",this)),r.hasTouch&&!this.options.disableTouch&&(s(this.wrapper,"touchstart",this),s(e,"touchmove",this),s(e,"touchcancel",this),s(e,"touchend",this)),s(this.scroller,"transitionend",this),s(this.scroller,"webkitTransitionEnd",this),s(this.scroller,"oTransitionEnd",this),s(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var i,s,e=t.getComputedStyle(this.scroller,null);return this.options.useTransform?(e=e[r.style.transform].split(")")[0].split(", "),i=+(e[12]||e[4]),s=+(e[13]||e[5])):(i=+e.left.replace(/[^-\d.]/g,""),s=+e.top.replace(/[^-\d.]/g,"")),{x:i,y:s}},_initIndicators:function(){function t(t){for(var i=r.indicators.length;i--;)t.call(r.indicators[i])}var i,s=this.options.interactiveScrollbars,e=("object"!=typeof this.options.scrollbars,"string"!=typeof this.options.scrollbars),h=[],r=this;this.indicators=[],this.options.scrollbars&&(this.options.scrollY&&(i={el:o("v",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,customStyle:e,resize:this.options.resizeIndicator,shrink:this.options.shrinkScrollbars,fade:this.options.fadeScrollbars,listenX:!1},this.wrapper.appendChild(i.el),h.push(i)),this.options.scrollX&&(i={el:o("h",s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,customStyle:e,resize:this.options.resizeIndicator,shrink:this.options.shrinkScrollbars,fade:this.options.fadeScrollbars,listenY:!1},this.wrapper.appendChild(i.el),h.push(i))),this.options.indicators&&(h=h.concat(this.options.indicators));for(var a=h.length;a--;)this.indicators.push(new n(this,h[a]));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})},_initZoom:function(){this.scrollerStyle[r.style.transformOrigin]="0 0"},_zoomStart:function(t){var i=s.abs(t.touches[0].pageX-t.touches[1].pageX),e=s.abs(t.touches[0].pageY-t.touches[1].pageY);this.touchesDistanceStart=s.sqrt(i*i+e*e),this.startScale=this.scale,this.originX=s.abs(t.touches[0].pageX+t.touches[1].pageX)/2+this.wrapperOffset.left-this.x,this.originY=s.abs(t.touches[0].pageY+t.touches[1].pageY)/2+this.wrapperOffset.top-this.y,this._execEvent("zoomStart")},_zoom:function(t){if(this.enabled&&r.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,e,o,n=s.abs(t.touches[0].pageX-t.touches[1].pageX),h=s.abs(t.touches[0].pageY-t.touches[1].pageY),a=s.sqrt(n*n+h*h),l=1/this.touchesDistanceStart*a*this.startScale;this.scaled=!0,l<this.options.zoomMin?l=.5*this.options.zoomMin*s.pow(2,l/this.options.zoomMin):l>this.options.zoomMax&&(l=2*this.options.zoomMax*s.pow(.5,this.options.zoomMax/l)),i=l/this.startScale,e=this.originX-this.originX*i+this.startX,o=this.originY-this.originY*i+this.startY,this.scale=l,this.scrollTo(e,o,0)}},_zoomEnd:function(t){if(this.enabled&&r.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,s,e;this.isInTransition=0,this.initiated=0,this.scale>this.options.zoomMax?this.scale=this.options.zoomMax:this.scale<this.options.zoomMin&&(this.scale=this.options.zoomMin),this.refresh(),e=this.scale/this.startScale,i=this.originX-this.originX*e+this.startX,s=this.originY-this.originY*e+this.startY,i>0?i=0:i<this.maxScrollX&&(i=this.maxScrollX),s>0?s=0:s<this.maxScrollY&&(s=this.maxScrollY),(this.x!=i||this.y!=s)&&this.scrollTo(i,s,this.options.bounceTime),this.scaled=!1,this._execEvent("zoomEnd")}},zoom:function(t,i,s,e){if(t<this.options.zoomMin?t=this.options.zoomMin:t>this.options.zoomMax&&(t=this.options.zoomMax),t!=this.scale){var o=t/this.scale;i=void 0===i?this.wrapperWidth/2:i,s=void 0===s?this.wrapperHeight/2:s,e=void 0===e?300:e,i=i+this.wrapperOffset.left-this.x,s=s+this.wrapperOffset.top-this.y,i=i-i*o+this.x,s=s-s*o+this.y,this.scale=t,this.refresh(),i>0?i=0:i<this.maxScrollX&&(i=this.maxScrollX),s>0?s=0:s<this.maxScrollY&&(s=this.maxScrollY),this.scrollTo(i,s,e)}},_wheelZoom:function(t){var i,e,o=this;if(clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout(function(){o._execEvent("zoomEnd")},400),"deltaX"in t)i=-t.deltaY/s.abs(t.deltaY);else if("wheelDeltaX"in t)i=t.wheelDeltaY/s.abs(t.wheelDeltaY);else if("wheelDelta"in t)i=t.wheelDelta/s.abs(t.wheelDelta);else{if(!("detail"in t))return;i=-t.detail/s.abs(t.wheelDelta)}e=this.scale+i/5,this.zoom(e,t.pageX,t.pageY,0)},_initWheel:function(){r.addEvent(this.wrapper,"wheel",this),r.addEvent(this.wrapper,"mousewheel",this),r.addEvent(this.wrapper,"DOMMouseScroll",this),this.on("destroy",function(){r.removeEvent(this.wrapper,"wheel",this),r.removeEvent(this.wrapper,"mousewheel",this),r.removeEvent(this.wrapper,"DOMMouseScroll",this)})},_wheel:function(t){if(this.enabled){t.preventDefault(),t.stopPropagation();var i,e,o,n,h=this;if(void 0===this.wheelTimeout&&h._execEvent("scrollStart"),clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout(function(){h._execEvent("scrollEnd"),h.wheelTimeout=void 0},400),"deltaX"in t)i=-t.deltaX,e=-t.deltaY;else if("wheelDeltaX"in t)i=t.wheelDeltaX/120*this.options.mouseWheelSpeed,e=t.wheelDeltaY/120*this.options.mouseWheelSpeed;else if("wheelDelta"in t)i=e=t.wheelDelta/120*this.options.mouseWheelSpeed;else{if(!("detail"in t))return;i=e=-t.detail/3*this.options.mouseWheelSpeed}if(i*=this.options.invertWheelDirection,e*=this.options.invertWheelDirection,this.hasVerticalScroll||(i=e,e=0),this.options.snap)return o=this.currentPage.pageX,n=this.currentPage.pageY,i>0?o--:0>i&&o++,e>0?n--:0>e&&n++,this.goToPage(o,n),void 0;o=this.x+s.round(this.hasHorizontalScroll?i:0),n=this.y+s.round(this.hasVerticalScroll?e:0),o>0?o=0:o<this.maxScrollX&&(o=this.maxScrollX),n>0?n=0:n<this.maxScrollY&&(n=this.maxScrollY),this.scrollTo(o,n,0)}},_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,e,o,n,h,r=0,a=0,l=0,c=this.options.snapStepX||this.wrapperWidth,p=this.options.snapStepY||this.wrapperHeight;if(this.pages=[],this.wrapperWidth&&this.wrapperHeight&&this.scrollerWidth&&this.scrollerHeight){if(this.options.snap===!0)for(e=s.round(c/2),o=s.round(p/2);l>-this.scrollerWidth;){for(this.pages[r]=[],t=0,n=0;n>-this.scrollerHeight;)this.pages[r][t]={x:s.max(l,this.maxScrollX),y:s.max(n,this.maxScrollY),width:c,height:p,cx:l-e,cy:n-o},n-=p,t++;l-=c,r++}else for(h=this.options.snap,t=h.length,i=-1;t>r;r++)(0===r||h[r].offsetLeft<=h[r-1].offsetLeft)&&(a=0,i++),this.pages[a]||(this.pages[a]=[]),l=s.max(-h[r].offsetLeft,this.maxScrollX),n=s.max(-h[r].offsetTop,this.maxScrollY),e=l-s.round(h[r].offsetWidth/2),o=n-s.round(h[r].offsetHeight/2),this.pages[a][i]={x:l,y:n,width:h[r].offsetWidth,height:h[r].offsetHeight,cx:e,cy:o},l>this.maxScrollX&&a++;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=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*this.options.snapThreshold),this.snapThresholdY=s.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold))}}),this.on("flick",function(){var t=this.options.snapSpeed||s.max(s.max(s.min(s.abs(this.x-this.startX),1e3),s.min(s.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 e=0,o=this.pages.length,n=0;if(s.abs(t-this.absStartX)<this.snapThresholdX&&s.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);o>e;e++)if(t>=this.pages[e][0].cx){t=this.pages[e][0].x;break}for(o=this.pages[e].length;o>n;n++)if(i>=this.pages[0][n].cy){i=this.pages[0][n].y;break}return e==this.currentPage.pageX&&(e+=this.directionX,0>e?e=0:e>=this.pages.length&&(e=this.pages.length-1),t=this.pages[e][0].x),n==this.currentPage.pageY&&(n+=this.directionY,0>n?n=0:n>=this.pages[0].length&&(n=this.pages[0].length-1),i=this.pages[0][n].y),{x:t,y:i,pageX:e,pageY:n}},goToPage:function(t,i,e,o){o=o||this.options.bounceEasing,t>=this.pages.length?t=this.pages.length-1:0>t&&(t=0),i>=this.pages[t].length?i=this.pages[t].length-1:0>i&&(i=0);var n=this.pages[t][i].x,h=this.pages[t][i].y;e=void 0===e?this.options.snapSpeed||s.max(s.max(s.min(s.abs(n-this.x),1e3),s.min(s.abs(h-this.y),1e3)),300):e,this.currentPage={x:n,y:h,pageX:t,pageY:i},this.scrollTo(n,h,e,o)},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--,0>s&&this.hasVerticalScroll&&(s=0,e--),this.goToPage(s,e,t,i)},_initKeys:function(){var i,s={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40};if("object"==typeof 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];r.addEvent(t,"keydown",this),this.on("destroy",function(){r.removeEvent(t,"keydown",this)})},_key:function(t){if(this.enabled){var i,e=this.options.snap,o=e?this.currentPage.pageX:this.x,n=e?this.currentPage.pageY:this.y,h=r.getTime(),a=this.keyTime||0,l=.25;switch(this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(s.round(i.x),s.round(i.y)),this.isInTransition=!1),this.keyAcceleration=200>h-a?s.min(this.keyAcceleration+l,50):0,t.keyCode){case this.options.keyBindings.pageUp:this.hasHorizontalScroll&&!this.hasVerticalScroll?o+=e?1:this.wrapperWidth:n+=e?1:this.wrapperHeight;break;case this.options.keyBindings.pageDown:this.hasHorizontalScroll&&!this.hasVerticalScroll?o-=e?1:this.wrapperWidth:n-=e?1:this.wrapperHeight;break;case this.options.keyBindings.end:o=e?this.pages.length-1:this.maxScrollX,n=e?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:o=0,n=0;break;case this.options.keyBindings.left:o+=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.up:n+=e?1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.right:o-=e?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.down:n-=e?1:5+this.keyAcceleration>>0;break;default:return}if(e)return this.goToPage(o,n),void 0;o>0?(o=0,this.keyAcceleration=0):o<this.maxScrollX&&(o=this.maxScrollX,this.keyAcceleration=0),n>0?(n=0,this.keyAcceleration=0):n<this.maxScrollY&&(n=this.maxScrollY,this.keyAcceleration=0),this.scrollTo(o,n,0),this.keyTime=h}},_animate:function(t,i,s,e){function o(){var d,u,m,f=r.getTime();return f>=p?(n.isAnimating=!1,n._translate(t,i),n.resetPosition(n.options.bounceTime)||n._execEvent("scrollEnd"),void 0):(f=(f-c)/s,m=e(f),d=(t-a)*m+a,u=(i-l)*m+l,n._translate(d,u),n.isAnimating&&h(o),void 0)}var n=this,a=this.x,l=this.y,c=r.getTime(),p=c+s;this.isAnimating=!0,o()},handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t),this.options.zoom&&t.touches&&t.touches.length>1&&this._zoomStart(t);break;case"touchmove":case"MSPointerMove":case"mousemove":if(this.options.zoom&&t.touches&&t.touches[1])return this._zoom(t),void 0;this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":if(this.scaled)return this._zoomEnd(t),void 0;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":if("zoom"==this.options.wheelAction)return this._wheelZoom(t),void 0;this._wheel(t);break;case"keydown":this._key(t)}}},n.prototype={handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t)}},destroy:function(){this.options.interactive&&(r.removeEvent(this.indicator,"touchstart",this),r.removeEvent(this.indicator,"MSPointerDown",this),r.removeEvent(this.indicator,"mousedown",this),r.removeEvent(t,"touchmove",this),r.removeEvent(t,"MSPointerMove",this),r.removeEvent(t,"mousemove",this),r.removeEvent(t,"touchend",this),r.removeEvent(t,"MSPointerUp",this),r.removeEvent(t,"mouseup",this)),this.options.defaultScrollbars&&this.wrapper.parentNode.removeChild(this.wrapper)},_start:function(i){var s=i.touches?i.touches[0]:i;i.preventDefault(),i.stopPropagation(),this.transitionTime(),this.initiated=!0,this.moved=!1,this.lastPointX=s.pageX,this.lastPointY=s.pageY,this.startTime=r.getTime(),this.options.disableTouch||r.addEvent(t,"touchmove",this),this.options.disablePointer||r.addEvent(t,"MSPointerMove",this),this.options.disableMouse||r.addEvent(t,"mousemove",this),this.scroller._execEvent("beforeScrollStart")},_move:function(t){{var i,s,e,o,n=t.touches?t.touches[0]:t;r.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),t.preventDefault(),t.stopPropagation()},_end:function(i){if(this.initiated){if(this.initiated=!1,i.preventDefault(),i.stopPropagation(),r.removeEvent(t,"touchmove",this),r.removeEvent(t,"MSPointerMove",this),r.removeEvent(t,"mousemove",this),this.scroller.options.snap){var e=this.scroller._nearestSnap(this.scroller.x,this.scroller.y),o=this.options.snapSpeed||s.max(s.max(s.min(s.abs(this.scroller.x-e.x),1e3),s.min(s.abs(this.scroller.y-e.y),1e3)),300);(this.scroller.x!=e.x||this.scroller.y!=e.y)&&(this.scroller.directionX=0,this.scroller.directionY=0,this.scroller.currentPage=e,this.scroller.scrollTo(e.x,e.y,o,this.scroller.options.bounceEasing))}this.moved&&this.scroller._execEvent("scrollEnd")}},transitionTime:function(t){t=t||0,this.indicatorStyle[r.style.transitionDuration]=t+"ms",!t&&r.isBadAndroid&&(this.indicatorStyle[r.style.transitionDuration]="0.001s")},transitionTimingFunction:function(t){this.indicatorStyle[r.style.transitionTimingFunction]=t},refresh:function(){this.transitionTime(),this.indicatorStyle.display=this.options.listenX&&!this.options.listenY?this.scroller.hasHorizontalScroll?"block":"none":this.options.listenY&&!this.options.listenX?this.scroller.hasVerticalScroll?"block":"none":this.scroller.hasHorizontalScroll||this.scroller.hasVerticalScroll?"block":"none",this.scroller.hasHorizontalScroll&&this.scroller.hasVerticalScroll?(r.addClass(this.wrapper,"iScrollBothScrollbars"),r.removeClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&this.options.customStyle&&(this.options.listenX?this.wrapper.style.right="8px":this.wrapper.style.bottom="8px")):(r.removeClass(this.wrapper,"iScrollBothScrollbars"),r.addClass(this.wrapper,"iScrollLoneScrollbar"),this.options.defaultScrollbars&&this.options.customStyle&&(this.options.listenX?this.wrapper.style.right="2px":this.wrapper.style.bottom="2px"));this.wrapper.offsetHeight;this.options.listenX&&(this.wrapperWidth=this.wrapper.clientWidth,this.options.resize?(this.indicatorWidth=s.max(s.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=-this.indicatorWidth+8,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=s.max(s.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=-this.indicatorHeight+8,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()
3-},updatePosition:function(){var t=this.options.listenX&&s.round(this.sizeRatioX*this.scroller.x)||0,i=this.options.listenY&&s.round(this.sizeRatioY*this.scroller.y)||0;this.options.ignoreBoundaries||(t<this.minBoundaryX?("scale"==this.options.shrink&&(this.width=s.max(this.indicatorWidth+t,8),this.indicatorStyle.width=this.width+"px"),t=this.minBoundaryX):t>this.maxBoundaryX?"scale"==this.options.shrink?(this.width=s.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=s.max(this.indicatorHeight+3*i,8),this.indicatorStyle.height=this.height+"px"),i=this.minBoundaryY):i>this.maxBoundaryY?"scale"==this.options.shrink?(this.height=s.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[r.style.transform]="translate("+t+"px,"+i+"px)"+this.scroller.translateZ:(this.indicatorStyle.left=t+"px",this.indicatorStyle.top=i+"px")},_pos:function(t,i){0>t?t=0:t>this.maxPosX&&(t=this.maxPosX),0>i?i=0:i>this.maxPosY&&(i=this.maxPosY),t=this.options.listenX?s.round(t/this.sizeRatioX):this.scroller.x,i=this.options.listenY?s.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[r.style.transitionDuration]=s+"ms",this.fadeTimeout=setTimeout(function(t){this.wrapperStyle.opacity=t,this.visible=+t}.bind(this,t),e)}}},e.utils=r,"undefined"!=typeof module&&module.exports?module.exports=e:t.IScroll=e}(window,document,Math);
No newline at the end of the file
modified package.json +1 −1
@@ -1,7 +1,7 @@
11 {
22 "name": "iscroll",
33 "description": "Smooth scrolling for the web",
4- "version": "5.0.9",
4+ "version": "5.1.0",
55 "homepage": "http://cubiq.org/iscroll-4",
66 "author": "Matteo Spinelli <matteo@cubiq.org> (http://cubiq.org)",
77 "keywords": [
modified src/core.js +3 −3
@@ -380,11 +380,11 @@
380380 this.scrollerWidth = this.scroller.offsetWidth;
381381 this.scrollerHeight = this.scroller.offsetHeight;
382382
383-/* REPLACE END: refresh */
384-
385383 this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
386384 this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
387385
386+/* REPLACE END: refresh */
387+
388388 this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
389389 this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
390390
@@ -433,7 +433,7 @@
433433 }
434434
435435 for ( ; i < l; i++ ) {
436- this._events[type][i].call(this);
436+ this._events[type][i].apply(this, [].slice.call(arguments, 1));
437437 }
438438 },
439439
modified src/indicator/_initIndicators.js +2 −2
@@ -18,7 +18,7 @@
1818 interactive: interactive,
1919 defaultScrollbars: true,
2020 customStyle: customStyle,
21- resize: this.options.resizeIndicator,
21+ resize: this.options.resizeScrollbars,
2222 shrink: this.options.shrinkScrollbars,
2323 fade: this.options.fadeScrollbars,
2424 listenX: false
@@ -35,7 +35,7 @@
3535 interactive: interactive,
3636 defaultScrollbars: true,
3737 customStyle: customStyle,
38- resize: this.options.resizeIndicator,
38+ resize: this.options.resizeScrollbars,
3939 shrink: this.options.shrinkScrollbars,
4040 fade: this.options.fadeScrollbars,
4141 listenY: false
modified src/indicator/build.json +1 −1
@@ -1,6 +1,6 @@
11 {
22 "insert": {
3- "OPTIONS": "\t\tresizeIndicator: true,",
3+ "OPTIONS": "\t\tresizeScrollbars: true,",
44 "NORMALIZATION": "\tif ( this.options.shrinkScrollbars == 'scale' ) {\n\t\tthis.options.useTransition = false;\n\t}",
55 "_init": "\t\tif ( this.options.scrollbars || this.options.indicators ) {\n\t\t\tthis._initIndicators();\n\t\t}",
66 "_transitionTime": "indicator/_transitionTime.js",
added src/infinite/build.json +9 −0
@@ -0,0 +1,9 @@
1+{
2+ "insert": {
3+ "NORMALIZATION": "\tif ( this.options.infiniteElements ) {\n\t\tthis.options.probeType = 3;\n\t}",
4+ "_init": "\t\tif ( this.options.infiniteElements ) {\n\t\t\tthis._initInfinite();\n\t\t}"
5+ },
6+ "replace": {
7+ "refresh": "infinite/refresh.js"
8+ }
9+}
No newline at the end of the file
added src/infinite/infinite.js +94 −0
@@ -0,0 +1,94 @@
1+
2+ _initInfinite: function () {
3+ var el = this.options.infiniteElements;
4+
5+ this.infiniteElements = typeof el == 'string' ? document.querySelectorAll(el) : el;
6+ this.infiniteLength = this.infiniteElements.length;
7+ this.infiniteMaster = this.infiniteElements[0];
8+ this.infiniteElementHeight = this.infiniteMaster.offsetHeight;
9+ this.infiniteHeight = this.infiniteLength * this.infiniteElementHeight;
10+
11+ this.options.cacheSize = this.options.cacheSize || 1000;
12+ this.infiniteCacheBuffer = Math.round(this.options.cacheSize / 4);
13+
14+ //this.infiniteCache = {};
15+ this.options.dataset.call(this, 0, this.options.cacheSize);
16+
17+ this.on('refresh', function () {
18+ var elementsPerPage = Math.ceil(this.wrapperHeight / this.infiniteElementHeight);
19+ this.infiniteUpperBufferSize = Math.floor((this.infiniteLength - elementsPerPage) / 2);
20+ this.reorderInfinite();
21+ });
22+
23+ this.on('scroll', this.reorderInfinite);
24+ },
25+
26+ // TO-DO: clean up the mess
27+ reorderInfinite: function () {
28+ var center = -this.y + this.wrapperHeight / 2;
29+
30+ var minorPhase = Math.max(Math.floor(-this.y / this.infiniteElementHeight) - this.infiniteUpperBufferSize, 0),
31+ majorPhase = Math.floor(minorPhase / this.infiniteLength),
32+ phase = minorPhase - majorPhase * this.infiniteLength;
33+
34+ var top = 0;
35+ var i = 0;
36+ var update = [];
37+
38+ //var cachePhase = Math.floor((minorPhase + this.infiniteLength / 2) / this.infiniteCacheBuffer);
39+ var cachePhase = Math.floor(minorPhase / this.infiniteCacheBuffer);
40+
41+ while ( i < this.infiniteLength ) {
42+ top = i * this.infiniteElementHeight + majorPhase * this.infiniteHeight;
43+
44+ if ( phase > i ) {
45+ top += this.infiniteElementHeight * this.infiniteLength;
46+ }
47+
48+ if ( this.infiniteElements[i]._top !== top ) {
49+ this.infiniteElements[i]._phase = top / this.infiniteElementHeight;
50+
51+ if ( this.infiniteElements[i]._phase < this.options.infiniteLimit ) {
52+ this.infiniteElements[i]._top = top;
53+ this.infiniteElements[i].style.top = top + 'px';
54+ update.push(this.infiniteElements[i]);
55+ }
56+ }
57+
58+ i++;
59+ }
60+
61+ if ( this.cachePhase != cachePhase && (cachePhase === 0 || minorPhase - this.infiniteCacheBuffer > 0) ) {
62+ this.options.dataset.call(this, Math.max(cachePhase * this.infiniteCacheBuffer - this.infiniteCacheBuffer, 0), this.options.cacheSize);
63+ }
64+
65+ this.cachePhase = cachePhase;
66+
67+ this.updateContent(update);
68+ },
69+
70+ updateContent: function (els) {
71+ if ( this.infiniteCache === undefined ) {
72+ return;
73+ }
74+
75+ for ( var i = 0, l = els.length; i < l; i++ ) {
76+ this.options.dataFiller.call(this, els[i], this.infiniteCache[els[i]._phase]);
77+ }
78+ },
79+
80+ updateCache: function (start, data) {
81+ var firstRun = this.infiniteCache === undefined;
82+
83+ this.infiniteCache = {};
84+
85+ for ( var i = 0, l = data.length; i < l; i++ ) {
86+ this.infiniteCache[start++] = data[i];
87+ }
88+
89+ if ( firstRun ) {
90+ this.updateContent(this.infiniteElements);
91+ }
92+
93+ },
94+
added src/infinite/refresh.js +12 −0
@@ -0,0 +1,12 @@
1+
2+ this.scrollerWidth = this.scroller.offsetWidth;
3+ this.scrollerHeight = this.scroller.offsetHeight;
4+
5+ this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
6+
7+ var limit;
8+ if ( this.options.infiniteElements ) {
9+ this.options.infiniteLimit = this.options.infiniteLimit || Math.floor(2147483645 / this.infiniteElementHeight);
10+ limit = -this.options.infiniteLimit * this.infiniteElementHeight + this.wrapperHeight;
11+ }
12+ this.maxScrollY = limit !== undefined ? limit : this.wrapperHeight - this.scrollerHeight;
modified src/utils.js +1 −1
@@ -82,7 +82,7 @@
8282 });
8383
8484 // This should find all Android browsers lower than build 535.19 (both stock browser and webview)
85- me.isBadAndroid = /Android/.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
85+ me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
8686
8787 me.extend(me.style = {}, {
8888 transform: _transform,
modified src/zoom/refresh.js +3 −0
@@ -1,3 +1,6 @@
11
22 this.scrollerWidth = Math.round(this.scroller.offsetWidth * this.scale);
33 this.scrollerHeight = Math.round(this.scroller.offsetHeight * this.scale);
4+
5+ this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
6+ this.maxScrollY = this.wrapperHeight - this.scrollerHeight;