[Pkg-javascript-commits] [node-iscroll] 01/02: Imported Upstream version 5.1.1
Balint Reczey
rbalint at moszumanska.debian.org
Thu Apr 3 01:44:06 UTC 2014
This is an automated email from the git hooks/post-receive script.
rbalint pushed a commit to branch master
in repository node-iscroll.
commit dafdc184f9859d8c4de063546a90111e91adaa13
Author: Balint Reczey <balint at balintreczey.hu>
Date: Wed Apr 2 22:25:10 2014 +0200
Imported Upstream version 5.1.1
---
.gitignore | 4 +
.nodemonignore | 5 +
CONTRIBUTING.md | 19 +
LICENSE | 22 +
README.md | 783 ++++++++++
RELEASENOTES.md | 34 +
build.js | 155 ++
build/iscroll-infinite.js | 1565 ++++++++++++++++++++
build/iscroll-lite.js | 930 ++++++++++++
build/iscroll-probe.js | 2015 ++++++++++++++++++++++++++
build/iscroll-zoom.js | 2172 ++++++++++++++++++++++++++++
build/iscroll.js | 1988 +++++++++++++++++++++++++
demos/2d-scroll/index.html | 138 ++
demos/barebone/index.html | 84 ++
demos/bounce-easing/index.html | 190 +++
demos/carousel/gaugin.jpg | Bin 0 -> 10618 bytes
demos/carousel/giotto.jpg | Bin 0 -> 16561 bytes
demos/carousel/index.html | 173 +++
demos/carousel/leonardo.jpg | Bin 0 -> 7894 bytes
demos/carousel/warhol.jpg | Bin 0 -> 12457 bytes
demos/click/index.html | 190 +++
demos/event-passthrough/index.html | 155 ++
demos/forms/index.html | 190 +++
demos/horizontal/index.html | 193 +++
demos/infinite/dataset.php | 14 +
demos/infinite/index.html | 247 ++++
demos/key-bindings/index.html | 190 +++
demos/minimap/ermine.jpg | Bin 0 -> 155092 bytes
demos/minimap/index.html | 174 +++
demos/no-transition/index.html | 190 +++
demos/parallax/galaxies1.png | Bin 0 -> 105019 bytes
demos/parallax/galaxies2.png | Bin 0 -> 92917 bytes
demos/parallax/index.html | 152 ++
demos/parallax/stars.jpg | Bin 0 -> 30908 bytes
demos/probe/index.html | 176 +++
demos/scroll-to-element/index.html | 190 +++
demos/scrollbars/index.html | 196 +++
demos/simple/index.html | 190 +++
demos/snap/index.html | 256 ++++
demos/styled-scrollbars/index.html | 251 ++++
demos/tap/index.html | 194 +++
demos/zoom/index.html | 165 +++
package.json | 29 +
src/close.js | 10 +
src/core.js | 600 ++++++++
src/default/_animate.js | 38 +
src/default/handleEvent.js | 48 +
src/indicator/_initIndicators.js | 104 ++
src/indicator/_transitionTime.js | 6 +
src/indicator/_transitionTimingFunction.js | 6 +
src/indicator/_translate.js | 6 +
src/indicator/build.json | 10 +
src/indicator/indicator.js | 417 ++++++
src/infinite/build.json | 10 +
src/infinite/infinite.js | 98 ++
src/infinite/refresh.js | 12 +
src/keys/build.json | 5 +
src/keys/keys.js | 123 ++
src/open.js | 1 +
src/probe/_animate.js | 42 +
src/probe/_move.js | 14 +
src/probe/build.json | 10 +
src/probe/indicator._move.js | 7 +
src/probe/probe.js | 6 +
src/snap/_end.js | 16 +
src/snap/build.json | 8 +
src/snap/refresh.js | 10 +
src/snap/snap.js | 247 ++++
src/utils.js | 234 +++
src/wheel/build.json | 7 +
src/wheel/wheel.js | 98 ++
src/zoom/build.json | 11 +
src/zoom/handleEvent.js | 59 +
src/zoom/refresh.js | 6 +
src/zoom/zoom.js | 170 +++
75 files changed, 16058 insertions(+)
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..eb75f45
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+.DS_Store
+._*
+node_modules
+dist
\ No newline at end of file
diff --git a/.nodemonignore b/.nodemonignore
new file mode 100644
index 0000000..2d75ce5
--- /dev/null
+++ b/.nodemonignore
@@ -0,0 +1,5 @@
+/build/*
+/dist/*
+/demos/*
+*.md
+*.tmp
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..a331488
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,19 @@
+# Contributing to iScroll / FAQ
+
+## Why we need a CLA (Contributor License Agreement)
+
+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.
+
+If you are an individual, please sign the following form:
+http://cubiq.org/iscroll/cla/individual.html
+
+If you are a company or an entity please sign the following form:
+http://cubiq.org/iscroll/cla/entity.html
+
+## Why is my patch not accepted yet?
+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.
+
+If you want to speed up the process, please provide your own test results and try to be as more specific as possible.
+
+Thanks!
+Matteo Spinelli
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..1f19c7b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2008-2013 Matteo Spinelli, http://cubiq.org
+
+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:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+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.
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..7384b52
--- /dev/null
+++ b/README.md
@@ -0,0 +1,783 @@
+<h1 id="intro">iScroll, smooth scrolling for the web</h1>
+
+iScroll is a high performance, small footprint, dependency free, multi-platform javascript scroller.
+
+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.
+
+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.
+
+Even on platforms where native scrolling is good enough, iScroll adds features that wouldn't be possible otherwise. Specifically:
+
+* Granular control over the scroll position, even during momentum. You can always get and set the x,y coordinates of the scroller.
+* Animation can be customized with user defined easing functions (bounce, elastic, back, ...).
+* You can easily hook to a plethora of custom events (onBeforeScrollStart, onScrollStart, onScroll, onScrollEnd, flick, ...).
+* Out of the box multi-platform support. From older Android devices to the latest iPhone, from Chrome to Internet Explorer.
+
+<h2 id="iscroll-versions">The many faces of iScroll</h2>
+
+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.
+
+Currently we have the following fragrances:
+
+* **iscroll.js**, it is the general purpose script. It includes the most commonly used features and grants very high performance in a small footprint.
+* **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.
+* **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).
+* **iscroll-zoom.js**, adds zooming to the standard scroll.
+* **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.
+
+<h2 id="getting-started">Getting started</h2>
+
+So you want to be an iScroll master. Cool, because that is what I'll make you into.
+
+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.
+
+`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.
+
+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.
+
+The optimal HTML structure is:
+
+ <div id="wrapper">
+ <ul>
+ <li>...</li>
+ <li>...</li>
+ ...
+ </ul>
+ </div>
+
+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.
+
+<div class="tip">
+<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>
+
+<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>
+</div>
+
+The minimal call to initiate the script is as follow:
+
+ <script type="text/javascript">
+ var myScroll = new IScroll('#wrapper');
+ </script>
+
+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:
+
+ var wrapper = document.getElementById('wrapper');
+ var myScroll = new IScroll(wrapper);
+
+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:
+
+ var myScroll = new IScroll('.wrapper');
+
+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.
+
+<div class="tip">
+<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.</p>
+
+For example you could later check the <a href="#scroller-info">scroller position</a> or <a href="#destroy">unload unnecessary events</a> when you don't need the iScroll anymore.</p>
+</div>
+
+<h2 id="initialization">Initialization</h2>
+
+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.
+
+<div class="important">
+<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>
+</div>
+
+To sum up, the smallest iScroll configuration is:
+
+ <head>
+ ...
+ <script type="text/javascript" src="iscroll.js"></script>
+ <script type="text/javascript">
+ var myScroll;
+ function loaded() {
+ myScroll = new IScroll('#wrapper');
+ }
+ </script>
+ </head>
+ ...
+ <body onload="loaded()">
+ <div id="wrapper">
+ <ul>
+ <li>...</li>
+ <li>...</li>
+ ...
+ </ul>
+ </div>
+ </body>
+
+Refer to the [barebone example](http://lab.cubiq.org/iscroll5/demos/barebone/) for more details on the minimal CSS/HTML requirements.
+
+<div class="tip">
+<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>
+</div>
+
+<h2 id="configuring">Configuring the iScroll</h2>
+
+iScroll can be configured by passing a second parameter during the initialization phase.
+
+ var myScroll = new IScroll('#wrapper', {
+ mouseWheel: true,
+ scrollbars: true
+ });
+
+The example above turns on mouse wheel support and scrollbars.
+
+After initialization you can access the *normalized* values from the `options` object. Eg:
+
+ console.log(myScroll.options);
+
+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`.
+
+<h2 id="the-core">Understanding the core</h2>
+
+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.
+
+Nonetheless it is important to understand which mechanisms iScroll works on and how to configure them.
+
+### <small>options.</small>useTransform
+
+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).
+
+This might be useful when scrolling sensitive content such as Flash, iframes and videos, but be warned: performance loss is huge.
+
+Default: `true`
+
+### <small>options.</small>useTransition
+
+iScroll uses CSS transition to perform animations (momentum and bounce). By setting this to `false`, `requestAnimationFrame` is used instead.
+
+On modern browsers the difference is barely noticeable. On older devices transitions perform better.
+
+Default: `true`
+
+### <small>options.</small>HWCompositing
+
+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).
+
+Default: `true`
+
+<div class="important">
+<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>
+</div>
+
+<h2 id="basic-features">Basic features</h2>
+
+### <small>options.</small>bounce
+
+When the scroller meets the boundary it performs a small bounce animation. Disabling bounce may help reach smoother results on old or slow devices.
+
+Default: `true`
+
+### <small>options.</small>click
+
+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).
+
+Default: `false`
+
+### <small>options.</small>disableMouse<br/><small>options.</small>disablePointer<br/><small>options.</small>disableTouch
+
+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.
+
+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).
+
+For example to disable mouse and pointer events:
+
+ var myScroll = new IScroll('#wrapper', {
+ disableMouse: true,
+ disablePointer: true
+ });
+
+Default: `false`
+
+### <small>options.</small>eventPassthrough
+
+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.
+
+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).
+
+### <small>options.</small>freeScroll
+
+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.
+
+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/).
+
+Default: `false`
+
+### <small>options.</small>keyBindings
+
+Set this to `true` to activate keyboard (and remote controls) interaction. See the [Key bindings](#key-bindings) section below for more information.
+
+Default: `false`
+
+### <small>options.</small>invertWheelDirection
+
+Meaningful when mouse wheel support is activated, in which case it just inverts the scrolling direction. (ie. going down scrolls up and vice-versa).
+
+Default: `false`
+
+### <small>options.</small>momentum
+
+You can turn on/off the momentum animation performed when the user quickly flicks on screen. Turning this off greatly enhance performance.
+
+Default: `true`
+
+### <small>options.</small>mouseWheel
+
+Listen to the mouse wheel event.
+
+Default: `false`
+
+### <small>options.</small>preventDefault
+
+Whether or not to `preventDefault()` when events are fired. This should be left `true` unless you really know what you are doing.
+
+See `preventDefaultException` in the [Advanced features](#advanced-features) for more control over the preventDefault behavior.
+
+Default: `true`
+
+### <small>options.</small>scrollbars
+
+Wheter or not to display the default scrollbars. See more in the [Scrollbar](#scrollbar) section.
+
+Default: `false`.
+
+### <small>options.</small>scrollX<br/><small>options.</small>scrollY
+
+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/).
+
+See also the **freeScroll** option.
+
+Default: `scrollX: false`, `scrollY: true`
+
+<div class="important">
+<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>
+</div>
+
+### <small>options.</small>startX<br/><small>options.</small>startY
+
+By default iScroll starts at `0, 0` (top left) position, you can instruct the scroller to kickoff at a different location.
+
+Default: `0`
+
+### <small>options.</small>tap
+
+Set this to `true` to let iScroll emit a custom `tap` event when the scroll area is clicked/tapped but not scrolled.
+
+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:
+
+ element.addEventListener('tap', doSomething, false); \\ Native
+ $('#element').on('tap', doSomething); \\ jQuery
+
+You can also customize the event name by passing a string. Eg:
+
+ tap: 'myCustomTapEvent'
+
+In this case you'd listen to `myCustomTapEvent`.
+
+Default: `false`
+
+<h2 id="scrollbars">Scrollbars</h2>
+
+The scrollbars are more than just what the name suggests. In fact internally they are referenced as *indicators*.
+
+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.
+
+Let's start with the basis.
+
+### <small>options.</small>scrollbars
+
+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:
+
+ var myScroll = new IScroll('#wrapper', {
+ scrollbars: true
+ });
+
+Of course the default behavior can be personalized.
+
+### <small>options.</small>fadeScrollbars
+
+When not in use the scrollbar fades away. Leave this to `false` to spare resources.
+
+Default: `false`
+
+### <small>options.</small>interactiveScrollbars
+
+The scrollbar becomes draggable and user can interact with it.
+
+Default: `false`
+
+### <small>options.</small>resizeScrollbars
+
+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)).
+
+Default: `true`
+
+### <small>options.</small>shrinkScrollbars
+
+When scrolling outside of the boundaries the scrollbar is shrunk by a small amount.
+
+Valid values are: `'clip'` and `'scale'`.
+
+`'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**.
+
+`'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.
+
+Default: `false`
+
+<div class="tip">
+<p>Note that resizing can't be performed by the GPU, so <code>scale</code> is all on the CPU.</p>
+<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>
+</div>
+
+See the [scrollbar demo](http://lab.cubiq.org/iscroll5/demos/scrollbars/).
+
+<h3 id="styling-the-scrollbar">Styling the scrollbar</h3>
+
+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'`:
+
+ var myScroll = new IScroll('#wrapper', {
+ scrollbars: 'custom'
+ });
+
+Then use the following CSS classes to style the little bastards.
+
+* **.iScrollHorizontalScrollbar**, this is applied to the horizontal container. The element that actually hosts the scrollbar indicator.
+* **.iScrollVerticalScrollbar**, same as above but for the vertical container.
+* **.iScrollIndicator**, the actual scrollbar indicator.
+* **.iScrollBothScrollbars**, this is added to the container elements when both scrollbars are shown. Normally just one (horizontal or vertical) is visible.
+
+The [styled scrollbars demo](http://lab.cubiq.org/iscroll5/demos/styled-scrollbars/) should make things clearer than my lousy explanation.
+
+If you set `resizeScrollbars: false` you could make the scrollbar of a fixed size, otherwise it would be resized based on the scroller length.
+
+Please keep reading to the following section for a revelation that will shake your world.
+
+<h2 id="indicators">Indicators</h2>
+
+All the scrollbar options above are in reality just wrappers to the low level `indicators` option. It looks more or less like this:
+
+ var myScroll = new IScroll('#wrapper', {
+ indicators: {
+ el: [element|element selector]
+ fade: false,
+ ignoreBoundaries: false,
+ interactive: false,
+ listenX: true,
+ listenY: true,
+ resize: true,
+ shrink: false,
+ speedRatioX: 0,
+ speedRatioY: 0,
+ }
+ });
+
+### <small>options.indicators.</small>el
+
+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?
+
+Valid syntax would be:
+
+ indicators: {
+ el: document.getElementById('indicator')
+ }
+
+Or simply:
+
+ indicators: {
+ el: '#indicator'
+ }
+
+### <small>options.indicators.</small>ignoreBoundaries
+
+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).
+
+Default: `false`
+
+### <small>options.indicators.</small>listenX<br/><small>options.indicators.</small>listenY
+
+To which axis the indicator listens to. It can be just one or both.
+
+Default: `true`
+
+### <small>options.indicators.</small>speedRatioX<br/><small>options.indicators.</small>speedRatioY
+
+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.
+
+Default: `0`
+
+### <small>options.indicators.</small>fade<br/><small>options.indicators.</small>interactive<br/><small>options.indicators.</small>resize</br><small>options.indicators.</small>shrink
+
+These are the same options we explored in the [scrollbars section](#scrollbars), I'm not going to insult your intelligence and repeat them here.
+
+<div class="important">
+<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>
+</div>
+
+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.
+
+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 know what you may need them for, but hey! who am I to argue about your scrollbar preferences?
+
+## <span id="parallax-scrolling">Parallax scrolling</span>
+
+Parallax scrolling is just a *collateral damage* of the [Indicators](#indicators) functionality.
+
+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.
+
+Please refer to the [parallax demo](http://lab.cubiq.org/iscroll5/demos/parallax/).
+
+## Scrolling programmatically
+
+You silly! Of course you can scroll programmaticaly!
+
+### scrollTo(x, y, time, easing)
+
+Say your iScroll instance resides into the `myScroll` variable. You can easily scroll to any position with the following syntax:
+
+ myScroll.scrollTo(0, -100);
+
+That would scroll down by 100 pixels. Remember: 0 is always the top left corner. To scroll you have to pass negative numbers.
+
+`time` and `easing` are optional. They regulates the duration (in ms) and the easing function of the animation respectively.
+
+The easing functions are available in the `IScroll.utils.ease` object. For example to apply a 1 second elastic easing you'd do:
+
+ myScroll.scrollTo(0, -100, 1000, IScroll.utils.ease.elastic);
+
+The available options are: `quadratic`, `circular`, `back`, `bounce`, `elastic`.
+
+### scrollBy(x, y, time, easing)
+
+Same as above but X and Y are relative to the current position.
+
+ myScroll.scrollBy(0, -10);
+
+Would scroll 10 pixels down. If you are at -100, you'll end up at -110.
+
+### scrollToElement(el, time, offsetX, offsetY, easing)
+
+You're gonna like this. Sit tight.
+
+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.
+
+`time` is optional and sets the animation duration.
+
+`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.
+
+`easing` works the same way as per the **scrollTo** method.
+
+<h2 id="snap">Snap</h2>
+
+iScroll can snap to fixed positions and elements.
+
+### <small>options.</small>snap
+
+The simplest snap config is as follow:
+
+ var myScroll = new IScroll('#wrapper', {
+ snap: true
+ });
+
+This would automatically split the scroller into pages the size of the container.
+
+`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
+
+ var myScroll = new IScroll('#wrapper', {
+ snap: 'li'
+ });
+
+would snap to each and every `LI` tag.
+
+To help you navigate through the snap points iScroll grants access to a series of interesting methods.
+
+### goToPage(x, y, time, easing)
+
+`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.
+
+`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.
+
+ myScroll.goToPage(10, 0, 1000);
+
+This would scroll to the 10th page on the horizontal axis in 1 second.
+
+### next()<br/>prev()
+
+Go to the next and previous page based on current position.
+
+<h2 id="zoom">Zoom</h2>
+
+To use the pinch/zoom functionality you better use the `iscroll-zoom.js` script.
+
+### <small>options.</small>zoom
+
+Set this to `true` to activate zoom.
+
+Default: `false`
+
+### <small>options.</small>zoomMax
+
+Maximum zoom level.
+
+Default: `4`
+
+### <small>options.</small>zoomMin
+
+Minimum zoom level.
+
+Default: `1`
+
+### <small>options.</small>zoomStart
+
+Starting zoom level.
+
+Default: `1`
+
+### <small>options.</small>wheelAction
+
+Wheel action can be set to `'zoom'` to have the wheel regulate the zoom level instead of scrolling position.
+
+Default: `undefined` (ie: the mouse wheel scrolls)
+
+To sum up, a nice zoom config would be:
+
+ myScroll = new IScroll('#wrapper', {
+ zoom: true,
+ mouseWheel: true,
+ wheelAction: 'zoom'
+ });
+
+<div class="important">
+<p>The zoom is performed with CSS transform. iScroll can zoom only on browsers that support that.</p>
+</div>
+
+<div class="tip">
+<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>
+
+<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>
+</div>
+
+Refer to the [zoom demo](http://lab.cubiq.org/iscroll5/demos/zoom/).
+
+### zoom(scale, x, y, time)
+
+Juicy method that lets you zoom programmatically.
+
+`scale` is the zoom factor.
+
+`x` and `y` the focus point, aka the center of the zoom. If not specified, the center of the screen will be used.
+
+`time` is the duration of the animation in milliseconds (optional).
+
+<h2 id="infinite-scrolling">Infinite scrolling</h2>
+
+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.
+
+Infinite scrolling is in an early stage of development and although it can be considered stable, it is not ready for wide consumption.
+
+Please review the [infinite demo](http://lab.cubiq.org/iscroll5/demos/infinite/) and send your suggestions and bug reports.
+
+I will add more details as soon as the functionality evolves.
+
+<h2 id="advanced-options">Advanced options</h2>
+
+For the hardcore developer.
+
+### <small>options.</small>bindToWrapper
+
+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.
+
+Default: `false`
+
+### <small>options.</small>bounceEasing
+
+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.
+
+`bounceEasing` is a bit smarter than that. You can also feed a custom easing function, like so:
+
+ bounceEasing: {
+ style: 'cubic-bezier(0,0,1,1)',
+ fn: function (k) { return k; }
+ }
+
+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`.
+
+Note that `bounce` and `elastic` can't be performed by CSS transitions.
+
+Default: `'circular'`
+
+### <small>options.</small>bounceTime
+
+Duration in millisecond of the bounce animation.
+
+Default: `600`
+
+### <small>options.</small>deceleration
+
+This value can be altered to change the momentum animation duration/speed. Higher numbers make the animation shorter. Sensible results can be experienced starting with a value of `0.01`, bigger than that basically doesn't make any momentum at all.
+
+Default: `0.0006`
+
+### <small>options.</small>mouseWheelSpeed
+
+Set the speed of the mouse wheel.
+
+Default: `20`
+
+### <small>options.</small>preventDefaultException
+
+These are all the exceptions when `preventDefault()` would be fired anyway despite the **preventDefault** option value.
+
+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:
+
+ preventDefaultException: { className: /(^|\s)formfield(\s|$)/ }
+
+Default: `{ tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ }`.
+
+### <small>options.</small>resizePolling
+
+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.
+
+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.
+
+Default: `60`
+
+<h2 id="refresh">Mastering the refresh method</h2>
+
+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.
+
+This is achieved by calling the `refresh` method with the right timing. Please follow me closely, understanding this will save you hours of frustration.
+
+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.
+
+To ensure that javascript gets the updated properties you should defer the refreh with something like this:
+
+ ajax('page.php', onCompletion);
+
+ function onCompletion () {
+ // Update here your DOM
+
+ setTimeout(function () {
+ myScroll.refresh();
+ }, 0);
+ };
+
+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.
+
+<div class="tip">
+<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>
+
+<p>This is generally true for all the tasks that have to be done on the DOM. Always give the renderer some rest.</p>
+</div>
+
+<h2 id="custom-events">Custom events</h2>
+
+iScroll also emits some useful custom events you can hook to.
+
+To register them you use the `on(type, fn)` method.
+
+ myScroll = new IScroll('#wrapper');
+ myScroll.on('scrollEnd', doSomething);
+
+The above code executes the `doSomething` function every time the content stops scrolling.
+
+The available types are:
+
+* **beforeScrollStart**, executed as soon as user touches the screen but before the scrolling has initiated.
+* **scrollCancel**, scroll initiated but didn't happen.
+* **scrollStart**, the scroll started.
+* **scroll**, the content is scrolling. Available only in `scroll-probe.js` edition. See [onScroll event](#onscroll).
+* **scrollEnd**, content stopped scrolling.
+* **flick**, user flicked left/right.
+* **zoomStart**, user started zooming.
+* **zoomEnd**, zoom ended.
+
+<h2 id="onscroll">onScroll event</h2>
+
+The `scroll` event is available on **iScroll probe edition** only (`iscroll-probe.js`). The probe behavior can be altered through the `probeType` option.
+
+### <small>options.</small>probeType
+
+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.
+
+`probeType: 1` has no impact on performance. The `scroll` event is fired only when the scroller is not busy doing its stuff.
+
+`probeType: 2` always executes the `scroll` event except during momentum and bounce. This resembles the native `onScroll` event.
+
+`probeType: 3` emits the `scroll` event with a to-the-pixel precision. Note that the scrolling is forced to `requestAnimationFrame` (ie: `useTransition:false`).
+
+Please see the [probe demo](http://lab.cubiq.org/iscroll5/demos/probe/).
+
+<h2 id="key-bindings">Key bindings</h2>
+
+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.
+
+You can pass an object with the list of key codes you want iScroll to react to.
+
+The default values are as follow:
+
+ keyBindings: {
+ pageUp: 33,
+ pageDown: 34,
+ end: 35,
+ home: 36,
+ left: 37,
+ up: 38,
+ right: 39,
+ down: 40
+ }
+
+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.
+
+<h2 id="scroller-info">Useful scroller info</h2>
+
+iScroll stores many useful information that you can use to augment your application.
+
+You will probably find useful:
+
+* **myScroll.x/y**, current position
+* **myScroll.directionX/Y**, last direction (-1 down/right, 0 still, 1 up/left)
+* **myScroll.currentPage**, current snap point info
+
+These pieces of information may be useful when dealing with custom events. Eg:
+
+ myScroll = new IScroll('#wrapper');
+ myScroll.on('scrollEnd', function () {
+ if ( this.x < -1000 ) {
+ // do something
+ }
+ });
+
+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.
+
+<h2 id="destroy">Destroy</h2>
+
+The public `destroy()` method can be used to free some memory when the iScroll is not needed anymore.
+
+ myScroll.destroy();
+ myScroll = null;
+
+<h2 id="contributing">Contributing and CLA</h2>
+
+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.
+
+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.
+
+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.
+
+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.*
+
+<h2 id="whos">Who is using iScroll</h2>
+
+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.
+
+<h2 id="license">License (MIT)</h2>
+
+
+Copyright (c) 2014 Matteo Spinelli, [cubiq.org](http://cubiq.org/)
+
+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:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+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.
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
new file mode 100644
index 0000000..4e18129
--- /dev/null
+++ b/RELEASENOTES.md
@@ -0,0 +1,34 @@
+# Release notes for iScroll
+
+---
+
+## Version 5.1.1 - 2014.01.10
+
+### Fixes
+* Infinite scroll now switch from `transform` to `top/left` based on `useTransform` option.
+* [#555](https://github.com/cubiq/iscroll/issues/555) removed unused variable
+* [#372](https://github.com/cubiq/iscroll/issues/372) case insensitive check on tag names
+
+### New features
+* New `off` method to unload custom events
+* Added `options.deceleration` to alter the momentum duration/speed
+* Added release notes file
+
+---
+
+## Version 5.1.0 - 2014.01.09
+
+### Fixes
+* [#558](https://github.com/cubiq/iscroll/issues/558) false positive for `isBadAndroid`
+
+### New features
+* Infinite scrolling
+* Documentation
+* `_execEvent` supports arguments
+
+### Changes
+* dist/minified files are no longer pushed to the main repo
+
+---
+
+*I started collecting release notes from version 5.1.0*
\ No newline at end of file
diff --git a/build.js b/build.js
new file mode 100755
index 0000000..5ae5f21
--- /dev/null
+++ b/build.js
@@ -0,0 +1,155 @@
+#!/usr/bin/env node
+
+var pkg = require('./package.json');
+var fs = require('fs');
+var hint = require("jshint").JSHINT;
+var uglify = require('uglify-js');
+
+var banner = '/*! iScroll v' + pkg.version + ' ~ (c) 2008-' + (new Date().getFullYear()) + ' Matteo Spinelli ~ http://cubiq.org/license */\n';
+
+var releases = {
+ lite: {
+ files: [
+ 'default/_animate.js',
+ 'default/handleEvent.js'
+ ]
+ },
+
+ iscroll: {
+ files: [
+ 'indicator/_initIndicators.js',
+ 'wheel/wheel.js',
+ 'snap/snap.js',
+ 'keys/keys.js',
+ 'default/_animate.js',
+ 'default/handleEvent.js',
+ 'indicator/indicator.js'
+ ],
+ postProcessing: [ 'indicator/build.json', 'wheel/build.json', 'snap/build.json', 'keys/build.json' ]
+ },
+
+ probe: {
+ files: [
+ 'indicator/_initIndicators.js',
+ 'wheel/wheel.js',
+ 'snap/snap.js',
+ 'keys/keys.js',
+ 'probe/_animate.js',
+ 'default/handleEvent.js',
+ 'indicator/indicator.js'
+ ],
+ postProcessing: [ 'indicator/build.json', 'wheel/build.json', 'snap/build.json', 'keys/build.json', 'probe/build.json' ]
+ },
+
+ zoom: {
+ files: [
+ 'indicator/_initIndicators.js',
+ 'zoom/zoom.js',
+ 'wheel/wheel.js',
+ 'snap/snap.js',
+ 'keys/keys.js',
+ 'default/_animate.js',
+ 'zoom/handleEvent.js',
+ 'indicator/indicator.js'
+ ],
+ postProcessing: [ 'zoom/build.json', 'indicator/build.json', 'wheel/build.json', 'snap/build.json', 'keys/build.json' ]
+ },
+
+ infinite: {
+ files: [
+ 'wheel/wheel.js',
+ 'snap/snap.js',
+ 'keys/keys.js',
+ 'probe/_animate.js',
+ 'infinite/infinite.js',
+ 'default/handleEvent.js',
+ ],
+ postProcessing: [ 'wheel/build.json', 'snap/build.json', 'keys/build.json', 'infinite/build.json', 'probe/build.json' ]
+ }
+};
+
+var args = process.argv.slice(2);
+
+if ( !args.length ) {
+ args = ['iscroll'];
+}
+
+if ( args[0] == 'dist' ) {
+ args = ['lite', 'iscroll', 'zoom', 'probe', 'infinite'];
+}
+
+// Get the list of files
+args.forEach(function (release) {
+ if ( !(release in releases) ) {
+ console.log('Unrecognized release: ' + release);
+ return;
+ }
+
+ console.log('Building release: ' + release);
+ build(release);
+});
+
+function build (release) {
+ var out = '';
+ var value = '';
+
+ var fileList = ['open.js', 'utils.js', 'core.js'];
+
+ fileList = fileList.concat(releases[release].files);
+
+ fileList.push('close.js');
+
+ // Concatenate files
+ out = banner + fileList.map(function (filePath) {
+ return fs.readFileSync('src/' + filePath, 'utf-8');
+ }).join('');
+
+ // Update version
+ out = out.replace('/* VERSION */', pkg.version);
+
+ // Post processing
+ if ( releases[release].postProcessing ) {
+ releases[release].postProcessing.forEach(function (file) {
+ var postProcessing = require('./src/' + file);
+
+ // Insert point
+ for ( var i in postProcessing.insert ) {
+ value = postProcessing.insert[i].substr(postProcessing.insert[i].length-3) == '.js' ?
+ fs.readFileSync('src/' + postProcessing.insert[i]) :
+ postProcessing.insert[i];
+
+ out = out.replace('// INSERT POINT: ' + i, value + '\n\n// INSERT POINT: ' + i );
+ }
+
+ // Replace
+ for ( i in postProcessing.replace ) {
+ value = postProcessing.replace[i].substr(postProcessing.replace[i].length-3) == '.js' ?
+ fs.readFileSync('src/' + postProcessing.replace[i]) :
+ postProcessing.replace[i];
+
+ var regex = new RegExp('\\/\\* REPLACE START: ' + i + ' \\*\\/[\\s\\S]*\\/\\* REPLACE END: ' + i + ' \\*\\/');
+ out = out.replace(regex, '/* REPLACE START: ' + i + ' */' + value + '/* REPLACE END: ' + i + ' */');
+ }
+ });
+ }
+
+ // Write build file
+ var buildFile = './build/iscroll' + (release != 'iscroll' ? '-' + release : '') + '.js';
+ fs.writeFileSync(buildFile, out);
+
+ // JSHint
+ if ( !hint(out) ) {
+ var lines = out.split('\n');
+ hint.errors.forEach(function (err) {
+ console.log('\033[31m[' + err.code + ']\033[0m ' + err.line + ':' + err.character + '\t- ' + err.reason);
+ console.log('\033[33m' + lines[err.line-1].replace(/\t/g, ' ') + '\033[0m\n');
+ });
+
+ process.exit();
+ }
+
+ // Write dist file
+ var distFile = buildFile.replace('/build/', '/dist/').replace('.js', '-min.js');
+ out = uglify.minify(out, { fromString: true });
+ fs.writeFileSync(distFile, banner + out.code);
+}
diff --git a/build/iscroll-infinite.js b/build/iscroll-infinite.js
new file mode 100644
index 0000000..f524f40
--- /dev/null
+++ b/build/iscroll-infinite.js
@@ -0,0 +1,1565 @@
+/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
+(function (window, document, Math) {
+var rAF = window.requestAnimationFrame ||
+ window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame ||
+ window.msRequestAnimationFrame ||
+ function (callback) { window.setTimeout(callback, 1000 / 60); };
+
+var utils = (function () {
+ var me = {};
+
+ var _elementStyle = document.createElement('div').style;
+ var _vendor = (function () {
+ var vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'],
+ transform,
+ i = 0,
+ l = vendors.length;
+
+ for ( ; i < l; i++ ) {
+ transform = vendors[i] + 'ransform';
+ if ( transform in _elementStyle ) return vendors[i].substr(0, vendors[i].length-1);
+ }
+
+ return false;
+ })();
+
+ function _prefixStyle (style) {
+ if ( _vendor === false ) return false;
+ if ( _vendor === '' ) return style;
+ return _vendor + style.charAt(0).toUpperCase() + style.substr(1);
+ }
+
+ me.getTime = Date.now || function getTime () { return new Date().getTime(); };
+
+ me.extend = function (target, obj) {
+ for ( var i in obj ) {
+ target[i] = obj[i];
+ }
+ };
+
+ me.addEvent = function (el, type, fn, capture) {
+ el.addEventListener(type, fn, !!capture);
+ };
+
+ me.removeEvent = function (el, type, fn, capture) {
+ el.removeEventListener(type, fn, !!capture);
+ };
+
+ me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
+ var distance = current - start,
+ speed = Math.abs(distance) / time,
+ destination,
+ duration;
+
+ deceleration = deceleration === undefined ? 0.0006 : deceleration;
+
+ destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );
+ duration = speed / deceleration;
+
+ if ( destination < lowerMargin ) {
+ destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin;
+ distance = Math.abs(destination - current);
+ duration = distance / speed;
+ } else if ( destination > 0 ) {
+ destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0;
+ distance = Math.abs(current) + destination;
+ duration = distance / speed;
+ }
+
+ return {
+ destination: Math.round(destination),
+ duration: duration
+ };
+ };
+
+ var _transform = _prefixStyle('transform');
+
+ me.extend(me, {
+ hasTransform: _transform !== false,
+ hasPerspective: _prefixStyle('perspective') in _elementStyle,
+ hasTouch: 'ontouchstart' in window,
+ hasPointer: navigator.msPointerEnabled,
+ hasTransition: _prefixStyle('transition') in _elementStyle
+ });
+
+ // This should find all Android browsers lower than build 535.19 (both stock browser and webview)
+ me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
+
+ me.extend(me.style = {}, {
+ transform: _transform,
+ transitionTimingFunction: _prefixStyle('transitionTimingFunction'),
+ transitionDuration: _prefixStyle('transitionDuration'),
+ transitionDelay: _prefixStyle('transitionDelay'),
+ transformOrigin: _prefixStyle('transformOrigin')
+ });
+
+ me.hasClass = function (e, c) {
+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)");
+ return re.test(e.className);
+ };
+
+ me.addClass = function (e, c) {
+ if ( me.hasClass(e, c) ) {
+ return;
+ }
+
+ var newclass = e.className.split(' ');
+ newclass.push(c);
+ e.className = newclass.join(' ');
+ };
+
+ me.removeClass = function (e, c) {
+ if ( !me.hasClass(e, c) ) {
+ return;
+ }
+
+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)", 'g');
+ e.className = e.className.replace(re, ' ');
+ };
+
+ me.offset = function (el) {
+ var left = -el.offsetLeft,
+ top = -el.offsetTop;
+
+ // jshint -W084
+ while (el = el.offsetParent) {
+ left -= el.offsetLeft;
+ top -= el.offsetTop;
+ }
+ // jshint +W084
+
+ return {
+ left: left,
+ top: top
+ };
+ };
+
+ me.preventDefaultException = function (el, exceptions) {
+ for ( var i in exceptions ) {
+ if ( exceptions[i].test(el[i]) ) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ me.extend(me.eventType = {}, {
+ touchstart: 1,
+ touchmove: 1,
+ touchend: 1,
+
+ mousedown: 2,
+ mousemove: 2,
+ mouseup: 2,
+
+ MSPointerDown: 3,
+ MSPointerMove: 3,
+ MSPointerUp: 3
+ });
+
+ me.extend(me.ease = {}, {
+ quadratic: {
+ style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
+ fn: function (k) {
+ return k * ( 2 - k );
+ }
+ },
+ circular: {
+ 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)
+ fn: function (k) {
+ return Math.sqrt( 1 - ( --k * k ) );
+ }
+ },
+ back: {
+ style: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
+ fn: function (k) {
+ var b = 4;
+ return ( k = k - 1 ) * k * ( ( b + 1 ) * k + b ) + 1;
+ }
+ },
+ bounce: {
+ style: '',
+ fn: function (k) {
+ if ( ( k /= 1 ) < ( 1 / 2.75 ) ) {
+ return 7.5625 * k * k;
+ } else if ( k < ( 2 / 2.75 ) ) {
+ return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75;
+ } else if ( k < ( 2.5 / 2.75 ) ) {
+ return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375;
+ } else {
+ return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375;
+ }
+ }
+ },
+ elastic: {
+ style: '',
+ fn: function (k) {
+ var f = 0.22,
+ e = 0.4;
+
+ if ( k === 0 ) { return 0; }
+ if ( k == 1 ) { return 1; }
+
+ return ( e * Math.pow( 2, - 10 * k ) * Math.sin( ( k - f / 4 ) * ( 2 * Math.PI ) / f ) + 1 );
+ }
+ }
+ });
+
+ me.tap = function (e, eventName) {
+ var ev = document.createEvent('Event');
+ ev.initEvent(eventName, true, true);
+ ev.pageX = e.pageX;
+ ev.pageY = e.pageY;
+ e.target.dispatchEvent(ev);
+ };
+
+ me.click = function (e) {
+ var target = e.target,
+ ev;
+
+ if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) {
+ ev = document.createEvent('MouseEvents');
+ ev.initMouseEvent('click', true, true, e.view, 1,
+ target.screenX, target.screenY, target.clientX, target.clientY,
+ e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
+ 0, null);
+
+ ev._constructed = true;
+ target.dispatchEvent(ev);
+ }
+ };
+
+ return me;
+})();
+
+function IScroll (el, options) {
+ this.wrapper = typeof el == 'string' ? document.querySelector(el) : el;
+ this.scroller = this.wrapper.children[0];
+ this.scrollerStyle = this.scroller.style; // cache style for better performance
+
+ this.options = {
+
+ mouseWheelSpeed: 20,
+
+ snapThreshold: 0.334,
+
+ infiniteUseTransform: true,
+ deceleration: 0.004,
+
+// INSERT POINT: OPTIONS
+
+ startX: 0,
+ startY: 0,
+ scrollY: true,
+ directionLockThreshold: 5,
+ momentum: true,
+
+ bounce: true,
+ bounceTime: 600,
+ bounceEasing: '',
+
+ preventDefault: true,
+ preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ },
+
+ HWCompositing: true,
+ useTransition: true,
+ useTransform: true
+ };
+
+ for ( var i in options ) {
+ this.options[i] = options[i];
+ }
+
+ // Normalize options
+ this.translateZ = this.options.HWCompositing && utils.hasPerspective ? ' translateZ(0)' : '';
+
+ this.options.useTransition = utils.hasTransition && this.options.useTransition;
+ this.options.useTransform = utils.hasTransform && this.options.useTransform;
+
+ this.options.eventPassthrough = this.options.eventPassthrough === true ? 'vertical' : this.options.eventPassthrough;
+ this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault;
+
+ // If you want eventPassthrough I have to lock one of the axes
+ this.options.scrollY = this.options.eventPassthrough == 'vertical' ? false : this.options.scrollY;
+ this.options.scrollX = this.options.eventPassthrough == 'horizontal' ? false : this.options.scrollX;
+
+ // With eventPassthrough we also need lockDirection mechanism
+ this.options.freeScroll = this.options.freeScroll && !this.options.eventPassthrough;
+ this.options.directionLockThreshold = this.options.eventPassthrough ? 0 : this.options.directionLockThreshold;
+
+ this.options.bounceEasing = typeof this.options.bounceEasing == 'string' ? utils.ease[this.options.bounceEasing] || utils.ease.circular : this.options.bounceEasing;
+
+ this.options.resizePolling = this.options.resizePolling === undefined ? 60 : this.options.resizePolling;
+
+ if ( this.options.tap === true ) {
+ this.options.tap = 'tap';
+ }
+
+ this.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1;
+
+ if ( this.options.infiniteElements ) {
+ this.options.probeType = 3;
+ }
+ this.options.infiniteUseTransform = this.options.infiniteUseTransform && this.options.useTransform;
+
+ if ( this.options.probeType == 3 ) {
+ this.options.useTransition = false; }
+
+// INSERT POINT: NORMALIZATION
+
+ // Some defaults
+ this.x = 0;
+ this.y = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+ this._events = {};
+
+// INSERT POINT: DEFAULTS
+
+ this._init();
+ this.refresh();
+
+ this.scrollTo(this.options.startX, this.options.startY);
+ this.enable();
+}
+
+IScroll.prototype = {
+ version: '5.1.1',
+
+ _init: function () {
+ this._initEvents();
+
+ if ( this.options.mouseWheel ) {
+ this._initWheel();
+ }
+
+ if ( this.options.snap ) {
+ this._initSnap();
+ }
+
+ if ( this.options.keyBindings ) {
+ this._initKeys();
+ }
+
+ if ( this.options.infiniteElements ) {
+ this._initInfinite();
+ }
+
+// INSERT POINT: _init
+
+ },
+
+ destroy: function () {
+ this._initEvents(true);
+
+ this._execEvent('destroy');
+ },
+
+ _transitionEnd: function (e) {
+ if ( e.target != this.scroller || !this.isInTransition ) {
+ return;
+ }
+
+ this._transitionTime();
+ if ( !this.resetPosition(this.options.bounceTime) ) {
+ this.isInTransition = false;
+ this._execEvent('scrollEnd');
+ }
+ },
+
+ _start: function (e) {
+ // React to left mouse button only
+ if ( utils.eventType[e.type] != 1 ) {
+ if ( e.button !== 0 ) {
+ return;
+ }
+ }
+
+ if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) {
+ return;
+ }
+
+ if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
+ e.preventDefault();
+ }
+
+ var point = e.touches ? e.touches[0] : e,
+ pos;
+
+ this.initiated = utils.eventType[e.type];
+ this.moved = false;
+ this.distX = 0;
+ this.distY = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+ this.directionLocked = 0;
+
+ this._transitionTime();
+
+ this.startTime = utils.getTime();
+
+ if ( this.options.useTransition && this.isInTransition ) {
+ this.isInTransition = false;
+ pos = this.getComputedPosition();
+ this._translate(Math.round(pos.x), Math.round(pos.y));
+ this._execEvent('scrollEnd');
+ } else if ( !this.options.useTransition && this.isAnimating ) {
+ this.isAnimating = false;
+ this._execEvent('scrollEnd');
+ }
+
+ this.startX = this.x;
+ this.startY = this.y;
+ this.absStartX = this.x;
+ this.absStartY = this.y;
+ this.pointX = point.pageX;
+ this.pointY = point.pageY;
+
+ this._execEvent('beforeScrollStart');
+ },
+
+ _move: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault ) { // increases performance on Android? TODO: check!
+ e.preventDefault();
+ }
+
+ var point = e.touches ? e.touches[0] : e,
+ deltaX = point.pageX - this.pointX,
+ deltaY = point.pageY - this.pointY,
+ timestamp = utils.getTime(),
+ newX, newY,
+ absDistX, absDistY;
+
+ this.pointX = point.pageX;
+ this.pointY = point.pageY;
+
+ this.distX += deltaX;
+ this.distY += deltaY;
+ absDistX = Math.abs(this.distX);
+ absDistY = Math.abs(this.distY);
+
+ // We need to move at least 10 pixels for the scrolling to initiate
+ if ( timestamp - this.endTime > 300 && (absDistX < 10 && absDistY < 10) ) {
+ return;
+ }
+
+ // If you are scrolling in one direction lock the other
+ if ( !this.directionLocked && !this.options.freeScroll ) {
+ if ( absDistX > absDistY + this.options.directionLockThreshold ) {
+ this.directionLocked = 'h'; // lock horizontally
+ } else if ( absDistY >= absDistX + this.options.directionLockThreshold ) {
+ this.directionLocked = 'v'; // lock vertically
+ } else {
+ this.directionLocked = 'n'; // no lock
+ }
+ }
+
+ if ( this.directionLocked == 'h' ) {
+ if ( this.options.eventPassthrough == 'vertical' ) {
+ e.preventDefault();
+ } else if ( this.options.eventPassthrough == 'horizontal' ) {
+ this.initiated = false;
+ return;
+ }
+
+ deltaY = 0;
+ } else if ( this.directionLocked == 'v' ) {
+ if ( this.options.eventPassthrough == 'horizontal' ) {
+ e.preventDefault();
+ } else if ( this.options.eventPassthrough == 'vertical' ) {
+ this.initiated = false;
+ return;
+ }
+
+ deltaX = 0;
+ }
+
+ deltaX = this.hasHorizontalScroll ? deltaX : 0;
+ deltaY = this.hasVerticalScroll ? deltaY : 0;
+
+ newX = this.x + deltaX;
+ newY = this.y + deltaY;
+
+ // Slow down if outside of the boundaries
+ if ( newX > 0 || newX < this.maxScrollX ) {
+ newX = this.options.bounce ? this.x + deltaX / 3 : newX > 0 ? 0 : this.maxScrollX;
+ }
+ if ( newY > 0 || newY < this.maxScrollY ) {
+ newY = this.options.bounce ? this.y + deltaY / 3 : newY > 0 ? 0 : this.maxScrollY;
+ }
+
+ this.directionX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
+ this.directionY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
+
+ if ( !this.moved ) {
+ this._execEvent('scrollStart');
+ }
+
+ this.moved = true;
+
+ this._translate(newX, newY);
+
+/* REPLACE START: _move */
+ if ( timestamp - this.startTime > 300 ) {
+ this.startTime = timestamp;
+ this.startX = this.x;
+ this.startY = this.y;
+
+ if ( this.options.probeType == 1 ) {
+ this._execEvent('scroll');
+ }
+ }
+
+ if ( this.options.probeType > 1 ) {
+ this._execEvent('scroll');
+ }
+/* REPLACE END: _move */
+
+ },
+
+ _end: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
+ e.preventDefault();
+ }
+
+ var point = e.changedTouches ? e.changedTouches[0] : e,
+ momentumX,
+ momentumY,
+ duration = utils.getTime() - this.startTime,
+ newX = Math.round(this.x),
+ newY = Math.round(this.y),
+ distanceX = Math.abs(newX - this.startX),
+ distanceY = Math.abs(newY - this.startY),
+ time = 0,
+ easing = '';
+
+ this.isInTransition = 0;
+ this.initiated = 0;
+ this.endTime = utils.getTime();
+
+ // reset if we are outside of the boundaries
+ if ( this.resetPosition(this.options.bounceTime) ) {
+ return;
+ }
+
+ this.scrollTo(newX, newY); // ensures that the last position is rounded
+
+ // we scrolled less than 10 pixels
+ if ( !this.moved ) {
+ if ( this.options.tap ) {
+ utils.tap(e, this.options.tap);
+ }
+
+ if ( this.options.click ) {
+ utils.click(e);
+ }
+
+ this._execEvent('scrollCancel');
+ return;
+ }
+
+ if ( this._events.flick && duration < 200 && distanceX < 100 && distanceY < 100 ) {
+ this._execEvent('flick');
+ return;
+ }
+
+ // start momentum animation if needed
+ if ( this.options.momentum && duration < 300 ) {
+ momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 };
+ momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 };
+ newX = momentumX.destination;
+ newY = momentumY.destination;
+ time = Math.max(momentumX.duration, momentumY.duration);
+ this.isInTransition = 1;
+ }
+
+
+ if ( this.options.snap ) {
+ var snap = this._nearestSnap(newX, newY);
+ this.currentPage = snap;
+ time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(newX - snap.x), 1000),
+ Math.min(Math.abs(newY - snap.y), 1000)
+ ), 300);
+ newX = snap.x;
+ newY = snap.y;
+
+ this.directionX = 0;
+ this.directionY = 0;
+ easing = this.options.bounceEasing;
+ }
+
+// INSERT POINT: _end
+
+ if ( newX != this.x || newY != this.y ) {
+ // change easing function when scroller goes out of the boundaries
+ if ( newX > 0 || newX < this.maxScrollX || newY > 0 || newY < this.maxScrollY ) {
+ easing = utils.ease.quadratic;
+ }
+
+ this.scrollTo(newX, newY, time, easing);
+ return;
+ }
+
+ this._execEvent('scrollEnd');
+ },
+
+ _resize: function () {
+ var that = this;
+
+ clearTimeout(this.resizeTimeout);
+
+ this.resizeTimeout = setTimeout(function () {
+ that.refresh();
+ }, this.options.resizePolling);
+ },
+
+ resetPosition: function (time) {
+ var x = this.x,
+ y = this.y;
+
+ time = time || 0;
+
+ if ( !this.hasHorizontalScroll || this.x > 0 ) {
+ x = 0;
+ } else if ( this.x < this.maxScrollX ) {
+ x = this.maxScrollX;
+ }
+
+ if ( !this.hasVerticalScroll || this.y > 0 ) {
+ y = 0;
+ } else if ( this.y < this.maxScrollY ) {
+ y = this.maxScrollY;
+ }
+
+ if ( x == this.x && y == this.y ) {
+ return false;
+ }
+
+ this.scrollTo(x, y, time, this.options.bounceEasing);
+
+ return true;
+ },
+
+ disable: function () {
+ this.enabled = false;
+ },
+
+ enable: function () {
+ this.enabled = true;
+ },
+
+ refresh: function () {
+ var rf = this.wrapper.offsetHeight; // Force reflow
+
+ this.wrapperWidth = this.wrapper.clientWidth;
+ this.wrapperHeight = this.wrapper.clientHeight;
+
+/* REPLACE START: refresh */
+ this.scrollerWidth = this.scroller.offsetWidth;
+ this.scrollerHeight = this.scroller.offsetHeight;
+
+ this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
+
+ var limit;
+ if ( this.options.infiniteElements ) {
+ this.options.infiniteLimit = this.options.infiniteLimit || Math.floor(2147483645 / this.infiniteElementHeight);
+ limit = -this.options.infiniteLimit * this.infiniteElementHeight + this.wrapperHeight;
+ }
+ this.maxScrollY = limit !== undefined ? limit : this.wrapperHeight - this.scrollerHeight;
+/* REPLACE END: refresh */
+
+ this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
+ this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
+
+ if ( !this.hasHorizontalScroll ) {
+ this.maxScrollX = 0;
+ this.scrollerWidth = this.wrapperWidth;
+ }
+
+ if ( !this.hasVerticalScroll ) {
+ this.maxScrollY = 0;
+ this.scrollerHeight = this.wrapperHeight;
+ }
+
+ this.endTime = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+
+ this.wrapperOffset = utils.offset(this.wrapper);
+
+ this._execEvent('refresh');
+
+ this.resetPosition();
+
+// INSERT POINT: _refresh
+
+ },
+
+ on: function (type, fn) {
+ if ( !this._events[type] ) {
+ this._events[type] = [];
+ }
+
+ this._events[type].push(fn);
+ },
+
+ off: function (type, fn) {
+ if ( !this._events[type] ) {
+ return;
+ }
+
+ var index = this._events[type].indexOf(fn);
+
+ if ( index > -1 ) {
+ this._events[type].splice(index, 1);
+ }
+ },
+
+ _execEvent: function (type) {
+ if ( !this._events[type] ) {
+ return;
+ }
+
+ var i = 0,
+ l = this._events[type].length;
+
+ if ( !l ) {
+ return;
+ }
+
+ for ( ; i < l; i++ ) {
+ this._events[type][i].apply(this, [].slice.call(arguments, 1));
+ }
+ },
+
+ scrollBy: function (x, y, time, easing) {
+ x = this.x + x;
+ y = this.y + y;
+ time = time || 0;
+
+ this.scrollTo(x, y, time, easing);
+ },
+
+ scrollTo: function (x, y, time, easing) {
+ easing = easing || utils.ease.circular;
+
+ this.isInTransition = this.options.useTransition && time > 0;
+
+ if ( !time || (this.options.useTransition && easing.style) ) {
+ this._transitionTimingFunction(easing.style);
+ this._transitionTime(time);
+ this._translate(x, y);
+ } else {
+ this._animate(x, y, time, easing.fn);
+ }
+ },
+
+ scrollToElement: function (el, time, offsetX, offsetY, easing) {
+ el = el.nodeType ? el : this.scroller.querySelector(el);
+
+ if ( !el ) {
+ return;
+ }
+
+ var pos = utils.offset(el);
+
+ pos.left -= this.wrapperOffset.left;
+ pos.top -= this.wrapperOffset.top;
+
+ // if offsetX/Y are true we center the element to the screen
+ if ( offsetX === true ) {
+ offsetX = Math.round(el.offsetWidth / 2 - this.wrapper.offsetWidth / 2);
+ }
+ if ( offsetY === true ) {
+ offsetY = Math.round(el.offsetHeight / 2 - this.wrapper.offsetHeight / 2);
+ }
+
+ pos.left -= offsetX || 0;
+ pos.top -= offsetY || 0;
+
+ pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left;
+ pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top;
+
+ time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(this.x-pos.left), Math.abs(this.y-pos.top)) : time;
+
+ this.scrollTo(pos.left, pos.top, time, easing);
+ },
+
+ _transitionTime: function (time) {
+ time = time || 0;
+
+ this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';
+
+ if ( !time && utils.isBadAndroid ) {
+ this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
+ }
+
+// INSERT POINT: _transitionTime
+
+ },
+
+ _transitionTimingFunction: function (easing) {
+ this.scrollerStyle[utils.style.transitionTimingFunction] = easing;
+
+// INSERT POINT: _transitionTimingFunction
+
+ },
+
+ _translate: function (x, y) {
+ if ( this.options.useTransform ) {
+
+/* REPLACE START: _translate */
+
+ this.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.translateZ;
+
+/* REPLACE END: _translate */
+
+ } else {
+ x = Math.round(x);
+ y = Math.round(y);
+ this.scrollerStyle.left = x + 'px';
+ this.scrollerStyle.top = y + 'px';
+ }
+
+ this.x = x;
+ this.y = y;
+
+// INSERT POINT: _translate
+
+ },
+
+ _initEvents: function (remove) {
+ var eventType = remove ? utils.removeEvent : utils.addEvent,
+ target = this.options.bindToWrapper ? this.wrapper : window;
+
+ eventType(window, 'orientationchange', this);
+ eventType(window, 'resize', this);
+
+ if ( this.options.click ) {
+ eventType(this.wrapper, 'click', this, true);
+ }
+
+ if ( !this.options.disableMouse ) {
+ eventType(this.wrapper, 'mousedown', this);
+ eventType(target, 'mousemove', this);
+ eventType(target, 'mousecancel', this);
+ eventType(target, 'mouseup', this);
+ }
+
+ if ( utils.hasPointer && !this.options.disablePointer ) {
+ eventType(this.wrapper, 'MSPointerDown', this);
+ eventType(target, 'MSPointerMove', this);
+ eventType(target, 'MSPointerCancel', this);
+ eventType(target, 'MSPointerUp', this);
+ }
+
+ if ( utils.hasTouch && !this.options.disableTouch ) {
+ eventType(this.wrapper, 'touchstart', this);
+ eventType(target, 'touchmove', this);
+ eventType(target, 'touchcancel', this);
+ eventType(target, 'touchend', this);
+ }
+
+ eventType(this.scroller, 'transitionend', this);
+ eventType(this.scroller, 'webkitTransitionEnd', this);
+ eventType(this.scroller, 'oTransitionEnd', this);
+ eventType(this.scroller, 'MSTransitionEnd', this);
+ },
+
+ getComputedPosition: function () {
+ var matrix = window.getComputedStyle(this.scroller, null),
+ x, y;
+
+ if ( this.options.useTransform ) {
+ matrix = matrix[utils.style.transform].split(')')[0].split(', ');
+ x = +(matrix[12] || matrix[4]);
+ y = +(matrix[13] || matrix[5]);
+ } else {
+ x = +matrix.left.replace(/[^-\d.]/g, '');
+ y = +matrix.top.replace(/[^-\d.]/g, '');
+ }
+
+ return { x: x, y: y };
+ },
+
+ _initWheel: function () {
+ utils.addEvent(this.wrapper, 'wheel', this);
+ utils.addEvent(this.wrapper, 'mousewheel', this);
+ utils.addEvent(this.wrapper, 'DOMMouseScroll', this);
+
+ this.on('destroy', function () {
+ utils.removeEvent(this.wrapper, 'wheel', this);
+ utils.removeEvent(this.wrapper, 'mousewheel', this);
+ utils.removeEvent(this.wrapper, 'DOMMouseScroll', this);
+ });
+ },
+
+ _wheel: function (e) {
+ if ( !this.enabled ) {
+ return;
+ }
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ var wheelDeltaX, wheelDeltaY,
+ newX, newY,
+ that = this;
+
+ if ( this.wheelTimeout === undefined ) {
+ that._execEvent('scrollStart');
+ }
+
+ // Execute the scrollEnd event after 400ms the wheel stopped scrolling
+ clearTimeout(this.wheelTimeout);
+ this.wheelTimeout = setTimeout(function () {
+ that._execEvent('scrollEnd');
+ that.wheelTimeout = undefined;
+ }, 400);
+
+ if ( 'deltaX' in e ) {
+ wheelDeltaX = -e.deltaX;
+ wheelDeltaY = -e.deltaY;
+ } else if ( 'wheelDeltaX' in e ) {
+ wheelDeltaX = e.wheelDeltaX / 120 * this.options.mouseWheelSpeed;
+ wheelDeltaY = e.wheelDeltaY / 120 * this.options.mouseWheelSpeed;
+ } else if ( 'wheelDelta' in e ) {
+ wheelDeltaX = wheelDeltaY = e.wheelDelta / 120 * this.options.mouseWheelSpeed;
+ } else if ( 'detail' in e ) {
+ wheelDeltaX = wheelDeltaY = -e.detail / 3 * this.options.mouseWheelSpeed;
+ } else {
+ return;
+ }
+
+ wheelDeltaX *= this.options.invertWheelDirection;
+ wheelDeltaY *= this.options.invertWheelDirection;
+
+ if ( !this.hasVerticalScroll ) {
+ wheelDeltaX = wheelDeltaY;
+ wheelDeltaY = 0;
+ }
+
+ if ( this.options.snap ) {
+ newX = this.currentPage.pageX;
+ newY = this.currentPage.pageY;
+
+ if ( wheelDeltaX > 0 ) {
+ newX--;
+ } else if ( wheelDeltaX < 0 ) {
+ newX++;
+ }
+
+ if ( wheelDeltaY > 0 ) {
+ newY--;
+ } else if ( wheelDeltaY < 0 ) {
+ newY++;
+ }
+
+ this.goToPage(newX, newY);
+
+ return;
+ }
+
+ newX = this.x + Math.round(this.hasHorizontalScroll ? wheelDeltaX : 0);
+ newY = this.y + Math.round(this.hasVerticalScroll ? wheelDeltaY : 0);
+
+ if ( newX > 0 ) {
+ newX = 0;
+ } else if ( newX < this.maxScrollX ) {
+ newX = this.maxScrollX;
+ }
+
+ if ( newY > 0 ) {
+ newY = 0;
+ } else if ( newY < this.maxScrollY ) {
+ newY = this.maxScrollY;
+ }
+
+ this.scrollTo(newX, newY, 0);
+
+ if ( this.options.probeType > 1 ) {
+ this._execEvent('scroll');
+ }
+
+// INSERT POINT: _wheel
+ },
+
+ _initSnap: function () {
+ this.currentPage = {};
+
+ if ( typeof this.options.snap == 'string' ) {
+ this.options.snap = this.scroller.querySelectorAll(this.options.snap);
+ }
+
+ this.on('refresh', function () {
+ var i = 0, l,
+ m = 0, n,
+ cx, cy,
+ x = 0, y,
+ stepX = this.options.snapStepX || this.wrapperWidth,
+ stepY = this.options.snapStepY || this.wrapperHeight,
+ el;
+
+ this.pages = [];
+
+ if ( !this.wrapperWidth || !this.wrapperHeight || !this.scrollerWidth || !this.scrollerHeight ) {
+ return;
+ }
+
+ if ( this.options.snap === true ) {
+ cx = Math.round( stepX / 2 );
+ cy = Math.round( stepY / 2 );
+
+ while ( x > -this.scrollerWidth ) {
+ this.pages[i] = [];
+ l = 0;
+ y = 0;
+
+ while ( y > -this.scrollerHeight ) {
+ this.pages[i][l] = {
+ x: Math.max(x, this.maxScrollX),
+ y: Math.max(y, this.maxScrollY),
+ width: stepX,
+ height: stepY,
+ cx: x - cx,
+ cy: y - cy
+ };
+
+ y -= stepY;
+ l++;
+ }
+
+ x -= stepX;
+ i++;
+ }
+ } else {
+ el = this.options.snap;
+ l = el.length;
+ n = -1;
+
+ for ( ; i < l; i++ ) {
+ if ( i === 0 || el[i].offsetLeft <= el[i-1].offsetLeft ) {
+ m = 0;
+ n++;
+ }
+
+ if ( !this.pages[m] ) {
+ this.pages[m] = [];
+ }
+
+ x = Math.max(-el[i].offsetLeft, this.maxScrollX);
+ y = Math.max(-el[i].offsetTop, this.maxScrollY);
+ cx = x - Math.round(el[i].offsetWidth / 2);
+ cy = y - Math.round(el[i].offsetHeight / 2);
+
+ this.pages[m][n] = {
+ x: x,
+ y: y,
+ width: el[i].offsetWidth,
+ height: el[i].offsetHeight,
+ cx: cx,
+ cy: cy
+ };
+
+ if ( x > this.maxScrollX ) {
+ m++;
+ }
+ }
+ }
+
+ this.goToPage(this.currentPage.pageX || 0, this.currentPage.pageY || 0, 0);
+
+ // Update snap threshold if needed
+ if ( this.options.snapThreshold % 1 === 0 ) {
+ this.snapThresholdX = this.options.snapThreshold;
+ this.snapThresholdY = this.options.snapThreshold;
+ } else {
+ this.snapThresholdX = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width * this.options.snapThreshold);
+ this.snapThresholdY = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height * this.options.snapThreshold);
+ }
+ });
+
+ this.on('flick', function () {
+ var time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(this.x - this.startX), 1000),
+ Math.min(Math.abs(this.y - this.startY), 1000)
+ ), 300);
+
+ this.goToPage(
+ this.currentPage.pageX + this.directionX,
+ this.currentPage.pageY + this.directionY,
+ time
+ );
+ });
+ },
+
+ _nearestSnap: function (x, y) {
+ if ( !this.pages.length ) {
+ return { x: 0, y: 0, pageX: 0, pageY: 0 };
+ }
+
+ var i = 0,
+ l = this.pages.length,
+ m = 0;
+
+ // Check if we exceeded the snap threshold
+ if ( Math.abs(x - this.absStartX) < this.snapThresholdX &&
+ Math.abs(y - this.absStartY) < this.snapThresholdY ) {
+ return this.currentPage;
+ }
+
+ if ( x > 0 ) {
+ x = 0;
+ } else if ( x < this.maxScrollX ) {
+ x = this.maxScrollX;
+ }
+
+ if ( y > 0 ) {
+ y = 0;
+ } else if ( y < this.maxScrollY ) {
+ y = this.maxScrollY;
+ }
+
+ for ( ; i < l; i++ ) {
+ if ( x >= this.pages[i][0].cx ) {
+ x = this.pages[i][0].x;
+ break;
+ }
+ }
+
+ l = this.pages[i].length;
+
+ for ( ; m < l; m++ ) {
+ if ( y >= this.pages[0][m].cy ) {
+ y = this.pages[0][m].y;
+ break;
+ }
+ }
+
+ if ( i == this.currentPage.pageX ) {
+ i += this.directionX;
+
+ if ( i < 0 ) {
+ i = 0;
+ } else if ( i >= this.pages.length ) {
+ i = this.pages.length - 1;
+ }
+
+ x = this.pages[i][0].x;
+ }
+
+ if ( m == this.currentPage.pageY ) {
+ m += this.directionY;
+
+ if ( m < 0 ) {
+ m = 0;
+ } else if ( m >= this.pages[0].length ) {
+ m = this.pages[0].length - 1;
+ }
+
+ y = this.pages[0][m].y;
+ }
+
+ return {
+ x: x,
+ y: y,
+ pageX: i,
+ pageY: m
+ };
+ },
+
+ goToPage: function (x, y, time, easing) {
+ easing = easing || this.options.bounceEasing;
+
+ if ( x >= this.pages.length ) {
+ x = this.pages.length - 1;
+ } else if ( x < 0 ) {
+ x = 0;
+ }
+
+ if ( y >= this.pages[x].length ) {
+ y = this.pages[x].length - 1;
+ } else if ( y < 0 ) {
+ y = 0;
+ }
+
+ var posX = this.pages[x][y].x,
+ posY = this.pages[x][y].y;
+
+ time = time === undefined ? this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(posX - this.x), 1000),
+ Math.min(Math.abs(posY - this.y), 1000)
+ ), 300) : time;
+
+ this.currentPage = {
+ x: posX,
+ y: posY,
+ pageX: x,
+ pageY: y
+ };
+
+ this.scrollTo(posX, posY, time, easing);
+ },
+
+ next: function (time, easing) {
+ var x = this.currentPage.pageX,
+ y = this.currentPage.pageY;
+
+ x++;
+
+ if ( x >= this.pages.length && this.hasVerticalScroll ) {
+ x = 0;
+ y++;
+ }
+
+ this.goToPage(x, y, time, easing);
+ },
+
+ prev: function (time, easing) {
+ var x = this.currentPage.pageX,
+ y = this.currentPage.pageY;
+
+ x--;
+
+ if ( x < 0 && this.hasVerticalScroll ) {
+ x = 0;
+ y--;
+ }
+
+ this.goToPage(x, y, time, easing);
+ },
+
+ _initKeys: function (e) {
+ // default key bindings
+ var keys = {
+ pageUp: 33,
+ pageDown: 34,
+ end: 35,
+ home: 36,
+ left: 37,
+ up: 38,
+ right: 39,
+ down: 40
+ };
+ var i;
+
+ // if you give me characters I give you keycode
+ if ( typeof this.options.keyBindings == 'object' ) {
+ for ( i in this.options.keyBindings ) {
+ if ( typeof this.options.keyBindings[i] == 'string' ) {
+ this.options.keyBindings[i] = this.options.keyBindings[i].toUpperCase().charCodeAt(0);
+ }
+ }
+ } else {
+ this.options.keyBindings = {};
+ }
+
+ for ( i in keys ) {
+ this.options.keyBindings[i] = this.options.keyBindings[i] || keys[i];
+ }
+
+ utils.addEvent(window, 'keydown', this);
+
+ this.on('destroy', function () {
+ utils.removeEvent(window, 'keydown', this);
+ });
+ },
+
+ _key: function (e) {
+ if ( !this.enabled ) {
+ return;
+ }
+
+ var snap = this.options.snap, // we are using this alot, better to cache it
+ newX = snap ? this.currentPage.pageX : this.x,
+ newY = snap ? this.currentPage.pageY : this.y,
+ now = utils.getTime(),
+ prevTime = this.keyTime || 0,
+ acceleration = 0.250,
+ pos;
+
+ if ( this.options.useTransition && this.isInTransition ) {
+ pos = this.getComputedPosition();
+
+ this._translate(Math.round(pos.x), Math.round(pos.y));
+ this.isInTransition = false;
+ }
+
+ this.keyAcceleration = now - prevTime < 200 ? Math.min(this.keyAcceleration + acceleration, 50) : 0;
+
+ switch ( e.keyCode ) {
+ case this.options.keyBindings.pageUp:
+ if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
+ newX += snap ? 1 : this.wrapperWidth;
+ } else {
+ newY += snap ? 1 : this.wrapperHeight;
+ }
+ break;
+ case this.options.keyBindings.pageDown:
+ if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
+ newX -= snap ? 1 : this.wrapperWidth;
+ } else {
+ newY -= snap ? 1 : this.wrapperHeight;
+ }
+ break;
+ case this.options.keyBindings.end:
+ newX = snap ? this.pages.length-1 : this.maxScrollX;
+ newY = snap ? this.pages[0].length-1 : this.maxScrollY;
+ break;
+ case this.options.keyBindings.home:
+ newX = 0;
+ newY = 0;
+ break;
+ case this.options.keyBindings.left:
+ newX += snap ? -1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.up:
+ newY += snap ? 1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.right:
+ newX -= snap ? -1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.down:
+ newY -= snap ? 1 : 5 + this.keyAcceleration>>0;
+ break;
+ default:
+ return;
+ }
+
+ if ( snap ) {
+ this.goToPage(newX, newY);
+ return;
+ }
+
+ if ( newX > 0 ) {
+ newX = 0;
+ this.keyAcceleration = 0;
+ } else if ( newX < this.maxScrollX ) {
+ newX = this.maxScrollX;
+ this.keyAcceleration = 0;
+ }
+
+ if ( newY > 0 ) {
+ newY = 0;
+ this.keyAcceleration = 0;
+ } else if ( newY < this.maxScrollY ) {
+ newY = this.maxScrollY;
+ this.keyAcceleration = 0;
+ }
+
+ this.scrollTo(newX, newY, 0);
+
+ this.keyTime = now;
+ },
+
+ _animate: function (destX, destY, duration, easingFn) {
+ var that = this,
+ startX = this.x,
+ startY = this.y,
+ startTime = utils.getTime(),
+ destTime = startTime + duration;
+
+ function step () {
+ var now = utils.getTime(),
+ newX, newY,
+ easing;
+
+ if ( now >= destTime ) {
+ that.isAnimating = false;
+ that._translate(destX, destY);
+
+ if ( !that.resetPosition(that.options.bounceTime) ) {
+ that._execEvent('scrollEnd');
+ }
+
+ return;
+ }
+
+ now = ( now - startTime ) / duration;
+ easing = easingFn(now);
+ newX = ( destX - startX ) * easing + startX;
+ newY = ( destY - startY ) * easing + startY;
+ that._translate(newX, newY);
+
+ if ( that.isAnimating ) {
+ rAF(step);
+ }
+
+ if ( that.options.probeType == 3 ) {
+ that._execEvent('scroll');
+ }
+ }
+
+ this.isAnimating = true;
+ step();
+ },
+
+ _initInfinite: function () {
+ var el = this.options.infiniteElements;
+
+ this.infiniteElements = typeof el == 'string' ? document.querySelectorAll(el) : el;
+ 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 || 1000;
+ this.infiniteCacheBuffer = Math.round(this.options.cacheSize / 4);
+
+ //this.infiniteCache = {};
+ this.options.dataset.call(this, 0, this.options.cacheSize);
+
+ this.on('refresh', function () {
+ var elementsPerPage = Math.ceil(this.wrapperHeight / this.infiniteElementHeight);
+ this.infiniteUpperBufferSize = Math.floor((this.infiniteLength - elementsPerPage) / 2);
+ this.reorderInfinite();
+ });
+
+ this.on('scroll', this.reorderInfinite);
+ },
+
+ // TO-DO: clean up the mess
+ reorderInfinite: function () {
+ var center = -this.y + this.wrapperHeight / 2;
+
+ var minorPhase = Math.max(Math.floor(-this.y / this.infiniteElementHeight) - this.infiniteUpperBufferSize, 0),
+ majorPhase = Math.floor(minorPhase / this.infiniteLength),
+ phase = minorPhase - majorPhase * this.infiniteLength;
+
+ var top = 0;
+ var i = 0;
+ var update = [];
+
+ //var cachePhase = Math.floor((minorPhase + this.infiniteLength / 2) / this.infiniteCacheBuffer);
+ var cachePhase = Math.floor(minorPhase / this.infiniteCacheBuffer);
+
+ while ( i < this.infiniteLength ) {
+ top = i * this.infiniteElementHeight + majorPhase * this.infiniteHeight;
+
+ if ( phase > i ) {
+ top += this.infiniteElementHeight * this.infiniteLength;
+ }
+
+ if ( this.infiniteElements[i]._top !== top ) {
+ this.infiniteElements[i]._phase = top / this.infiniteElementHeight;
+
+ if ( this.infiniteElements[i]._phase < this.options.infiniteLimit ) {
+ this.infiniteElements[i]._top = top;
+ if ( this.options.infiniteUseTransform ) {
+ this.infiniteElements[i].style[utils.style.transform] = 'translate(0, ' + top + 'px)' + this.translateZ;
+ } else {
+ this.infiniteElements[i].style.top = top + 'px';
+ }
+ update.push(this.infiniteElements[i]);
+ }
+ }
+
+ i++;
+ }
+
+ if ( this.cachePhase != cachePhase && (cachePhase === 0 || minorPhase - this.infiniteCacheBuffer > 0) ) {
+ this.options.dataset.call(this, Math.max(cachePhase * this.infiniteCacheBuffer - this.infiniteCacheBuffer, 0), this.options.cacheSize);
+ }
+
+ this.cachePhase = cachePhase;
+
+ this.updateContent(update);
+ },
+
+ updateContent: function (els) {
+ if ( this.infiniteCache === undefined ) {
+ return;
+ }
+
+ for ( var i = 0, l = els.length; i < l; i++ ) {
+ this.options.dataFiller.call(this, els[i], this.infiniteCache[els[i]._phase]);
+ }
+ },
+
+ updateCache: function (start, data) {
+ var firstRun = this.infiniteCache === undefined;
+
+ this.infiniteCache = {};
+
+ for ( var i = 0, l = data.length; i < l; i++ ) {
+ this.infiniteCache[start++] = data[i];
+ }
+
+ if ( firstRun ) {
+ this.updateContent(this.infiniteElements);
+ }
+
+ },
+
+
+ handleEvent: function (e) {
+ switch ( e.type ) {
+ case 'touchstart':
+ case 'MSPointerDown':
+ case 'mousedown':
+ this._start(e);
+ break;
+ case 'touchmove':
+ case 'MSPointerMove':
+ case 'mousemove':
+ this._move(e);
+ break;
+ case 'touchend':
+ case 'MSPointerUp':
+ case 'mouseup':
+ case 'touchcancel':
+ case 'MSPointerCancel':
+ case 'mousecancel':
+ this._end(e);
+ break;
+ case 'orientationchange':
+ case 'resize':
+ this._resize();
+ break;
+ case 'transitionend':
+ case 'webkitTransitionEnd':
+ case 'oTransitionEnd':
+ case 'MSTransitionEnd':
+ this._transitionEnd(e);
+ break;
+ case 'wheel':
+ case 'DOMMouseScroll':
+ case 'mousewheel':
+ this._wheel(e);
+ break;
+ case 'keydown':
+ this._key(e);
+ break;
+ case 'click':
+ if ( !e._constructed ) {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ break;
+ }
+ }
+};
+IScroll.utils = utils;
+
+if ( typeof module != 'undefined' && module.exports ) {
+ module.exports = IScroll;
+} else {
+ window.IScroll = IScroll;
+}
+
+})(window, document, Math);
\ No newline at end of file
diff --git a/build/iscroll-lite.js b/build/iscroll-lite.js
new file mode 100644
index 0000000..5a0ab35
--- /dev/null
+++ b/build/iscroll-lite.js
@@ -0,0 +1,930 @@
+/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
+(function (window, document, Math) {
+var rAF = window.requestAnimationFrame ||
+ window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame ||
+ window.msRequestAnimationFrame ||
+ function (callback) { window.setTimeout(callback, 1000 / 60); };
+
+var utils = (function () {
+ var me = {};
+
+ var _elementStyle = document.createElement('div').style;
+ var _vendor = (function () {
+ var vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'],
+ transform,
+ i = 0,
+ l = vendors.length;
+
+ for ( ; i < l; i++ ) {
+ transform = vendors[i] + 'ransform';
+ if ( transform in _elementStyle ) return vendors[i].substr(0, vendors[i].length-1);
+ }
+
+ return false;
+ })();
+
+ function _prefixStyle (style) {
+ if ( _vendor === false ) return false;
+ if ( _vendor === '' ) return style;
+ return _vendor + style.charAt(0).toUpperCase() + style.substr(1);
+ }
+
+ me.getTime = Date.now || function getTime () { return new Date().getTime(); };
+
+ me.extend = function (target, obj) {
+ for ( var i in obj ) {
+ target[i] = obj[i];
+ }
+ };
+
+ me.addEvent = function (el, type, fn, capture) {
+ el.addEventListener(type, fn, !!capture);
+ };
+
+ me.removeEvent = function (el, type, fn, capture) {
+ el.removeEventListener(type, fn, !!capture);
+ };
+
+ me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
+ var distance = current - start,
+ speed = Math.abs(distance) / time,
+ destination,
+ duration;
+
+ deceleration = deceleration === undefined ? 0.0006 : deceleration;
+
+ destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );
+ duration = speed / deceleration;
+
+ if ( destination < lowerMargin ) {
+ destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin;
+ distance = Math.abs(destination - current);
+ duration = distance / speed;
+ } else if ( destination > 0 ) {
+ destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0;
+ distance = Math.abs(current) + destination;
+ duration = distance / speed;
+ }
+
+ return {
+ destination: Math.round(destination),
+ duration: duration
+ };
+ };
+
+ var _transform = _prefixStyle('transform');
+
+ me.extend(me, {
+ hasTransform: _transform !== false,
+ hasPerspective: _prefixStyle('perspective') in _elementStyle,
+ hasTouch: 'ontouchstart' in window,
+ hasPointer: navigator.msPointerEnabled,
+ hasTransition: _prefixStyle('transition') in _elementStyle
+ });
+
+ // This should find all Android browsers lower than build 535.19 (both stock browser and webview)
+ me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
+
+ me.extend(me.style = {}, {
+ transform: _transform,
+ transitionTimingFunction: _prefixStyle('transitionTimingFunction'),
+ transitionDuration: _prefixStyle('transitionDuration'),
+ transitionDelay: _prefixStyle('transitionDelay'),
+ transformOrigin: _prefixStyle('transformOrigin')
+ });
+
+ me.hasClass = function (e, c) {
+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)");
+ return re.test(e.className);
+ };
+
+ me.addClass = function (e, c) {
+ if ( me.hasClass(e, c) ) {
+ return;
+ }
+
+ var newclass = e.className.split(' ');
+ newclass.push(c);
+ e.className = newclass.join(' ');
+ };
+
+ me.removeClass = function (e, c) {
+ if ( !me.hasClass(e, c) ) {
+ return;
+ }
+
+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)", 'g');
+ e.className = e.className.replace(re, ' ');
+ };
+
+ me.offset = function (el) {
+ var left = -el.offsetLeft,
+ top = -el.offsetTop;
+
+ // jshint -W084
+ while (el = el.offsetParent) {
+ left -= el.offsetLeft;
+ top -= el.offsetTop;
+ }
+ // jshint +W084
+
+ return {
+ left: left,
+ top: top
+ };
+ };
+
+ me.preventDefaultException = function (el, exceptions) {
+ for ( var i in exceptions ) {
+ if ( exceptions[i].test(el[i]) ) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ me.extend(me.eventType = {}, {
+ touchstart: 1,
+ touchmove: 1,
+ touchend: 1,
+
+ mousedown: 2,
+ mousemove: 2,
+ mouseup: 2,
+
+ MSPointerDown: 3,
+ MSPointerMove: 3,
+ MSPointerUp: 3
+ });
+
+ me.extend(me.ease = {}, {
+ quadratic: {
+ style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
+ fn: function (k) {
+ return k * ( 2 - k );
+ }
+ },
+ circular: {
+ 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)
+ fn: function (k) {
+ return Math.sqrt( 1 - ( --k * k ) );
+ }
+ },
+ back: {
+ style: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
+ fn: function (k) {
+ var b = 4;
+ return ( k = k - 1 ) * k * ( ( b + 1 ) * k + b ) + 1;
+ }
+ },
+ bounce: {
+ style: '',
+ fn: function (k) {
+ if ( ( k /= 1 ) < ( 1 / 2.75 ) ) {
+ return 7.5625 * k * k;
+ } else if ( k < ( 2 / 2.75 ) ) {
+ return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75;
+ } else if ( k < ( 2.5 / 2.75 ) ) {
+ return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375;
+ } else {
+ return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375;
+ }
+ }
+ },
+ elastic: {
+ style: '',
+ fn: function (k) {
+ var f = 0.22,
+ e = 0.4;
+
+ if ( k === 0 ) { return 0; }
+ if ( k == 1 ) { return 1; }
+
+ return ( e * Math.pow( 2, - 10 * k ) * Math.sin( ( k - f / 4 ) * ( 2 * Math.PI ) / f ) + 1 );
+ }
+ }
+ });
+
+ me.tap = function (e, eventName) {
+ var ev = document.createEvent('Event');
+ ev.initEvent(eventName, true, true);
+ ev.pageX = e.pageX;
+ ev.pageY = e.pageY;
+ e.target.dispatchEvent(ev);
+ };
+
+ me.click = function (e) {
+ var target = e.target,
+ ev;
+
+ if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) {
+ ev = document.createEvent('MouseEvents');
+ ev.initMouseEvent('click', true, true, e.view, 1,
+ target.screenX, target.screenY, target.clientX, target.clientY,
+ e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
+ 0, null);
+
+ ev._constructed = true;
+ target.dispatchEvent(ev);
+ }
+ };
+
+ return me;
+})();
+
+function IScroll (el, options) {
+ this.wrapper = typeof el == 'string' ? document.querySelector(el) : el;
+ this.scroller = this.wrapper.children[0];
+ this.scrollerStyle = this.scroller.style; // cache style for better performance
+
+ this.options = {
+
+// INSERT POINT: OPTIONS
+
+ startX: 0,
+ startY: 0,
+ scrollY: true,
+ directionLockThreshold: 5,
+ momentum: true,
+
+ bounce: true,
+ bounceTime: 600,
+ bounceEasing: '',
+
+ preventDefault: true,
+ preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ },
+
+ HWCompositing: true,
+ useTransition: true,
+ useTransform: true
+ };
+
+ for ( var i in options ) {
+ this.options[i] = options[i];
+ }
+
+ // Normalize options
+ this.translateZ = this.options.HWCompositing && utils.hasPerspective ? ' translateZ(0)' : '';
+
+ this.options.useTransition = utils.hasTransition && this.options.useTransition;
+ this.options.useTransform = utils.hasTransform && this.options.useTransform;
+
+ this.options.eventPassthrough = this.options.eventPassthrough === true ? 'vertical' : this.options.eventPassthrough;
+ this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault;
+
+ // If you want eventPassthrough I have to lock one of the axes
+ this.options.scrollY = this.options.eventPassthrough == 'vertical' ? false : this.options.scrollY;
+ this.options.scrollX = this.options.eventPassthrough == 'horizontal' ? false : this.options.scrollX;
+
+ // With eventPassthrough we also need lockDirection mechanism
+ this.options.freeScroll = this.options.freeScroll && !this.options.eventPassthrough;
+ this.options.directionLockThreshold = this.options.eventPassthrough ? 0 : this.options.directionLockThreshold;
+
+ this.options.bounceEasing = typeof this.options.bounceEasing == 'string' ? utils.ease[this.options.bounceEasing] || utils.ease.circular : this.options.bounceEasing;
+
+ this.options.resizePolling = this.options.resizePolling === undefined ? 60 : this.options.resizePolling;
+
+ if ( this.options.tap === true ) {
+ this.options.tap = 'tap';
+ }
+
+// INSERT POINT: NORMALIZATION
+
+ // Some defaults
+ this.x = 0;
+ this.y = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+ this._events = {};
+
+// INSERT POINT: DEFAULTS
+
+ this._init();
+ this.refresh();
+
+ this.scrollTo(this.options.startX, this.options.startY);
+ this.enable();
+}
+
+IScroll.prototype = {
+ version: '5.1.1',
+
+ _init: function () {
+ this._initEvents();
+
+// INSERT POINT: _init
+
+ },
+
+ destroy: function () {
+ this._initEvents(true);
+
+ this._execEvent('destroy');
+ },
+
+ _transitionEnd: function (e) {
+ if ( e.target != this.scroller || !this.isInTransition ) {
+ return;
+ }
+
+ this._transitionTime();
+ if ( !this.resetPosition(this.options.bounceTime) ) {
+ this.isInTransition = false;
+ this._execEvent('scrollEnd');
+ }
+ },
+
+ _start: function (e) {
+ // React to left mouse button only
+ if ( utils.eventType[e.type] != 1 ) {
+ if ( e.button !== 0 ) {
+ return;
+ }
+ }
+
+ if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) {
+ return;
+ }
+
+ if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
+ e.preventDefault();
+ }
+
+ var point = e.touches ? e.touches[0] : e,
+ pos;
+
+ this.initiated = utils.eventType[e.type];
+ this.moved = false;
+ this.distX = 0;
+ this.distY = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+ this.directionLocked = 0;
+
+ this._transitionTime();
+
+ this.startTime = utils.getTime();
+
+ if ( this.options.useTransition && this.isInTransition ) {
+ this.isInTransition = false;
+ pos = this.getComputedPosition();
+ this._translate(Math.round(pos.x), Math.round(pos.y));
+ this._execEvent('scrollEnd');
+ } else if ( !this.options.useTransition && this.isAnimating ) {
+ this.isAnimating = false;
+ this._execEvent('scrollEnd');
+ }
+
+ this.startX = this.x;
+ this.startY = this.y;
+ this.absStartX = this.x;
+ this.absStartY = this.y;
+ this.pointX = point.pageX;
+ this.pointY = point.pageY;
+
+ this._execEvent('beforeScrollStart');
+ },
+
+ _move: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault ) { // increases performance on Android? TODO: check!
+ e.preventDefault();
+ }
+
+ var point = e.touches ? e.touches[0] : e,
+ deltaX = point.pageX - this.pointX,
+ deltaY = point.pageY - this.pointY,
+ timestamp = utils.getTime(),
+ newX, newY,
+ absDistX, absDistY;
+
+ this.pointX = point.pageX;
+ this.pointY = point.pageY;
+
+ this.distX += deltaX;
+ this.distY += deltaY;
+ absDistX = Math.abs(this.distX);
+ absDistY = Math.abs(this.distY);
+
+ // We need to move at least 10 pixels for the scrolling to initiate
+ if ( timestamp - this.endTime > 300 && (absDistX < 10 && absDistY < 10) ) {
+ return;
+ }
+
+ // If you are scrolling in one direction lock the other
+ if ( !this.directionLocked && !this.options.freeScroll ) {
+ if ( absDistX > absDistY + this.options.directionLockThreshold ) {
+ this.directionLocked = 'h'; // lock horizontally
+ } else if ( absDistY >= absDistX + this.options.directionLockThreshold ) {
+ this.directionLocked = 'v'; // lock vertically
+ } else {
+ this.directionLocked = 'n'; // no lock
+ }
+ }
+
+ if ( this.directionLocked == 'h' ) {
+ if ( this.options.eventPassthrough == 'vertical' ) {
+ e.preventDefault();
+ } else if ( this.options.eventPassthrough == 'horizontal' ) {
+ this.initiated = false;
+ return;
+ }
+
+ deltaY = 0;
+ } else if ( this.directionLocked == 'v' ) {
+ if ( this.options.eventPassthrough == 'horizontal' ) {
+ e.preventDefault();
+ } else if ( this.options.eventPassthrough == 'vertical' ) {
+ this.initiated = false;
+ return;
+ }
+
+ deltaX = 0;
+ }
+
+ deltaX = this.hasHorizontalScroll ? deltaX : 0;
+ deltaY = this.hasVerticalScroll ? deltaY : 0;
+
+ newX = this.x + deltaX;
+ newY = this.y + deltaY;
+
+ // Slow down if outside of the boundaries
+ if ( newX > 0 || newX < this.maxScrollX ) {
+ newX = this.options.bounce ? this.x + deltaX / 3 : newX > 0 ? 0 : this.maxScrollX;
+ }
+ if ( newY > 0 || newY < this.maxScrollY ) {
+ newY = this.options.bounce ? this.y + deltaY / 3 : newY > 0 ? 0 : this.maxScrollY;
+ }
+
+ this.directionX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
+ this.directionY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
+
+ if ( !this.moved ) {
+ this._execEvent('scrollStart');
+ }
+
+ this.moved = true;
+
+ this._translate(newX, newY);
+
+/* REPLACE START: _move */
+
+ if ( timestamp - this.startTime > 300 ) {
+ this.startTime = timestamp;
+ this.startX = this.x;
+ this.startY = this.y;
+ }
+
+/* REPLACE END: _move */
+
+ },
+
+ _end: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
+ e.preventDefault();
+ }
+
+ var point = e.changedTouches ? e.changedTouches[0] : e,
+ momentumX,
+ momentumY,
+ duration = utils.getTime() - this.startTime,
+ newX = Math.round(this.x),
+ newY = Math.round(this.y),
+ distanceX = Math.abs(newX - this.startX),
+ distanceY = Math.abs(newY - this.startY),
+ time = 0,
+ easing = '';
+
+ this.isInTransition = 0;
+ this.initiated = 0;
+ this.endTime = utils.getTime();
+
+ // reset if we are outside of the boundaries
+ if ( this.resetPosition(this.options.bounceTime) ) {
+ return;
+ }
+
+ this.scrollTo(newX, newY); // ensures that the last position is rounded
+
+ // we scrolled less than 10 pixels
+ if ( !this.moved ) {
+ if ( this.options.tap ) {
+ utils.tap(e, this.options.tap);
+ }
+
+ if ( this.options.click ) {
+ utils.click(e);
+ }
+
+ this._execEvent('scrollCancel');
+ return;
+ }
+
+ if ( this._events.flick && duration < 200 && distanceX < 100 && distanceY < 100 ) {
+ this._execEvent('flick');
+ return;
+ }
+
+ // start momentum animation if needed
+ if ( this.options.momentum && duration < 300 ) {
+ momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 };
+ momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 };
+ newX = momentumX.destination;
+ newY = momentumY.destination;
+ time = Math.max(momentumX.duration, momentumY.duration);
+ this.isInTransition = 1;
+ }
+
+// INSERT POINT: _end
+
+ if ( newX != this.x || newY != this.y ) {
+ // change easing function when scroller goes out of the boundaries
+ if ( newX > 0 || newX < this.maxScrollX || newY > 0 || newY < this.maxScrollY ) {
+ easing = utils.ease.quadratic;
+ }
+
+ this.scrollTo(newX, newY, time, easing);
+ return;
+ }
+
+ this._execEvent('scrollEnd');
+ },
+
+ _resize: function () {
+ var that = this;
+
+ clearTimeout(this.resizeTimeout);
+
+ this.resizeTimeout = setTimeout(function () {
+ that.refresh();
+ }, this.options.resizePolling);
+ },
+
+ resetPosition: function (time) {
+ var x = this.x,
+ y = this.y;
+
+ time = time || 0;
+
+ if ( !this.hasHorizontalScroll || this.x > 0 ) {
+ x = 0;
+ } else if ( this.x < this.maxScrollX ) {
+ x = this.maxScrollX;
+ }
+
+ if ( !this.hasVerticalScroll || this.y > 0 ) {
+ y = 0;
+ } else if ( this.y < this.maxScrollY ) {
+ y = this.maxScrollY;
+ }
+
+ if ( x == this.x && y == this.y ) {
+ return false;
+ }
+
+ this.scrollTo(x, y, time, this.options.bounceEasing);
+
+ return true;
+ },
+
+ disable: function () {
+ this.enabled = false;
+ },
+
+ enable: function () {
+ this.enabled = true;
+ },
+
+ refresh: function () {
+ var rf = this.wrapper.offsetHeight; // Force reflow
+
+ this.wrapperWidth = this.wrapper.clientWidth;
+ this.wrapperHeight = this.wrapper.clientHeight;
+
+/* REPLACE START: refresh */
+
+ this.scrollerWidth = this.scroller.offsetWidth;
+ this.scrollerHeight = this.scroller.offsetHeight;
+
+ this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
+ this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
+
+/* REPLACE END: refresh */
+
+ this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
+ this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
+
+ if ( !this.hasHorizontalScroll ) {
+ this.maxScrollX = 0;
+ this.scrollerWidth = this.wrapperWidth;
+ }
+
+ if ( !this.hasVerticalScroll ) {
+ this.maxScrollY = 0;
+ this.scrollerHeight = this.wrapperHeight;
+ }
+
+ this.endTime = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+
+ this.wrapperOffset = utils.offset(this.wrapper);
+
+ this._execEvent('refresh');
+
+ this.resetPosition();
+
+// INSERT POINT: _refresh
+
+ },
+
+ on: function (type, fn) {
+ if ( !this._events[type] ) {
+ this._events[type] = [];
+ }
+
+ this._events[type].push(fn);
+ },
+
+ off: function (type, fn) {
+ if ( !this._events[type] ) {
+ return;
+ }
+
+ var index = this._events[type].indexOf(fn);
+
+ if ( index > -1 ) {
+ this._events[type].splice(index, 1);
+ }
+ },
+
+ _execEvent: function (type) {
+ if ( !this._events[type] ) {
+ return;
+ }
+
+ var i = 0,
+ l = this._events[type].length;
+
+ if ( !l ) {
+ return;
+ }
+
+ for ( ; i < l; i++ ) {
+ this._events[type][i].apply(this, [].slice.call(arguments, 1));
+ }
+ },
+
+ scrollBy: function (x, y, time, easing) {
+ x = this.x + x;
+ y = this.y + y;
+ time = time || 0;
+
+ this.scrollTo(x, y, time, easing);
+ },
+
+ scrollTo: function (x, y, time, easing) {
+ easing = easing || utils.ease.circular;
+
+ this.isInTransition = this.options.useTransition && time > 0;
+
+ if ( !time || (this.options.useTransition && easing.style) ) {
+ this._transitionTimingFunction(easing.style);
+ this._transitionTime(time);
+ this._translate(x, y);
+ } else {
+ this._animate(x, y, time, easing.fn);
+ }
+ },
+
+ scrollToElement: function (el, time, offsetX, offsetY, easing) {
+ el = el.nodeType ? el : this.scroller.querySelector(el);
+
+ if ( !el ) {
+ return;
+ }
+
+ var pos = utils.offset(el);
+
+ pos.left -= this.wrapperOffset.left;
+ pos.top -= this.wrapperOffset.top;
+
+ // if offsetX/Y are true we center the element to the screen
+ if ( offsetX === true ) {
+ offsetX = Math.round(el.offsetWidth / 2 - this.wrapper.offsetWidth / 2);
+ }
+ if ( offsetY === true ) {
+ offsetY = Math.round(el.offsetHeight / 2 - this.wrapper.offsetHeight / 2);
+ }
+
+ pos.left -= offsetX || 0;
+ pos.top -= offsetY || 0;
+
+ pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left;
+ pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top;
+
+ time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(this.x-pos.left), Math.abs(this.y-pos.top)) : time;
+
+ this.scrollTo(pos.left, pos.top, time, easing);
+ },
+
+ _transitionTime: function (time) {
+ time = time || 0;
+
+ this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';
+
+ if ( !time && utils.isBadAndroid ) {
+ this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
+ }
+
+// INSERT POINT: _transitionTime
+
+ },
+
+ _transitionTimingFunction: function (easing) {
+ this.scrollerStyle[utils.style.transitionTimingFunction] = easing;
+
+// INSERT POINT: _transitionTimingFunction
+
+ },
+
+ _translate: function (x, y) {
+ if ( this.options.useTransform ) {
+
+/* REPLACE START: _translate */
+
+ this.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.translateZ;
+
+/* REPLACE END: _translate */
+
+ } else {
+ x = Math.round(x);
+ y = Math.round(y);
+ this.scrollerStyle.left = x + 'px';
+ this.scrollerStyle.top = y + 'px';
+ }
+
+ this.x = x;
+ this.y = y;
+
+// INSERT POINT: _translate
+
+ },
+
+ _initEvents: function (remove) {
+ var eventType = remove ? utils.removeEvent : utils.addEvent,
+ target = this.options.bindToWrapper ? this.wrapper : window;
+
+ eventType(window, 'orientationchange', this);
+ eventType(window, 'resize', this);
+
+ if ( this.options.click ) {
+ eventType(this.wrapper, 'click', this, true);
+ }
+
+ if ( !this.options.disableMouse ) {
+ eventType(this.wrapper, 'mousedown', this);
+ eventType(target, 'mousemove', this);
+ eventType(target, 'mousecancel', this);
+ eventType(target, 'mouseup', this);
+ }
+
+ if ( utils.hasPointer && !this.options.disablePointer ) {
+ eventType(this.wrapper, 'MSPointerDown', this);
+ eventType(target, 'MSPointerMove', this);
+ eventType(target, 'MSPointerCancel', this);
+ eventType(target, 'MSPointerUp', this);
+ }
+
+ if ( utils.hasTouch && !this.options.disableTouch ) {
+ eventType(this.wrapper, 'touchstart', this);
+ eventType(target, 'touchmove', this);
+ eventType(target, 'touchcancel', this);
+ eventType(target, 'touchend', this);
+ }
+
+ eventType(this.scroller, 'transitionend', this);
+ eventType(this.scroller, 'webkitTransitionEnd', this);
+ eventType(this.scroller, 'oTransitionEnd', this);
+ eventType(this.scroller, 'MSTransitionEnd', this);
+ },
+
+ getComputedPosition: function () {
+ var matrix = window.getComputedStyle(this.scroller, null),
+ x, y;
+
+ if ( this.options.useTransform ) {
+ matrix = matrix[utils.style.transform].split(')')[0].split(', ');
+ x = +(matrix[12] || matrix[4]);
+ y = +(matrix[13] || matrix[5]);
+ } else {
+ x = +matrix.left.replace(/[^-\d.]/g, '');
+ y = +matrix.top.replace(/[^-\d.]/g, '');
+ }
+
+ return { x: x, y: y };
+ },
+
+ _animate: function (destX, destY, duration, easingFn) {
+ var that = this,
+ startX = this.x,
+ startY = this.y,
+ startTime = utils.getTime(),
+ destTime = startTime + duration;
+
+ function step () {
+ var now = utils.getTime(),
+ newX, newY,
+ easing;
+
+ if ( now >= destTime ) {
+ that.isAnimating = false;
+ that._translate(destX, destY);
+
+ if ( !that.resetPosition(that.options.bounceTime) ) {
+ that._execEvent('scrollEnd');
+ }
+
+ return;
+ }
+
+ now = ( now - startTime ) / duration;
+ easing = easingFn(now);
+ newX = ( destX - startX ) * easing + startX;
+ newY = ( destY - startY ) * easing + startY;
+ that._translate(newX, newY);
+
+ if ( that.isAnimating ) {
+ rAF(step);
+ }
+ }
+
+ this.isAnimating = true;
+ step();
+ },
+ handleEvent: function (e) {
+ switch ( e.type ) {
+ case 'touchstart':
+ case 'MSPointerDown':
+ case 'mousedown':
+ this._start(e);
+ break;
+ case 'touchmove':
+ case 'MSPointerMove':
+ case 'mousemove':
+ this._move(e);
+ break;
+ case 'touchend':
+ case 'MSPointerUp':
+ case 'mouseup':
+ case 'touchcancel':
+ case 'MSPointerCancel':
+ case 'mousecancel':
+ this._end(e);
+ break;
+ case 'orientationchange':
+ case 'resize':
+ this._resize();
+ break;
+ case 'transitionend':
+ case 'webkitTransitionEnd':
+ case 'oTransitionEnd':
+ case 'MSTransitionEnd':
+ this._transitionEnd(e);
+ break;
+ case 'wheel':
+ case 'DOMMouseScroll':
+ case 'mousewheel':
+ this._wheel(e);
+ break;
+ case 'keydown':
+ this._key(e);
+ break;
+ case 'click':
+ if ( !e._constructed ) {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ break;
+ }
+ }
+};
+IScroll.utils = utils;
+
+if ( typeof module != 'undefined' && module.exports ) {
+ module.exports = IScroll;
+} else {
+ window.IScroll = IScroll;
+}
+
+})(window, document, Math);
\ No newline at end of file
diff --git a/build/iscroll-probe.js b/build/iscroll-probe.js
new file mode 100644
index 0000000..9a145f0
--- /dev/null
+++ b/build/iscroll-probe.js
@@ -0,0 +1,2015 @@
+/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
+(function (window, document, Math) {
+var rAF = window.requestAnimationFrame ||
+ window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame ||
+ window.msRequestAnimationFrame ||
+ function (callback) { window.setTimeout(callback, 1000 / 60); };
+
+var utils = (function () {
+ var me = {};
+
+ var _elementStyle = document.createElement('div').style;
+ var _vendor = (function () {
+ var vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'],
+ transform,
+ i = 0,
+ l = vendors.length;
+
+ for ( ; i < l; i++ ) {
+ transform = vendors[i] + 'ransform';
+ if ( transform in _elementStyle ) return vendors[i].substr(0, vendors[i].length-1);
+ }
+
+ return false;
+ })();
+
+ function _prefixStyle (style) {
+ if ( _vendor === false ) return false;
+ if ( _vendor === '' ) return style;
+ return _vendor + style.charAt(0).toUpperCase() + style.substr(1);
+ }
+
+ me.getTime = Date.now || function getTime () { return new Date().getTime(); };
+
+ me.extend = function (target, obj) {
+ for ( var i in obj ) {
+ target[i] = obj[i];
+ }
+ };
+
+ me.addEvent = function (el, type, fn, capture) {
+ el.addEventListener(type, fn, !!capture);
+ };
+
+ me.removeEvent = function (el, type, fn, capture) {
+ el.removeEventListener(type, fn, !!capture);
+ };
+
+ me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
+ var distance = current - start,
+ speed = Math.abs(distance) / time,
+ destination,
+ duration;
+
+ deceleration = deceleration === undefined ? 0.0006 : deceleration;
+
+ destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );
+ duration = speed / deceleration;
+
+ if ( destination < lowerMargin ) {
+ destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin;
+ distance = Math.abs(destination - current);
+ duration = distance / speed;
+ } else if ( destination > 0 ) {
+ destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0;
+ distance = Math.abs(current) + destination;
+ duration = distance / speed;
+ }
+
+ return {
+ destination: Math.round(destination),
+ duration: duration
+ };
+ };
+
+ var _transform = _prefixStyle('transform');
+
+ me.extend(me, {
+ hasTransform: _transform !== false,
+ hasPerspective: _prefixStyle('perspective') in _elementStyle,
+ hasTouch: 'ontouchstart' in window,
+ hasPointer: navigator.msPointerEnabled,
+ hasTransition: _prefixStyle('transition') in _elementStyle
+ });
+
+ // This should find all Android browsers lower than build 535.19 (both stock browser and webview)
+ me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
+
+ me.extend(me.style = {}, {
+ transform: _transform,
+ transitionTimingFunction: _prefixStyle('transitionTimingFunction'),
+ transitionDuration: _prefixStyle('transitionDuration'),
+ transitionDelay: _prefixStyle('transitionDelay'),
+ transformOrigin: _prefixStyle('transformOrigin')
+ });
+
+ me.hasClass = function (e, c) {
+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)");
+ return re.test(e.className);
+ };
+
+ me.addClass = function (e, c) {
+ if ( me.hasClass(e, c) ) {
+ return;
+ }
+
+ var newclass = e.className.split(' ');
+ newclass.push(c);
+ e.className = newclass.join(' ');
+ };
+
+ me.removeClass = function (e, c) {
+ if ( !me.hasClass(e, c) ) {
+ return;
+ }
+
+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)", 'g');
+ e.className = e.className.replace(re, ' ');
+ };
+
+ me.offset = function (el) {
+ var left = -el.offsetLeft,
+ top = -el.offsetTop;
+
+ // jshint -W084
+ while (el = el.offsetParent) {
+ left -= el.offsetLeft;
+ top -= el.offsetTop;
+ }
+ // jshint +W084
+
+ return {
+ left: left,
+ top: top
+ };
+ };
+
+ me.preventDefaultException = function (el, exceptions) {
+ for ( var i in exceptions ) {
+ if ( exceptions[i].test(el[i]) ) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ me.extend(me.eventType = {}, {
+ touchstart: 1,
+ touchmove: 1,
+ touchend: 1,
+
+ mousedown: 2,
+ mousemove: 2,
+ mouseup: 2,
+
+ MSPointerDown: 3,
+ MSPointerMove: 3,
+ MSPointerUp: 3
+ });
+
+ me.extend(me.ease = {}, {
+ quadratic: {
+ style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
+ fn: function (k) {
+ return k * ( 2 - k );
+ }
+ },
+ circular: {
+ 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)
+ fn: function (k) {
+ return Math.sqrt( 1 - ( --k * k ) );
+ }
+ },
+ back: {
+ style: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
+ fn: function (k) {
+ var b = 4;
+ return ( k = k - 1 ) * k * ( ( b + 1 ) * k + b ) + 1;
+ }
+ },
+ bounce: {
+ style: '',
+ fn: function (k) {
+ if ( ( k /= 1 ) < ( 1 / 2.75 ) ) {
+ return 7.5625 * k * k;
+ } else if ( k < ( 2 / 2.75 ) ) {
+ return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75;
+ } else if ( k < ( 2.5 / 2.75 ) ) {
+ return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375;
+ } else {
+ return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375;
+ }
+ }
+ },
+ elastic: {
+ style: '',
+ fn: function (k) {
+ var f = 0.22,
+ e = 0.4;
+
+ if ( k === 0 ) { return 0; }
+ if ( k == 1 ) { return 1; }
+
+ return ( e * Math.pow( 2, - 10 * k ) * Math.sin( ( k - f / 4 ) * ( 2 * Math.PI ) / f ) + 1 );
+ }
+ }
+ });
+
+ me.tap = function (e, eventName) {
+ var ev = document.createEvent('Event');
+ ev.initEvent(eventName, true, true);
+ ev.pageX = e.pageX;
+ ev.pageY = e.pageY;
+ e.target.dispatchEvent(ev);
+ };
+
+ me.click = function (e) {
+ var target = e.target,
+ ev;
+
+ if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) {
+ ev = document.createEvent('MouseEvents');
+ ev.initMouseEvent('click', true, true, e.view, 1,
+ target.screenX, target.screenY, target.clientX, target.clientY,
+ e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
+ 0, null);
+
+ ev._constructed = true;
+ target.dispatchEvent(ev);
+ }
+ };
+
+ return me;
+})();
+
+function IScroll (el, options) {
+ this.wrapper = typeof el == 'string' ? document.querySelector(el) : el;
+ this.scroller = this.wrapper.children[0];
+ this.scrollerStyle = this.scroller.style; // cache style for better performance
+
+ this.options = {
+
+ resizeScrollbars: true,
+
+ mouseWheelSpeed: 20,
+
+ snapThreshold: 0.334,
+
+// INSERT POINT: OPTIONS
+
+ startX: 0,
+ startY: 0,
+ scrollY: true,
+ directionLockThreshold: 5,
+ momentum: true,
+
+ bounce: true,
+ bounceTime: 600,
+ bounceEasing: '',
+
+ preventDefault: true,
+ preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ },
+
+ HWCompositing: true,
+ useTransition: true,
+ useTransform: true
+ };
+
+ for ( var i in options ) {
+ this.options[i] = options[i];
+ }
+
+ // Normalize options
+ this.translateZ = this.options.HWCompositing && utils.hasPerspective ? ' translateZ(0)' : '';
+
+ this.options.useTransition = utils.hasTransition && this.options.useTransition;
+ this.options.useTransform = utils.hasTransform && this.options.useTransform;
+
+ this.options.eventPassthrough = this.options.eventPassthrough === true ? 'vertical' : this.options.eventPassthrough;
+ this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault;
+
+ // If you want eventPassthrough I have to lock one of the axes
+ this.options.scrollY = this.options.eventPassthrough == 'vertical' ? false : this.options.scrollY;
+ this.options.scrollX = this.options.eventPassthrough == 'horizontal' ? false : this.options.scrollX;
+
+ // With eventPassthrough we also need lockDirection mechanism
+ this.options.freeScroll = this.options.freeScroll && !this.options.eventPassthrough;
+ this.options.directionLockThreshold = this.options.eventPassthrough ? 0 : this.options.directionLockThreshold;
+
+ this.options.bounceEasing = typeof this.options.bounceEasing == 'string' ? utils.ease[this.options.bounceEasing] || utils.ease.circular : this.options.bounceEasing;
+
+ this.options.resizePolling = this.options.resizePolling === undefined ? 60 : this.options.resizePolling;
+
+ if ( this.options.tap === true ) {
+ this.options.tap = 'tap';
+ }
+
+ if ( this.options.shrinkScrollbars == 'scale' ) {
+ this.options.useTransition = false;
+ }
+
+ this.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1;
+
+ if ( this.options.probeType == 3 ) {
+ this.options.useTransition = false; }
+
+// INSERT POINT: NORMALIZATION
+
+ // Some defaults
+ this.x = 0;
+ this.y = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+ this._events = {};
+
+// INSERT POINT: DEFAULTS
+
+ this._init();
+ this.refresh();
+
+ this.scrollTo(this.options.startX, this.options.startY);
+ this.enable();
+}
+
+IScroll.prototype = {
+ version: '5.1.1',
+
+ _init: function () {
+ this._initEvents();
+
+ if ( this.options.scrollbars || this.options.indicators ) {
+ this._initIndicators();
+ }
+
+ if ( this.options.mouseWheel ) {
+ this._initWheel();
+ }
+
+ if ( this.options.snap ) {
+ this._initSnap();
+ }
+
+ if ( this.options.keyBindings ) {
+ this._initKeys();
+ }
+
+// INSERT POINT: _init
+
+ },
+
+ destroy: function () {
+ this._initEvents(true);
+
+ this._execEvent('destroy');
+ },
+
+ _transitionEnd: function (e) {
+ if ( e.target != this.scroller || !this.isInTransition ) {
+ return;
+ }
+
+ this._transitionTime();
+ if ( !this.resetPosition(this.options.bounceTime) ) {
+ this.isInTransition = false;
+ this._execEvent('scrollEnd');
+ }
+ },
+
+ _start: function (e) {
+ // React to left mouse button only
+ if ( utils.eventType[e.type] != 1 ) {
+ if ( e.button !== 0 ) {
+ return;
+ }
+ }
+
+ if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) {
+ return;
+ }
+
+ if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
+ e.preventDefault();
+ }
+
+ var point = e.touches ? e.touches[0] : e,
+ pos;
+
+ this.initiated = utils.eventType[e.type];
+ this.moved = false;
+ this.distX = 0;
+ this.distY = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+ this.directionLocked = 0;
+
+ this._transitionTime();
+
+ this.startTime = utils.getTime();
+
+ if ( this.options.useTransition && this.isInTransition ) {
+ this.isInTransition = false;
+ pos = this.getComputedPosition();
+ this._translate(Math.round(pos.x), Math.round(pos.y));
+ this._execEvent('scrollEnd');
+ } else if ( !this.options.useTransition && this.isAnimating ) {
+ this.isAnimating = false;
+ this._execEvent('scrollEnd');
+ }
+
+ this.startX = this.x;
+ this.startY = this.y;
+ this.absStartX = this.x;
+ this.absStartY = this.y;
+ this.pointX = point.pageX;
+ this.pointY = point.pageY;
+
+ this._execEvent('beforeScrollStart');
+ },
+
+ _move: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault ) { // increases performance on Android? TODO: check!
+ e.preventDefault();
+ }
+
+ var point = e.touches ? e.touches[0] : e,
+ deltaX = point.pageX - this.pointX,
+ deltaY = point.pageY - this.pointY,
+ timestamp = utils.getTime(),
+ newX, newY,
+ absDistX, absDistY;
+
+ this.pointX = point.pageX;
+ this.pointY = point.pageY;
+
+ this.distX += deltaX;
+ this.distY += deltaY;
+ absDistX = Math.abs(this.distX);
+ absDistY = Math.abs(this.distY);
+
+ // We need to move at least 10 pixels for the scrolling to initiate
+ if ( timestamp - this.endTime > 300 && (absDistX < 10 && absDistY < 10) ) {
+ return;
+ }
+
+ // If you are scrolling in one direction lock the other
+ if ( !this.directionLocked && !this.options.freeScroll ) {
+ if ( absDistX > absDistY + this.options.directionLockThreshold ) {
+ this.directionLocked = 'h'; // lock horizontally
+ } else if ( absDistY >= absDistX + this.options.directionLockThreshold ) {
+ this.directionLocked = 'v'; // lock vertically
+ } else {
+ this.directionLocked = 'n'; // no lock
+ }
+ }
+
+ if ( this.directionLocked == 'h' ) {
+ if ( this.options.eventPassthrough == 'vertical' ) {
+ e.preventDefault();
+ } else if ( this.options.eventPassthrough == 'horizontal' ) {
+ this.initiated = false;
+ return;
+ }
+
+ deltaY = 0;
+ } else if ( this.directionLocked == 'v' ) {
+ if ( this.options.eventPassthrough == 'horizontal' ) {
+ e.preventDefault();
+ } else if ( this.options.eventPassthrough == 'vertical' ) {
+ this.initiated = false;
+ return;
+ }
+
+ deltaX = 0;
+ }
+
+ deltaX = this.hasHorizontalScroll ? deltaX : 0;
+ deltaY = this.hasVerticalScroll ? deltaY : 0;
+
+ newX = this.x + deltaX;
+ newY = this.y + deltaY;
+
+ // Slow down if outside of the boundaries
+ if ( newX > 0 || newX < this.maxScrollX ) {
+ newX = this.options.bounce ? this.x + deltaX / 3 : newX > 0 ? 0 : this.maxScrollX;
+ }
+ if ( newY > 0 || newY < this.maxScrollY ) {
+ newY = this.options.bounce ? this.y + deltaY / 3 : newY > 0 ? 0 : this.maxScrollY;
+ }
+
+ this.directionX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
+ this.directionY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
+
+ if ( !this.moved ) {
+ this._execEvent('scrollStart');
+ }
+
+ this.moved = true;
+
+ this._translate(newX, newY);
+
+/* REPLACE START: _move */
+ if ( timestamp - this.startTime > 300 ) {
+ this.startTime = timestamp;
+ this.startX = this.x;
+ this.startY = this.y;
+
+ if ( this.options.probeType == 1 ) {
+ this._execEvent('scroll');
+ }
+ }
+
+ if ( this.options.probeType > 1 ) {
+ this._execEvent('scroll');
+ }
+/* REPLACE END: _move */
+
+ },
+
+ _end: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
+ e.preventDefault();
+ }
+
+ var point = e.changedTouches ? e.changedTouches[0] : e,
+ momentumX,
+ momentumY,
+ duration = utils.getTime() - this.startTime,
+ newX = Math.round(this.x),
+ newY = Math.round(this.y),
+ distanceX = Math.abs(newX - this.startX),
+ distanceY = Math.abs(newY - this.startY),
+ time = 0,
+ easing = '';
+
+ this.isInTransition = 0;
+ this.initiated = 0;
+ this.endTime = utils.getTime();
+
+ // reset if we are outside of the boundaries
+ if ( this.resetPosition(this.options.bounceTime) ) {
+ return;
+ }
+
+ this.scrollTo(newX, newY); // ensures that the last position is rounded
+
+ // we scrolled less than 10 pixels
+ if ( !this.moved ) {
+ if ( this.options.tap ) {
+ utils.tap(e, this.options.tap);
+ }
+
+ if ( this.options.click ) {
+ utils.click(e);
+ }
+
+ this._execEvent('scrollCancel');
+ return;
+ }
+
+ if ( this._events.flick && duration < 200 && distanceX < 100 && distanceY < 100 ) {
+ this._execEvent('flick');
+ return;
+ }
+
+ // start momentum animation if needed
+ if ( this.options.momentum && duration < 300 ) {
+ momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 };
+ momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 };
+ newX = momentumX.destination;
+ newY = momentumY.destination;
+ time = Math.max(momentumX.duration, momentumY.duration);
+ this.isInTransition = 1;
+ }
+
+
+ if ( this.options.snap ) {
+ var snap = this._nearestSnap(newX, newY);
+ this.currentPage = snap;
+ time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(newX - snap.x), 1000),
+ Math.min(Math.abs(newY - snap.y), 1000)
+ ), 300);
+ newX = snap.x;
+ newY = snap.y;
+
+ this.directionX = 0;
+ this.directionY = 0;
+ easing = this.options.bounceEasing;
+ }
+
+// INSERT POINT: _end
+
+ if ( newX != this.x || newY != this.y ) {
+ // change easing function when scroller goes out of the boundaries
+ if ( newX > 0 || newX < this.maxScrollX || newY > 0 || newY < this.maxScrollY ) {
+ easing = utils.ease.quadratic;
+ }
+
+ this.scrollTo(newX, newY, time, easing);
+ return;
+ }
+
+ this._execEvent('scrollEnd');
+ },
+
+ _resize: function () {
+ var that = this;
+
+ clearTimeout(this.resizeTimeout);
+
+ this.resizeTimeout = setTimeout(function () {
+ that.refresh();
+ }, this.options.resizePolling);
+ },
+
+ resetPosition: function (time) {
+ var x = this.x,
+ y = this.y;
+
+ time = time || 0;
+
+ if ( !this.hasHorizontalScroll || this.x > 0 ) {
+ x = 0;
+ } else if ( this.x < this.maxScrollX ) {
+ x = this.maxScrollX;
+ }
+
+ if ( !this.hasVerticalScroll || this.y > 0 ) {
+ y = 0;
+ } else if ( this.y < this.maxScrollY ) {
+ y = this.maxScrollY;
+ }
+
+ if ( x == this.x && y == this.y ) {
+ return false;
+ }
+
+ this.scrollTo(x, y, time, this.options.bounceEasing);
+
+ return true;
+ },
+
+ disable: function () {
+ this.enabled = false;
+ },
+
+ enable: function () {
+ this.enabled = true;
+ },
+
+ refresh: function () {
+ var rf = this.wrapper.offsetHeight; // Force reflow
+
+ this.wrapperWidth = this.wrapper.clientWidth;
+ this.wrapperHeight = this.wrapper.clientHeight;
+
+/* REPLACE START: refresh */
+
+ this.scrollerWidth = this.scroller.offsetWidth;
+ this.scrollerHeight = this.scroller.offsetHeight;
+
+ this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
+ this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
+
+/* REPLACE END: refresh */
+
+ this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
+ this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
+
+ if ( !this.hasHorizontalScroll ) {
+ this.maxScrollX = 0;
+ this.scrollerWidth = this.wrapperWidth;
+ }
+
+ if ( !this.hasVerticalScroll ) {
+ this.maxScrollY = 0;
+ this.scrollerHeight = this.wrapperHeight;
+ }
+
+ this.endTime = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+
+ this.wrapperOffset = utils.offset(this.wrapper);
+
+ this._execEvent('refresh');
+
+ this.resetPosition();
+
+// INSERT POINT: _refresh
+
+ },
+
+ on: function (type, fn) {
+ if ( !this._events[type] ) {
+ this._events[type] = [];
+ }
+
+ this._events[type].push(fn);
+ },
+
+ off: function (type, fn) {
+ if ( !this._events[type] ) {
+ return;
+ }
+
+ var index = this._events[type].indexOf(fn);
+
+ if ( index > -1 ) {
+ this._events[type].splice(index, 1);
+ }
+ },
+
+ _execEvent: function (type) {
+ if ( !this._events[type] ) {
+ return;
+ }
+
+ var i = 0,
+ l = this._events[type].length;
+
+ if ( !l ) {
+ return;
+ }
+
+ for ( ; i < l; i++ ) {
+ this._events[type][i].apply(this, [].slice.call(arguments, 1));
+ }
+ },
+
+ scrollBy: function (x, y, time, easing) {
+ x = this.x + x;
+ y = this.y + y;
+ time = time || 0;
+
+ this.scrollTo(x, y, time, easing);
+ },
+
+ scrollTo: function (x, y, time, easing) {
+ easing = easing || utils.ease.circular;
+
+ this.isInTransition = this.options.useTransition && time > 0;
+
+ if ( !time || (this.options.useTransition && easing.style) ) {
+ this._transitionTimingFunction(easing.style);
+ this._transitionTime(time);
+ this._translate(x, y);
+ } else {
+ this._animate(x, y, time, easing.fn);
+ }
+ },
+
+ scrollToElement: function (el, time, offsetX, offsetY, easing) {
+ el = el.nodeType ? el : this.scroller.querySelector(el);
+
+ if ( !el ) {
+ return;
+ }
+
+ var pos = utils.offset(el);
+
+ pos.left -= this.wrapperOffset.left;
+ pos.top -= this.wrapperOffset.top;
+
+ // if offsetX/Y are true we center the element to the screen
+ if ( offsetX === true ) {
+ offsetX = Math.round(el.offsetWidth / 2 - this.wrapper.offsetWidth / 2);
+ }
+ if ( offsetY === true ) {
+ offsetY = Math.round(el.offsetHeight / 2 - this.wrapper.offsetHeight / 2);
+ }
+
+ pos.left -= offsetX || 0;
+ pos.top -= offsetY || 0;
+
+ pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left;
+ pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top;
+
+ time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(this.x-pos.left), Math.abs(this.y-pos.top)) : time;
+
+ this.scrollTo(pos.left, pos.top, time, easing);
+ },
+
+ _transitionTime: function (time) {
+ time = time || 0;
+
+ this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';
+
+ if ( !time && utils.isBadAndroid ) {
+ this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
+ }
+
+
+ if ( this.indicators ) {
+ for ( var i = this.indicators.length; i--; ) {
+ this.indicators[i].transitionTime(time);
+ }
+ }
+
+
+// INSERT POINT: _transitionTime
+
+ },
+
+ _transitionTimingFunction: function (easing) {
+ this.scrollerStyle[utils.style.transitionTimingFunction] = easing;
+
+
+ if ( this.indicators ) {
+ for ( var i = this.indicators.length; i--; ) {
+ this.indicators[i].transitionTimingFunction(easing);
+ }
+ }
+
+
+// INSERT POINT: _transitionTimingFunction
+
+ },
+
+ _translate: function (x, y) {
+ if ( this.options.useTransform ) {
+
+/* REPLACE START: _translate */
+
+ this.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.translateZ;
+
+/* REPLACE END: _translate */
+
+ } else {
+ x = Math.round(x);
+ y = Math.round(y);
+ this.scrollerStyle.left = x + 'px';
+ this.scrollerStyle.top = y + 'px';
+ }
+
+ this.x = x;
+ this.y = y;
+
+
+ if ( this.indicators ) {
+ for ( var i = this.indicators.length; i--; ) {
+ this.indicators[i].updatePosition();
+ }
+ }
+
+
+// INSERT POINT: _translate
+
+ },
+
+ _initEvents: function (remove) {
+ var eventType = remove ? utils.removeEvent : utils.addEvent,
+ target = this.options.bindToWrapper ? this.wrapper : window;
+
+ eventType(window, 'orientationchange', this);
+ eventType(window, 'resize', this);
+
+ if ( this.options.click ) {
+ eventType(this.wrapper, 'click', this, true);
+ }
+
+ if ( !this.options.disableMouse ) {
+ eventType(this.wrapper, 'mousedown', this);
+ eventType(target, 'mousemove', this);
+ eventType(target, 'mousecancel', this);
+ eventType(target, 'mouseup', this);
+ }
+
+ if ( utils.hasPointer && !this.options.disablePointer ) {
+ eventType(this.wrapper, 'MSPointerDown', this);
+ eventType(target, 'MSPointerMove', this);
+ eventType(target, 'MSPointerCancel', this);
+ eventType(target, 'MSPointerUp', this);
+ }
+
+ if ( utils.hasTouch && !this.options.disableTouch ) {
+ eventType(this.wrapper, 'touchstart', this);
+ eventType(target, 'touchmove', this);
+ eventType(target, 'touchcancel', this);
+ eventType(target, 'touchend', this);
+ }
+
+ eventType(this.scroller, 'transitionend', this);
+ eventType(this.scroller, 'webkitTransitionEnd', this);
+ eventType(this.scroller, 'oTransitionEnd', this);
+ eventType(this.scroller, 'MSTransitionEnd', this);
+ },
+
+ getComputedPosition: function () {
+ var matrix = window.getComputedStyle(this.scroller, null),
+ x, y;
+
+ if ( this.options.useTransform ) {
+ matrix = matrix[utils.style.transform].split(')')[0].split(', ');
+ x = +(matrix[12] || matrix[4]);
+ y = +(matrix[13] || matrix[5]);
+ } else {
+ x = +matrix.left.replace(/[^-\d.]/g, '');
+ y = +matrix.top.replace(/[^-\d.]/g, '');
+ }
+
+ return { x: x, y: y };
+ },
+
+ _initIndicators: function () {
+ var interactive = this.options.interactiveScrollbars,
+ customStyle = typeof this.options.scrollbars != 'string',
+ indicators = [],
+ indicator;
+
+ var that = this;
+
+ this.indicators = [];
+
+ if ( this.options.scrollbars ) {
+ // Vertical scrollbar
+ if ( this.options.scrollY ) {
+ indicator = {
+ el: createDefaultScrollbar('v', interactive, this.options.scrollbars),
+ interactive: interactive,
+ defaultScrollbars: true,
+ customStyle: customStyle,
+ resize: this.options.resizeScrollbars,
+ shrink: this.options.shrinkScrollbars,
+ fade: this.options.fadeScrollbars,
+ listenX: false
+ };
+
+ this.wrapper.appendChild(indicator.el);
+ indicators.push(indicator);
+ }
+
+ // Horizontal scrollbar
+ if ( this.options.scrollX ) {
+ indicator = {
+ el: createDefaultScrollbar('h', interactive, this.options.scrollbars),
+ interactive: interactive,
+ defaultScrollbars: true,
+ customStyle: customStyle,
+ resize: this.options.resizeScrollbars,
+ shrink: this.options.shrinkScrollbars,
+ fade: this.options.fadeScrollbars,
+ listenY: false
+ };
+
+ this.wrapper.appendChild(indicator.el);
+ indicators.push(indicator);
+ }
+ }
+
+ if ( this.options.indicators ) {
+ // TODO: check concat compatibility
+ indicators = indicators.concat(this.options.indicators);
+ }
+
+ for ( var i = indicators.length; i--; ) {
+ this.indicators.push( new Indicator(this, indicators[i]) );
+ }
+
+ // TODO: check if we can use array.map (wide compatibility and performance issues)
+ function _indicatorsMap (fn) {
+ for ( var i = that.indicators.length; i--; ) {
+ fn.call(that.indicators[i]);
+ }
+ }
+
+ if ( this.options.fadeScrollbars ) {
+ this.on('scrollEnd', function () {
+ _indicatorsMap(function () {
+ this.fade();
+ });
+ });
+
+ this.on('scrollCancel', function () {
+ _indicatorsMap(function () {
+ this.fade();
+ });
+ });
+
+ this.on('scrollStart', function () {
+ _indicatorsMap(function () {
+ this.fade(1);
+ });
+ });
+
+ this.on('beforeScrollStart', function () {
+ _indicatorsMap(function () {
+ this.fade(1, true);
+ });
+ });
+ }
+
+
+ this.on('refresh', function () {
+ _indicatorsMap(function () {
+ this.refresh();
+ });
+ });
+
+ this.on('destroy', function () {
+ _indicatorsMap(function () {
+ this.destroy();
+ });
+
+ delete this.indicators;
+ });
+ },
+
+ _initWheel: function () {
+ utils.addEvent(this.wrapper, 'wheel', this);
+ utils.addEvent(this.wrapper, 'mousewheel', this);
+ utils.addEvent(this.wrapper, 'DOMMouseScroll', this);
+
+ this.on('destroy', function () {
+ utils.removeEvent(this.wrapper, 'wheel', this);
+ utils.removeEvent(this.wrapper, 'mousewheel', this);
+ utils.removeEvent(this.wrapper, 'DOMMouseScroll', this);
+ });
+ },
+
+ _wheel: function (e) {
+ if ( !this.enabled ) {
+ return;
+ }
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ var wheelDeltaX, wheelDeltaY,
+ newX, newY,
+ that = this;
+
+ if ( this.wheelTimeout === undefined ) {
+ that._execEvent('scrollStart');
+ }
+
+ // Execute the scrollEnd event after 400ms the wheel stopped scrolling
+ clearTimeout(this.wheelTimeout);
+ this.wheelTimeout = setTimeout(function () {
+ that._execEvent('scrollEnd');
+ that.wheelTimeout = undefined;
+ }, 400);
+
+ if ( 'deltaX' in e ) {
+ wheelDeltaX = -e.deltaX;
+ wheelDeltaY = -e.deltaY;
+ } else if ( 'wheelDeltaX' in e ) {
+ wheelDeltaX = e.wheelDeltaX / 120 * this.options.mouseWheelSpeed;
+ wheelDeltaY = e.wheelDeltaY / 120 * this.options.mouseWheelSpeed;
+ } else if ( 'wheelDelta' in e ) {
+ wheelDeltaX = wheelDeltaY = e.wheelDelta / 120 * this.options.mouseWheelSpeed;
+ } else if ( 'detail' in e ) {
+ wheelDeltaX = wheelDeltaY = -e.detail / 3 * this.options.mouseWheelSpeed;
+ } else {
+ return;
+ }
+
+ wheelDeltaX *= this.options.invertWheelDirection;
+ wheelDeltaY *= this.options.invertWheelDirection;
+
+ if ( !this.hasVerticalScroll ) {
+ wheelDeltaX = wheelDeltaY;
+ wheelDeltaY = 0;
+ }
+
+ if ( this.options.snap ) {
+ newX = this.currentPage.pageX;
+ newY = this.currentPage.pageY;
+
+ if ( wheelDeltaX > 0 ) {
+ newX--;
+ } else if ( wheelDeltaX < 0 ) {
+ newX++;
+ }
+
+ if ( wheelDeltaY > 0 ) {
+ newY--;
+ } else if ( wheelDeltaY < 0 ) {
+ newY++;
+ }
+
+ this.goToPage(newX, newY);
+
+ return;
+ }
+
+ newX = this.x + Math.round(this.hasHorizontalScroll ? wheelDeltaX : 0);
+ newY = this.y + Math.round(this.hasVerticalScroll ? wheelDeltaY : 0);
+
+ if ( newX > 0 ) {
+ newX = 0;
+ } else if ( newX < this.maxScrollX ) {
+ newX = this.maxScrollX;
+ }
+
+ if ( newY > 0 ) {
+ newY = 0;
+ } else if ( newY < this.maxScrollY ) {
+ newY = this.maxScrollY;
+ }
+
+ this.scrollTo(newX, newY, 0);
+
+ if ( this.options.probeType > 1 ) {
+ this._execEvent('scroll');
+ }
+
+// INSERT POINT: _wheel
+ },
+
+ _initSnap: function () {
+ this.currentPage = {};
+
+ if ( typeof this.options.snap == 'string' ) {
+ this.options.snap = this.scroller.querySelectorAll(this.options.snap);
+ }
+
+ this.on('refresh', function () {
+ var i = 0, l,
+ m = 0, n,
+ cx, cy,
+ x = 0, y,
+ stepX = this.options.snapStepX || this.wrapperWidth,
+ stepY = this.options.snapStepY || this.wrapperHeight,
+ el;
+
+ this.pages = [];
+
+ if ( !this.wrapperWidth || !this.wrapperHeight || !this.scrollerWidth || !this.scrollerHeight ) {
+ return;
+ }
+
+ if ( this.options.snap === true ) {
+ cx = Math.round( stepX / 2 );
+ cy = Math.round( stepY / 2 );
+
+ while ( x > -this.scrollerWidth ) {
+ this.pages[i] = [];
+ l = 0;
+ y = 0;
+
+ while ( y > -this.scrollerHeight ) {
+ this.pages[i][l] = {
+ x: Math.max(x, this.maxScrollX),
+ y: Math.max(y, this.maxScrollY),
+ width: stepX,
+ height: stepY,
+ cx: x - cx,
+ cy: y - cy
+ };
+
+ y -= stepY;
+ l++;
+ }
+
+ x -= stepX;
+ i++;
+ }
+ } else {
+ el = this.options.snap;
+ l = el.length;
+ n = -1;
+
+ for ( ; i < l; i++ ) {
+ if ( i === 0 || el[i].offsetLeft <= el[i-1].offsetLeft ) {
+ m = 0;
+ n++;
+ }
+
+ if ( !this.pages[m] ) {
+ this.pages[m] = [];
+ }
+
+ x = Math.max(-el[i].offsetLeft, this.maxScrollX);
+ y = Math.max(-el[i].offsetTop, this.maxScrollY);
+ cx = x - Math.round(el[i].offsetWidth / 2);
+ cy = y - Math.round(el[i].offsetHeight / 2);
+
+ this.pages[m][n] = {
+ x: x,
+ y: y,
+ width: el[i].offsetWidth,
+ height: el[i].offsetHeight,
+ cx: cx,
+ cy: cy
+ };
+
+ if ( x > this.maxScrollX ) {
+ m++;
+ }
+ }
+ }
+
+ this.goToPage(this.currentPage.pageX || 0, this.currentPage.pageY || 0, 0);
+
+ // Update snap threshold if needed
+ if ( this.options.snapThreshold % 1 === 0 ) {
+ this.snapThresholdX = this.options.snapThreshold;
+ this.snapThresholdY = this.options.snapThreshold;
+ } else {
+ this.snapThresholdX = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width * this.options.snapThreshold);
+ this.snapThresholdY = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height * this.options.snapThreshold);
+ }
+ });
+
+ this.on('flick', function () {
+ var time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(this.x - this.startX), 1000),
+ Math.min(Math.abs(this.y - this.startY), 1000)
+ ), 300);
+
+ this.goToPage(
+ this.currentPage.pageX + this.directionX,
+ this.currentPage.pageY + this.directionY,
+ time
+ );
+ });
+ },
+
+ _nearestSnap: function (x, y) {
+ if ( !this.pages.length ) {
+ return { x: 0, y: 0, pageX: 0, pageY: 0 };
+ }
+
+ var i = 0,
+ l = this.pages.length,
+ m = 0;
+
+ // Check if we exceeded the snap threshold
+ if ( Math.abs(x - this.absStartX) < this.snapThresholdX &&
+ Math.abs(y - this.absStartY) < this.snapThresholdY ) {
+ return this.currentPage;
+ }
+
+ if ( x > 0 ) {
+ x = 0;
+ } else if ( x < this.maxScrollX ) {
+ x = this.maxScrollX;
+ }
+
+ if ( y > 0 ) {
+ y = 0;
+ } else if ( y < this.maxScrollY ) {
+ y = this.maxScrollY;
+ }
+
+ for ( ; i < l; i++ ) {
+ if ( x >= this.pages[i][0].cx ) {
+ x = this.pages[i][0].x;
+ break;
+ }
+ }
+
+ l = this.pages[i].length;
+
+ for ( ; m < l; m++ ) {
+ if ( y >= this.pages[0][m].cy ) {
+ y = this.pages[0][m].y;
+ break;
+ }
+ }
+
+ if ( i == this.currentPage.pageX ) {
+ i += this.directionX;
+
+ if ( i < 0 ) {
+ i = 0;
+ } else if ( i >= this.pages.length ) {
+ i = this.pages.length - 1;
+ }
+
+ x = this.pages[i][0].x;
+ }
+
+ if ( m == this.currentPage.pageY ) {
+ m += this.directionY;
+
+ if ( m < 0 ) {
+ m = 0;
+ } else if ( m >= this.pages[0].length ) {
+ m = this.pages[0].length - 1;
+ }
+
+ y = this.pages[0][m].y;
+ }
+
+ return {
+ x: x,
+ y: y,
+ pageX: i,
+ pageY: m
+ };
+ },
+
+ goToPage: function (x, y, time, easing) {
+ easing = easing || this.options.bounceEasing;
+
+ if ( x >= this.pages.length ) {
+ x = this.pages.length - 1;
+ } else if ( x < 0 ) {
+ x = 0;
+ }
+
+ if ( y >= this.pages[x].length ) {
+ y = this.pages[x].length - 1;
+ } else if ( y < 0 ) {
+ y = 0;
+ }
+
+ var posX = this.pages[x][y].x,
+ posY = this.pages[x][y].y;
+
+ time = time === undefined ? this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(posX - this.x), 1000),
+ Math.min(Math.abs(posY - this.y), 1000)
+ ), 300) : time;
+
+ this.currentPage = {
+ x: posX,
+ y: posY,
+ pageX: x,
+ pageY: y
+ };
+
+ this.scrollTo(posX, posY, time, easing);
+ },
+
+ next: function (time, easing) {
+ var x = this.currentPage.pageX,
+ y = this.currentPage.pageY;
+
+ x++;
+
+ if ( x >= this.pages.length && this.hasVerticalScroll ) {
+ x = 0;
+ y++;
+ }
+
+ this.goToPage(x, y, time, easing);
+ },
+
+ prev: function (time, easing) {
+ var x = this.currentPage.pageX,
+ y = this.currentPage.pageY;
+
+ x--;
+
+ if ( x < 0 && this.hasVerticalScroll ) {
+ x = 0;
+ y--;
+ }
+
+ this.goToPage(x, y, time, easing);
+ },
+
+ _initKeys: function (e) {
+ // default key bindings
+ var keys = {
+ pageUp: 33,
+ pageDown: 34,
+ end: 35,
+ home: 36,
+ left: 37,
+ up: 38,
+ right: 39,
+ down: 40
+ };
+ var i;
+
+ // if you give me characters I give you keycode
+ if ( typeof this.options.keyBindings == 'object' ) {
+ for ( i in this.options.keyBindings ) {
+ if ( typeof this.options.keyBindings[i] == 'string' ) {
+ this.options.keyBindings[i] = this.options.keyBindings[i].toUpperCase().charCodeAt(0);
+ }
+ }
+ } else {
+ this.options.keyBindings = {};
+ }
+
+ for ( i in keys ) {
+ this.options.keyBindings[i] = this.options.keyBindings[i] || keys[i];
+ }
+
+ utils.addEvent(window, 'keydown', this);
+
+ this.on('destroy', function () {
+ utils.removeEvent(window, 'keydown', this);
+ });
+ },
+
+ _key: function (e) {
+ if ( !this.enabled ) {
+ return;
+ }
+
+ var snap = this.options.snap, // we are using this alot, better to cache it
+ newX = snap ? this.currentPage.pageX : this.x,
+ newY = snap ? this.currentPage.pageY : this.y,
+ now = utils.getTime(),
+ prevTime = this.keyTime || 0,
+ acceleration = 0.250,
+ pos;
+
+ if ( this.options.useTransition && this.isInTransition ) {
+ pos = this.getComputedPosition();
+
+ this._translate(Math.round(pos.x), Math.round(pos.y));
+ this.isInTransition = false;
+ }
+
+ this.keyAcceleration = now - prevTime < 200 ? Math.min(this.keyAcceleration + acceleration, 50) : 0;
+
+ switch ( e.keyCode ) {
+ case this.options.keyBindings.pageUp:
+ if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
+ newX += snap ? 1 : this.wrapperWidth;
+ } else {
+ newY += snap ? 1 : this.wrapperHeight;
+ }
+ break;
+ case this.options.keyBindings.pageDown:
+ if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
+ newX -= snap ? 1 : this.wrapperWidth;
+ } else {
+ newY -= snap ? 1 : this.wrapperHeight;
+ }
+ break;
+ case this.options.keyBindings.end:
+ newX = snap ? this.pages.length-1 : this.maxScrollX;
+ newY = snap ? this.pages[0].length-1 : this.maxScrollY;
+ break;
+ case this.options.keyBindings.home:
+ newX = 0;
+ newY = 0;
+ break;
+ case this.options.keyBindings.left:
+ newX += snap ? -1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.up:
+ newY += snap ? 1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.right:
+ newX -= snap ? -1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.down:
+ newY -= snap ? 1 : 5 + this.keyAcceleration>>0;
+ break;
+ default:
+ return;
+ }
+
+ if ( snap ) {
+ this.goToPage(newX, newY);
+ return;
+ }
+
+ if ( newX > 0 ) {
+ newX = 0;
+ this.keyAcceleration = 0;
+ } else if ( newX < this.maxScrollX ) {
+ newX = this.maxScrollX;
+ this.keyAcceleration = 0;
+ }
+
+ if ( newY > 0 ) {
+ newY = 0;
+ this.keyAcceleration = 0;
+ } else if ( newY < this.maxScrollY ) {
+ newY = this.maxScrollY;
+ this.keyAcceleration = 0;
+ }
+
+ this.scrollTo(newX, newY, 0);
+
+ this.keyTime = now;
+ },
+
+ _animate: function (destX, destY, duration, easingFn) {
+ var that = this,
+ startX = this.x,
+ startY = this.y,
+ startTime = utils.getTime(),
+ destTime = startTime + duration;
+
+ function step () {
+ var now = utils.getTime(),
+ newX, newY,
+ easing;
+
+ if ( now >= destTime ) {
+ that.isAnimating = false;
+ that._translate(destX, destY);
+
+ if ( !that.resetPosition(that.options.bounceTime) ) {
+ that._execEvent('scrollEnd');
+ }
+
+ return;
+ }
+
+ now = ( now - startTime ) / duration;
+ easing = easingFn(now);
+ newX = ( destX - startX ) * easing + startX;
+ newY = ( destY - startY ) * easing + startY;
+ that._translate(newX, newY);
+
+ if ( that.isAnimating ) {
+ rAF(step);
+ }
+
+ if ( that.options.probeType == 3 ) {
+ that._execEvent('scroll');
+ }
+ }
+
+ this.isAnimating = true;
+ step();
+ },
+
+ handleEvent: function (e) {
+ switch ( e.type ) {
+ case 'touchstart':
+ case 'MSPointerDown':
+ case 'mousedown':
+ this._start(e);
+ break;
+ case 'touchmove':
+ case 'MSPointerMove':
+ case 'mousemove':
+ this._move(e);
+ break;
+ case 'touchend':
+ case 'MSPointerUp':
+ case 'mouseup':
+ case 'touchcancel':
+ case 'MSPointerCancel':
+ case 'mousecancel':
+ this._end(e);
+ break;
+ case 'orientationchange':
+ case 'resize':
+ this._resize();
+ break;
+ case 'transitionend':
+ case 'webkitTransitionEnd':
+ case 'oTransitionEnd':
+ case 'MSTransitionEnd':
+ this._transitionEnd(e);
+ break;
+ case 'wheel':
+ case 'DOMMouseScroll':
+ case 'mousewheel':
+ this._wheel(e);
+ break;
+ case 'keydown':
+ this._key(e);
+ break;
+ case 'click':
+ if ( !e._constructed ) {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ break;
+ }
+ }
+};
+function createDefaultScrollbar (direction, interactive, type) {
+ var scrollbar = document.createElement('div'),
+ indicator = document.createElement('div');
+
+ if ( type === true ) {
+ scrollbar.style.cssText = 'position:absolute;z-index:9999';
+ indicator.style.cssText = '-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px';
+ }
+
+ indicator.className = 'iScrollIndicator';
+
+ if ( direction == 'h' ) {
+ if ( type === true ) {
+ scrollbar.style.cssText += ';height:7px;left:2px;right:2px;bottom:0';
+ indicator.style.height = '100%';
+ }
+ scrollbar.className = 'iScrollHorizontalScrollbar';
+ } else {
+ if ( type === true ) {
+ scrollbar.style.cssText += ';width:7px;bottom:2px;top:2px;right:1px';
+ indicator.style.width = '100%';
+ }
+ scrollbar.className = 'iScrollVerticalScrollbar';
+ }
+
+ scrollbar.style.cssText += ';overflow:hidden';
+
+ if ( !interactive ) {
+ scrollbar.style.pointerEvents = 'none';
+ }
+
+ scrollbar.appendChild(indicator);
+
+ return scrollbar;
+}
+
+function Indicator (scroller, options) {
+ this.wrapper = typeof options.el == 'string' ? document.querySelector(options.el) : options.el;
+ this.wrapperStyle = this.wrapper.style;
+ this.indicator = this.wrapper.children[0];
+ this.indicatorStyle = this.indicator.style;
+ this.scroller = scroller;
+
+ this.options = {
+ listenX: true,
+ listenY: true,
+ interactive: false,
+ resize: true,
+ defaultScrollbars: false,
+ shrink: false,
+ fade: false,
+ speedRatioX: 0,
+ speedRatioY: 0
+ };
+
+ for ( var i in options ) {
+ this.options[i] = options[i];
+ }
+
+ this.sizeRatioX = 1;
+ this.sizeRatioY = 1;
+ this.maxPosX = 0;
+ this.maxPosY = 0;
+
+ if ( this.options.interactive ) {
+ if ( !this.options.disableTouch ) {
+ utils.addEvent(this.indicator, 'touchstart', this);
+ utils.addEvent(window, 'touchend', this);
+ }
+ if ( !this.options.disablePointer ) {
+ utils.addEvent(this.indicator, 'MSPointerDown', this);
+ utils.addEvent(window, 'MSPointerUp', this);
+ }
+ if ( !this.options.disableMouse ) {
+ utils.addEvent(this.indicator, 'mousedown', this);
+ utils.addEvent(window, 'mouseup', this);
+ }
+ }
+
+ if ( this.options.fade ) {
+ this.wrapperStyle[utils.style.transform] = this.scroller.translateZ;
+ this.wrapperStyle[utils.style.transitionDuration] = utils.isBadAndroid ? '0.001s' : '0ms';
+ this.wrapperStyle.opacity = '0';
+ }
+}
+
+Indicator.prototype = {
+ handleEvent: function (e) {
+ switch ( e.type ) {
+ case 'touchstart':
+ case 'MSPointerDown':
+ case 'mousedown':
+ this._start(e);
+ break;
+ case 'touchmove':
+ case 'MSPointerMove':
+ case 'mousemove':
+ this._move(e);
+ break;
+ case 'touchend':
+ case 'MSPointerUp':
+ case 'mouseup':
+ case 'touchcancel':
+ case 'MSPointerCancel':
+ case 'mousecancel':
+ this._end(e);
+ break;
+ }
+ },
+
+ destroy: function () {
+ if ( this.options.interactive ) {
+ utils.removeEvent(this.indicator, 'touchstart', this);
+ utils.removeEvent(this.indicator, 'MSPointerDown', this);
+ utils.removeEvent(this.indicator, 'mousedown', this);
+
+ utils.removeEvent(window, 'touchmove', this);
+ utils.removeEvent(window, 'MSPointerMove', this);
+ utils.removeEvent(window, 'mousemove', this);
+
+ utils.removeEvent(window, 'touchend', this);
+ utils.removeEvent(window, 'MSPointerUp', this);
+ utils.removeEvent(window, 'mouseup', this);
+ }
+
+ if ( this.options.defaultScrollbars ) {
+ this.wrapper.parentNode.removeChild(this.wrapper);
+ }
+ },
+
+ _start: function (e) {
+ var point = e.touches ? e.touches[0] : e;
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ this.transitionTime();
+
+ this.initiated = true;
+ this.moved = false;
+ this.lastPointX = point.pageX;
+ this.lastPointY = point.pageY;
+
+ this.startTime = utils.getTime();
+
+ if ( !this.options.disableTouch ) {
+ utils.addEvent(window, 'touchmove', this);
+ }
+ if ( !this.options.disablePointer ) {
+ utils.addEvent(window, 'MSPointerMove', this);
+ }
+ if ( !this.options.disableMouse ) {
+ utils.addEvent(window, 'mousemove', this);
+ }
+
+ this.scroller._execEvent('beforeScrollStart');
+ },
+
+ _move: function (e) {
+ var point = e.touches ? e.touches[0] : e,
+ deltaX, deltaY,
+ newX, newY,
+ timestamp = utils.getTime();
+
+ if ( !this.moved ) {
+ this.scroller._execEvent('scrollStart');
+ }
+
+ this.moved = true;
+
+ deltaX = point.pageX - this.lastPointX;
+ this.lastPointX = point.pageX;
+
+ deltaY = point.pageY - this.lastPointY;
+ this.lastPointY = point.pageY;
+
+ newX = this.x + deltaX;
+ newY = this.y + deltaY;
+
+ this._pos(newX, newY);
+
+
+ if ( this.scroller.options.probeType == 1 && timestamp - this.startTime > 300 ) {
+ this.startTime = timestamp;
+ this.scroller._execEvent('scroll');
+ } else if ( this.scroller.options.probeType > 1 ) {
+ this.scroller._execEvent('scroll');
+ }
+
+
+// INSERT POINT: indicator._move
+
+ e.preventDefault();
+ e.stopPropagation();
+ },
+
+ _end: function (e) {
+ if ( !this.initiated ) {
+ return;
+ }
+
+ this.initiated = false;
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ utils.removeEvent(window, 'touchmove', this);
+ utils.removeEvent(window, 'MSPointerMove', this);
+ utils.removeEvent(window, 'mousemove', this);
+
+ if ( this.scroller.options.snap ) {
+ var snap = this.scroller._nearestSnap(this.scroller.x, this.scroller.y);
+
+ var time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(this.scroller.x - snap.x), 1000),
+ Math.min(Math.abs(this.scroller.y - snap.y), 1000)
+ ), 300);
+
+ if ( this.scroller.x != snap.x || this.scroller.y != snap.y ) {
+ this.scroller.directionX = 0;
+ this.scroller.directionY = 0;
+ this.scroller.currentPage = snap;
+ this.scroller.scrollTo(snap.x, snap.y, time, this.scroller.options.bounceEasing);
+ }
+ }
+
+ if ( this.moved ) {
+ this.scroller._execEvent('scrollEnd');
+ }
+ },
+
+ transitionTime: function (time) {
+ time = time || 0;
+ this.indicatorStyle[utils.style.transitionDuration] = time + 'ms';
+
+ if ( !time && utils.isBadAndroid ) {
+ this.indicatorStyle[utils.style.transitionDuration] = '0.001s';
+ }
+ },
+
+ transitionTimingFunction: function (easing) {
+ this.indicatorStyle[utils.style.transitionTimingFunction] = easing;
+ },
+
+ refresh: function () {
+ this.transitionTime();
+
+ if ( this.options.listenX && !this.options.listenY ) {
+ this.indicatorStyle.display = this.scroller.hasHorizontalScroll ? 'block' : 'none';
+ } else if ( this.options.listenY && !this.options.listenX ) {
+ this.indicatorStyle.display = this.scroller.hasVerticalScroll ? 'block' : 'none';
+ } else {
+ this.indicatorStyle.display = this.scroller.hasHorizontalScroll || this.scroller.hasVerticalScroll ? 'block' : 'none';
+ }
+
+ if ( this.scroller.hasHorizontalScroll && this.scroller.hasVerticalScroll ) {
+ utils.addClass(this.wrapper, 'iScrollBothScrollbars');
+ utils.removeClass(this.wrapper, 'iScrollLoneScrollbar');
+
+ if ( this.options.defaultScrollbars && this.options.customStyle ) {
+ if ( this.options.listenX ) {
+ this.wrapper.style.right = '8px';
+ } else {
+ this.wrapper.style.bottom = '8px';
+ }
+ }
+ } else {
+ utils.removeClass(this.wrapper, 'iScrollBothScrollbars');
+ utils.addClass(this.wrapper, 'iScrollLoneScrollbar');
+
+ if ( this.options.defaultScrollbars && this.options.customStyle ) {
+ if ( this.options.listenX ) {
+ this.wrapper.style.right = '2px';
+ } else {
+ this.wrapper.style.bottom = '2px';
+ }
+ }
+ }
+
+ var r = this.wrapper.offsetHeight; // force refresh
+
+ if ( this.options.listenX ) {
+ this.wrapperWidth = this.wrapper.clientWidth;
+ if ( this.options.resize ) {
+ this.indicatorWidth = Math.max(Math.round(this.wrapperWidth * this.wrapperWidth / (this.scroller.scrollerWidth || this.wrapperWidth || 1)), 8);
+ this.indicatorStyle.width = this.indicatorWidth + 'px';
+ } else {
+ this.indicatorWidth = this.indicator.clientWidth;
+ }
+
+ this.maxPosX = this.wrapperWidth - this.indicatorWidth;
+
+ if ( this.options.shrink == 'clip' ) {
+ this.minBoundaryX = -this.indicatorWidth + 8;
+ this.maxBoundaryX = this.wrapperWidth - 8;
+ } else {
+ this.minBoundaryX = 0;
+ this.maxBoundaryX = this.maxPosX;
+ }
+
+ this.sizeRatioX = this.options.speedRatioX || (this.scroller.maxScrollX && (this.maxPosX / this.scroller.maxScrollX));
+ }
+
+ if ( this.options.listenY ) {
+ this.wrapperHeight = this.wrapper.clientHeight;
+ if ( this.options.resize ) {
+ this.indicatorHeight = Math.max(Math.round(this.wrapperHeight * this.wrapperHeight / (this.scroller.scrollerHeight || this.wrapperHeight || 1)), 8);
+ this.indicatorStyle.height = this.indicatorHeight + 'px';
+ } else {
+ this.indicatorHeight = this.indicator.clientHeight;
+ }
+
+ this.maxPosY = this.wrapperHeight - this.indicatorHeight;
+
+ if ( this.options.shrink == 'clip' ) {
+ this.minBoundaryY = -this.indicatorHeight + 8;
+ this.maxBoundaryY = this.wrapperHeight - 8;
+ } else {
+ 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 x = this.options.listenX && Math.round(this.sizeRatioX * this.scroller.x) || 0,
+ y = this.options.listenY && Math.round(this.sizeRatioY * this.scroller.y) || 0;
+
+ if ( !this.options.ignoreBoundaries ) {
+ if ( x < this.minBoundaryX ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.width = Math.max(this.indicatorWidth + x, 8);
+ this.indicatorStyle.width = this.width + 'px';
+ }
+ x = this.minBoundaryX;
+ } else if ( x > this.maxBoundaryX ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.width = Math.max(this.indicatorWidth - (x - this.maxPosX), 8);
+ this.indicatorStyle.width = this.width + 'px';
+ x = this.maxPosX + this.indicatorWidth - this.width;
+ } else {
+ x = this.maxBoundaryX;
+ }
+ } else if ( this.options.shrink == 'scale' && this.width != this.indicatorWidth ) {
+ this.width = this.indicatorWidth;
+ this.indicatorStyle.width = this.width + 'px';
+ }
+
+ if ( y < this.minBoundaryY ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.height = Math.max(this.indicatorHeight + y * 3, 8);
+ this.indicatorStyle.height = this.height + 'px';
+ }
+ y = this.minBoundaryY;
+ } else if ( y > this.maxBoundaryY ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.height = Math.max(this.indicatorHeight - (y - this.maxPosY) * 3, 8);
+ this.indicatorStyle.height = this.height + 'px';
+ y = this.maxPosY + this.indicatorHeight - this.height;
+ } else {
+ y = this.maxBoundaryY;
+ }
+ } else if ( this.options.shrink == 'scale' && this.height != this.indicatorHeight ) {
+ this.height = this.indicatorHeight;
+ this.indicatorStyle.height = this.height + 'px';
+ }
+ }
+
+ this.x = x;
+ this.y = y;
+
+ if ( this.scroller.options.useTransform ) {
+ this.indicatorStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.scroller.translateZ;
+ } else {
+ this.indicatorStyle.left = x + 'px';
+ this.indicatorStyle.top = y + 'px';
+ }
+ },
+
+ _pos: function (x, y) {
+ if ( x < 0 ) {
+ x = 0;
+ } else if ( x > this.maxPosX ) {
+ x = this.maxPosX;
+ }
+
+ if ( y < 0 ) {
+ y = 0;
+ } else if ( y > this.maxPosY ) {
+ y = this.maxPosY;
+ }
+
+ x = this.options.listenX ? Math.round(x / this.sizeRatioX) : this.scroller.x;
+ y = this.options.listenY ? Math.round(y / this.sizeRatioY) : this.scroller.y;
+
+ this.scroller.scrollTo(x, y);
+ },
+
+ fade: function (val, hold) {
+ if ( hold && !this.visible ) {
+ return;
+ }
+
+ clearTimeout(this.fadeTimeout);
+ this.fadeTimeout = null;
+
+ var time = val ? 250 : 500,
+ delay = val ? 0 : 300;
+
+ val = val ? '1' : '0';
+
+ this.wrapperStyle[utils.style.transitionDuration] = time + 'ms';
+
+ this.fadeTimeout = setTimeout((function (val) {
+ this.wrapperStyle.opacity = val;
+ this.visible = +val;
+ }).bind(this, val), delay);
+ }
+};
+
+IScroll.utils = utils;
+
+if ( typeof module != 'undefined' && module.exports ) {
+ module.exports = IScroll;
+} else {
+ window.IScroll = IScroll;
+}
+
+})(window, document, Math);
\ No newline at end of file
diff --git a/build/iscroll-zoom.js b/build/iscroll-zoom.js
new file mode 100644
index 0000000..4a44055
--- /dev/null
+++ b/build/iscroll-zoom.js
@@ -0,0 +1,2172 @@
+/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
+(function (window, document, Math) {
+var rAF = window.requestAnimationFrame ||
+ window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame ||
+ window.msRequestAnimationFrame ||
+ function (callback) { window.setTimeout(callback, 1000 / 60); };
+
+var utils = (function () {
+ var me = {};
+
+ var _elementStyle = document.createElement('div').style;
+ var _vendor = (function () {
+ var vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'],
+ transform,
+ i = 0,
+ l = vendors.length;
+
+ for ( ; i < l; i++ ) {
+ transform = vendors[i] + 'ransform';
+ if ( transform in _elementStyle ) return vendors[i].substr(0, vendors[i].length-1);
+ }
+
+ return false;
+ })();
+
+ function _prefixStyle (style) {
+ if ( _vendor === false ) return false;
+ if ( _vendor === '' ) return style;
+ return _vendor + style.charAt(0).toUpperCase() + style.substr(1);
+ }
+
+ me.getTime = Date.now || function getTime () { return new Date().getTime(); };
+
+ me.extend = function (target, obj) {
+ for ( var i in obj ) {
+ target[i] = obj[i];
+ }
+ };
+
+ me.addEvent = function (el, type, fn, capture) {
+ el.addEventListener(type, fn, !!capture);
+ };
+
+ me.removeEvent = function (el, type, fn, capture) {
+ el.removeEventListener(type, fn, !!capture);
+ };
+
+ me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
+ var distance = current - start,
+ speed = Math.abs(distance) / time,
+ destination,
+ duration;
+
+ deceleration = deceleration === undefined ? 0.0006 : deceleration;
+
+ destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );
+ duration = speed / deceleration;
+
+ if ( destination < lowerMargin ) {
+ destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin;
+ distance = Math.abs(destination - current);
+ duration = distance / speed;
+ } else if ( destination > 0 ) {
+ destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0;
+ distance = Math.abs(current) + destination;
+ duration = distance / speed;
+ }
+
+ return {
+ destination: Math.round(destination),
+ duration: duration
+ };
+ };
+
+ var _transform = _prefixStyle('transform');
+
+ me.extend(me, {
+ hasTransform: _transform !== false,
+ hasPerspective: _prefixStyle('perspective') in _elementStyle,
+ hasTouch: 'ontouchstart' in window,
+ hasPointer: navigator.msPointerEnabled,
+ hasTransition: _prefixStyle('transition') in _elementStyle
+ });
+
+ // This should find all Android browsers lower than build 535.19 (both stock browser and webview)
+ me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
+
+ me.extend(me.style = {}, {
+ transform: _transform,
+ transitionTimingFunction: _prefixStyle('transitionTimingFunction'),
+ transitionDuration: _prefixStyle('transitionDuration'),
+ transitionDelay: _prefixStyle('transitionDelay'),
+ transformOrigin: _prefixStyle('transformOrigin')
+ });
+
+ me.hasClass = function (e, c) {
+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)");
+ return re.test(e.className);
+ };
+
+ me.addClass = function (e, c) {
+ if ( me.hasClass(e, c) ) {
+ return;
+ }
+
+ var newclass = e.className.split(' ');
+ newclass.push(c);
+ e.className = newclass.join(' ');
+ };
+
+ me.removeClass = function (e, c) {
+ if ( !me.hasClass(e, c) ) {
+ return;
+ }
+
+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)", 'g');
+ e.className = e.className.replace(re, ' ');
+ };
+
+ me.offset = function (el) {
+ var left = -el.offsetLeft,
+ top = -el.offsetTop;
+
+ // jshint -W084
+ while (el = el.offsetParent) {
+ left -= el.offsetLeft;
+ top -= el.offsetTop;
+ }
+ // jshint +W084
+
+ return {
+ left: left,
+ top: top
+ };
+ };
+
+ me.preventDefaultException = function (el, exceptions) {
+ for ( var i in exceptions ) {
+ if ( exceptions[i].test(el[i]) ) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ me.extend(me.eventType = {}, {
+ touchstart: 1,
+ touchmove: 1,
+ touchend: 1,
+
+ mousedown: 2,
+ mousemove: 2,
+ mouseup: 2,
+
+ MSPointerDown: 3,
+ MSPointerMove: 3,
+ MSPointerUp: 3
+ });
+
+ me.extend(me.ease = {}, {
+ quadratic: {
+ style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
+ fn: function (k) {
+ return k * ( 2 - k );
+ }
+ },
+ circular: {
+ 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)
+ fn: function (k) {
+ return Math.sqrt( 1 - ( --k * k ) );
+ }
+ },
+ back: {
+ style: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
+ fn: function (k) {
+ var b = 4;
+ return ( k = k - 1 ) * k * ( ( b + 1 ) * k + b ) + 1;
+ }
+ },
+ bounce: {
+ style: '',
+ fn: function (k) {
+ if ( ( k /= 1 ) < ( 1 / 2.75 ) ) {
+ return 7.5625 * k * k;
+ } else if ( k < ( 2 / 2.75 ) ) {
+ return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75;
+ } else if ( k < ( 2.5 / 2.75 ) ) {
+ return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375;
+ } else {
+ return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375;
+ }
+ }
+ },
+ elastic: {
+ style: '',
+ fn: function (k) {
+ var f = 0.22,
+ e = 0.4;
+
+ if ( k === 0 ) { return 0; }
+ if ( k == 1 ) { return 1; }
+
+ return ( e * Math.pow( 2, - 10 * k ) * Math.sin( ( k - f / 4 ) * ( 2 * Math.PI ) / f ) + 1 );
+ }
+ }
+ });
+
+ me.tap = function (e, eventName) {
+ var ev = document.createEvent('Event');
+ ev.initEvent(eventName, true, true);
+ ev.pageX = e.pageX;
+ ev.pageY = e.pageY;
+ e.target.dispatchEvent(ev);
+ };
+
+ me.click = function (e) {
+ var target = e.target,
+ ev;
+
+ if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) {
+ ev = document.createEvent('MouseEvents');
+ ev.initMouseEvent('click', true, true, e.view, 1,
+ target.screenX, target.screenY, target.clientX, target.clientY,
+ e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
+ 0, null);
+
+ ev._constructed = true;
+ target.dispatchEvent(ev);
+ }
+ };
+
+ return me;
+})();
+
+function IScroll (el, options) {
+ this.wrapper = typeof el == 'string' ? document.querySelector(el) : el;
+ this.scroller = this.wrapper.children[0];
+ this.scrollerStyle = this.scroller.style; // cache style for better performance
+
+ this.options = {
+
+ zoomMin: 1,
+ zoomMax: 4, startZoom: 1,
+
+ resizeScrollbars: true,
+
+ mouseWheelSpeed: 20,
+
+ snapThreshold: 0.334,
+
+// INSERT POINT: OPTIONS
+
+ startX: 0,
+ startY: 0,
+ scrollY: true,
+ directionLockThreshold: 5,
+ momentum: true,
+
+ bounce: true,
+ bounceTime: 600,
+ bounceEasing: '',
+
+ preventDefault: true,
+ preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ },
+
+ HWCompositing: true,
+ useTransition: true,
+ useTransform: true
+ };
+
+ for ( var i in options ) {
+ this.options[i] = options[i];
+ }
+
+ // Normalize options
+ this.translateZ = this.options.HWCompositing && utils.hasPerspective ? ' translateZ(0)' : '';
+
+ this.options.useTransition = utils.hasTransition && this.options.useTransition;
+ this.options.useTransform = utils.hasTransform && this.options.useTransform;
+
+ this.options.eventPassthrough = this.options.eventPassthrough === true ? 'vertical' : this.options.eventPassthrough;
+ this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault;
+
+ // If you want eventPassthrough I have to lock one of the axes
+ this.options.scrollY = this.options.eventPassthrough == 'vertical' ? false : this.options.scrollY;
+ this.options.scrollX = this.options.eventPassthrough == 'horizontal' ? false : this.options.scrollX;
+
+ // With eventPassthrough we also need lockDirection mechanism
+ this.options.freeScroll = this.options.freeScroll && !this.options.eventPassthrough;
+ this.options.directionLockThreshold = this.options.eventPassthrough ? 0 : this.options.directionLockThreshold;
+
+ this.options.bounceEasing = typeof this.options.bounceEasing == 'string' ? utils.ease[this.options.bounceEasing] || utils.ease.circular : this.options.bounceEasing;
+
+ this.options.resizePolling = this.options.resizePolling === undefined ? 60 : this.options.resizePolling;
+
+ if ( this.options.tap === true ) {
+ this.options.tap = 'tap';
+ }
+
+ if ( this.options.shrinkScrollbars == 'scale' ) {
+ this.options.useTransition = false;
+ }
+
+ this.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1;
+
+// INSERT POINT: NORMALIZATION
+
+ // Some defaults
+ this.x = 0;
+ this.y = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+ this._events = {};
+
+ this.scale = Math.min(Math.max(this.options.startZoom, this.options.zoomMin), this.options.zoomMax);
+
+// INSERT POINT: DEFAULTS
+
+ this._init();
+ this.refresh();
+
+ this.scrollTo(this.options.startX, this.options.startY);
+ this.enable();
+}
+
+IScroll.prototype = {
+ version: '5.1.1',
+
+ _init: function () {
+ this._initEvents();
+
+ if ( this.options.zoom ) {
+ this._initZoom();
+ }
+
+ if ( this.options.scrollbars || this.options.indicators ) {
+ this._initIndicators();
+ }
+
+ if ( this.options.mouseWheel ) {
+ this._initWheel();
+ }
+
+ if ( this.options.snap ) {
+ this._initSnap();
+ }
+
+ if ( this.options.keyBindings ) {
+ this._initKeys();
+ }
+
+// INSERT POINT: _init
+
+ },
+
+ destroy: function () {
+ this._initEvents(true);
+
+ this._execEvent('destroy');
+ },
+
+ _transitionEnd: function (e) {
+ if ( e.target != this.scroller || !this.isInTransition ) {
+ return;
+ }
+
+ this._transitionTime();
+ if ( !this.resetPosition(this.options.bounceTime) ) {
+ this.isInTransition = false;
+ this._execEvent('scrollEnd');
+ }
+ },
+
+ _start: function (e) {
+ // React to left mouse button only
+ if ( utils.eventType[e.type] != 1 ) {
+ if ( e.button !== 0 ) {
+ return;
+ }
+ }
+
+ if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) {
+ return;
+ }
+
+ if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
+ e.preventDefault();
+ }
+
+ var point = e.touches ? e.touches[0] : e,
+ pos;
+
+ this.initiated = utils.eventType[e.type];
+ this.moved = false;
+ this.distX = 0;
+ this.distY = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+ this.directionLocked = 0;
+
+ this._transitionTime();
+
+ this.startTime = utils.getTime();
+
+ if ( this.options.useTransition && this.isInTransition ) {
+ this.isInTransition = false;
+ pos = this.getComputedPosition();
+ this._translate(Math.round(pos.x), Math.round(pos.y));
+ this._execEvent('scrollEnd');
+ } else if ( !this.options.useTransition && this.isAnimating ) {
+ this.isAnimating = false;
+ this._execEvent('scrollEnd');
+ }
+
+ this.startX = this.x;
+ this.startY = this.y;
+ this.absStartX = this.x;
+ this.absStartY = this.y;
+ this.pointX = point.pageX;
+ this.pointY = point.pageY;
+
+ this._execEvent('beforeScrollStart');
+ },
+
+ _move: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault ) { // increases performance on Android? TODO: check!
+ e.preventDefault();
+ }
+
+ var point = e.touches ? e.touches[0] : e,
+ deltaX = point.pageX - this.pointX,
+ deltaY = point.pageY - this.pointY,
+ timestamp = utils.getTime(),
+ newX, newY,
+ absDistX, absDistY;
+
+ this.pointX = point.pageX;
+ this.pointY = point.pageY;
+
+ this.distX += deltaX;
+ this.distY += deltaY;
+ absDistX = Math.abs(this.distX);
+ absDistY = Math.abs(this.distY);
+
+ // We need to move at least 10 pixels for the scrolling to initiate
+ if ( timestamp - this.endTime > 300 && (absDistX < 10 && absDistY < 10) ) {
+ return;
+ }
+
+ // If you are scrolling in one direction lock the other
+ if ( !this.directionLocked && !this.options.freeScroll ) {
+ if ( absDistX > absDistY + this.options.directionLockThreshold ) {
+ this.directionLocked = 'h'; // lock horizontally
+ } else if ( absDistY >= absDistX + this.options.directionLockThreshold ) {
+ this.directionLocked = 'v'; // lock vertically
+ } else {
+ this.directionLocked = 'n'; // no lock
+ }
+ }
+
+ if ( this.directionLocked == 'h' ) {
+ if ( this.options.eventPassthrough == 'vertical' ) {
+ e.preventDefault();
+ } else if ( this.options.eventPassthrough == 'horizontal' ) {
+ this.initiated = false;
+ return;
+ }
+
+ deltaY = 0;
+ } else if ( this.directionLocked == 'v' ) {
+ if ( this.options.eventPassthrough == 'horizontal' ) {
+ e.preventDefault();
+ } else if ( this.options.eventPassthrough == 'vertical' ) {
+ this.initiated = false;
+ return;
+ }
+
+ deltaX = 0;
+ }
+
+ deltaX = this.hasHorizontalScroll ? deltaX : 0;
+ deltaY = this.hasVerticalScroll ? deltaY : 0;
+
+ newX = this.x + deltaX;
+ newY = this.y + deltaY;
+
+ // Slow down if outside of the boundaries
+ if ( newX > 0 || newX < this.maxScrollX ) {
+ newX = this.options.bounce ? this.x + deltaX / 3 : newX > 0 ? 0 : this.maxScrollX;
+ }
+ if ( newY > 0 || newY < this.maxScrollY ) {
+ newY = this.options.bounce ? this.y + deltaY / 3 : newY > 0 ? 0 : this.maxScrollY;
+ }
+
+ this.directionX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
+ this.directionY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
+
+ if ( !this.moved ) {
+ this._execEvent('scrollStart');
+ }
+
+ this.moved = true;
+
+ this._translate(newX, newY);
+
+/* REPLACE START: _move */
+
+ if ( timestamp - this.startTime > 300 ) {
+ this.startTime = timestamp;
+ this.startX = this.x;
+ this.startY = this.y;
+ }
+
+/* REPLACE END: _move */
+
+ },
+
+ _end: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
+ e.preventDefault();
+ }
+
+ var point = e.changedTouches ? e.changedTouches[0] : e,
+ momentumX,
+ momentumY,
+ duration = utils.getTime() - this.startTime,
+ newX = Math.round(this.x),
+ newY = Math.round(this.y),
+ distanceX = Math.abs(newX - this.startX),
+ distanceY = Math.abs(newY - this.startY),
+ time = 0,
+ easing = '';
+
+ this.isInTransition = 0;
+ this.initiated = 0;
+ this.endTime = utils.getTime();
+
+ // reset if we are outside of the boundaries
+ if ( this.resetPosition(this.options.bounceTime) ) {
+ return;
+ }
+
+ this.scrollTo(newX, newY); // ensures that the last position is rounded
+
+ // we scrolled less than 10 pixels
+ if ( !this.moved ) {
+ if ( this.options.tap ) {
+ utils.tap(e, this.options.tap);
+ }
+
+ if ( this.options.click ) {
+ utils.click(e);
+ }
+
+ this._execEvent('scrollCancel');
+ return;
+ }
+
+ if ( this._events.flick && duration < 200 && distanceX < 100 && distanceY < 100 ) {
+ this._execEvent('flick');
+ return;
+ }
+
+ // start momentum animation if needed
+ if ( this.options.momentum && duration < 300 ) {
+ momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 };
+ momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 };
+ newX = momentumX.destination;
+ newY = momentumY.destination;
+ time = Math.max(momentumX.duration, momentumY.duration);
+ this.isInTransition = 1;
+ }
+
+
+ if ( this.options.snap ) {
+ var snap = this._nearestSnap(newX, newY);
+ this.currentPage = snap;
+ time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(newX - snap.x), 1000),
+ Math.min(Math.abs(newY - snap.y), 1000)
+ ), 300);
+ newX = snap.x;
+ newY = snap.y;
+
+ this.directionX = 0;
+ this.directionY = 0;
+ easing = this.options.bounceEasing;
+ }
+
+// INSERT POINT: _end
+
+ if ( newX != this.x || newY != this.y ) {
+ // change easing function when scroller goes out of the boundaries
+ if ( newX > 0 || newX < this.maxScrollX || newY > 0 || newY < this.maxScrollY ) {
+ easing = utils.ease.quadratic;
+ }
+
+ this.scrollTo(newX, newY, time, easing);
+ return;
+ }
+
+ this._execEvent('scrollEnd');
+ },
+
+ _resize: function () {
+ var that = this;
+
+ clearTimeout(this.resizeTimeout);
+
+ this.resizeTimeout = setTimeout(function () {
+ that.refresh();
+ }, this.options.resizePolling);
+ },
+
+ resetPosition: function (time) {
+ var x = this.x,
+ y = this.y;
+
+ time = time || 0;
+
+ if ( !this.hasHorizontalScroll || this.x > 0 ) {
+ x = 0;
+ } else if ( this.x < this.maxScrollX ) {
+ x = this.maxScrollX;
+ }
+
+ if ( !this.hasVerticalScroll || this.y > 0 ) {
+ y = 0;
+ } else if ( this.y < this.maxScrollY ) {
+ y = this.maxScrollY;
+ }
+
+ if ( x == this.x && y == this.y ) {
+ return false;
+ }
+
+ this.scrollTo(x, y, time, this.options.bounceEasing);
+
+ return true;
+ },
+
+ disable: function () {
+ this.enabled = false;
+ },
+
+ enable: function () {
+ this.enabled = true;
+ },
+
+ refresh: function () {
+ var rf = this.wrapper.offsetHeight; // Force reflow
+
+ this.wrapperWidth = this.wrapper.clientWidth;
+ this.wrapperHeight = this.wrapper.clientHeight;
+
+/* REPLACE START: refresh */
+ this.scrollerWidth = Math.round(this.scroller.offsetWidth * this.scale);
+ this.scrollerHeight = Math.round(this.scroller.offsetHeight * this.scale);
+
+ this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
+ this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
+/* REPLACE END: refresh */
+
+ this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
+ this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
+
+ if ( !this.hasHorizontalScroll ) {
+ this.maxScrollX = 0;
+ this.scrollerWidth = this.wrapperWidth;
+ }
+
+ if ( !this.hasVerticalScroll ) {
+ this.maxScrollY = 0;
+ this.scrollerHeight = this.wrapperHeight;
+ }
+
+ this.endTime = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+
+ this.wrapperOffset = utils.offset(this.wrapper);
+
+ this._execEvent('refresh');
+
+ this.resetPosition();
+
+// INSERT POINT: _refresh
+
+ },
+
+ on: function (type, fn) {
+ if ( !this._events[type] ) {
+ this._events[type] = [];
+ }
+
+ this._events[type].push(fn);
+ },
+
+ off: function (type, fn) {
+ if ( !this._events[type] ) {
+ return;
+ }
+
+ var index = this._events[type].indexOf(fn);
+
+ if ( index > -1 ) {
+ this._events[type].splice(index, 1);
+ }
+ },
+
+ _execEvent: function (type) {
+ if ( !this._events[type] ) {
+ return;
+ }
+
+ var i = 0,
+ l = this._events[type].length;
+
+ if ( !l ) {
+ return;
+ }
+
+ for ( ; i < l; i++ ) {
+ this._events[type][i].apply(this, [].slice.call(arguments, 1));
+ }
+ },
+
+ scrollBy: function (x, y, time, easing) {
+ x = this.x + x;
+ y = this.y + y;
+ time = time || 0;
+
+ this.scrollTo(x, y, time, easing);
+ },
+
+ scrollTo: function (x, y, time, easing) {
+ easing = easing || utils.ease.circular;
+
+ this.isInTransition = this.options.useTransition && time > 0;
+
+ if ( !time || (this.options.useTransition && easing.style) ) {
+ this._transitionTimingFunction(easing.style);
+ this._transitionTime(time);
+ this._translate(x, y);
+ } else {
+ this._animate(x, y, time, easing.fn);
+ }
+ },
+
+ scrollToElement: function (el, time, offsetX, offsetY, easing) {
+ el = el.nodeType ? el : this.scroller.querySelector(el);
+
+ if ( !el ) {
+ return;
+ }
+
+ var pos = utils.offset(el);
+
+ pos.left -= this.wrapperOffset.left;
+ pos.top -= this.wrapperOffset.top;
+
+ // if offsetX/Y are true we center the element to the screen
+ if ( offsetX === true ) {
+ offsetX = Math.round(el.offsetWidth / 2 - this.wrapper.offsetWidth / 2);
+ }
+ if ( offsetY === true ) {
+ offsetY = Math.round(el.offsetHeight / 2 - this.wrapper.offsetHeight / 2);
+ }
+
+ pos.left -= offsetX || 0;
+ pos.top -= offsetY || 0;
+
+ pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left;
+ pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top;
+
+ time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(this.x-pos.left), Math.abs(this.y-pos.top)) : time;
+
+ this.scrollTo(pos.left, pos.top, time, easing);
+ },
+
+ _transitionTime: function (time) {
+ time = time || 0;
+
+ this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';
+
+ if ( !time && utils.isBadAndroid ) {
+ this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
+ }
+
+
+ if ( this.indicators ) {
+ for ( var i = this.indicators.length; i--; ) {
+ this.indicators[i].transitionTime(time);
+ }
+ }
+
+
+// INSERT POINT: _transitionTime
+
+ },
+
+ _transitionTimingFunction: function (easing) {
+ this.scrollerStyle[utils.style.transitionTimingFunction] = easing;
+
+
+ if ( this.indicators ) {
+ for ( var i = this.indicators.length; i--; ) {
+ this.indicators[i].transitionTimingFunction(easing);
+ }
+ }
+
+
+// INSERT POINT: _transitionTimingFunction
+
+ },
+
+ _translate: function (x, y) {
+ if ( this.options.useTransform ) {
+
+/* REPLACE START: _translate */ this.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px) scale(' + this.scale + ') ' + this.translateZ;/* REPLACE END: _translate */
+
+ } else {
+ x = Math.round(x);
+ y = Math.round(y);
+ this.scrollerStyle.left = x + 'px';
+ this.scrollerStyle.top = y + 'px';
+ }
+
+ this.x = x;
+ this.y = y;
+
+
+ if ( this.indicators ) {
+ for ( var i = this.indicators.length; i--; ) {
+ this.indicators[i].updatePosition();
+ }
+ }
+
+
+// INSERT POINT: _translate
+
+ },
+
+ _initEvents: function (remove) {
+ var eventType = remove ? utils.removeEvent : utils.addEvent,
+ target = this.options.bindToWrapper ? this.wrapper : window;
+
+ eventType(window, 'orientationchange', this);
+ eventType(window, 'resize', this);
+
+ if ( this.options.click ) {
+ eventType(this.wrapper, 'click', this, true);
+ }
+
+ if ( !this.options.disableMouse ) {
+ eventType(this.wrapper, 'mousedown', this);
+ eventType(target, 'mousemove', this);
+ eventType(target, 'mousecancel', this);
+ eventType(target, 'mouseup', this);
+ }
+
+ if ( utils.hasPointer && !this.options.disablePointer ) {
+ eventType(this.wrapper, 'MSPointerDown', this);
+ eventType(target, 'MSPointerMove', this);
+ eventType(target, 'MSPointerCancel', this);
+ eventType(target, 'MSPointerUp', this);
+ }
+
+ if ( utils.hasTouch && !this.options.disableTouch ) {
+ eventType(this.wrapper, 'touchstart', this);
+ eventType(target, 'touchmove', this);
+ eventType(target, 'touchcancel', this);
+ eventType(target, 'touchend', this);
+ }
+
+ eventType(this.scroller, 'transitionend', this);
+ eventType(this.scroller, 'webkitTransitionEnd', this);
+ eventType(this.scroller, 'oTransitionEnd', this);
+ eventType(this.scroller, 'MSTransitionEnd', this);
+ },
+
+ getComputedPosition: function () {
+ var matrix = window.getComputedStyle(this.scroller, null),
+ x, y;
+
+ if ( this.options.useTransform ) {
+ matrix = matrix[utils.style.transform].split(')')[0].split(', ');
+ x = +(matrix[12] || matrix[4]);
+ y = +(matrix[13] || matrix[5]);
+ } else {
+ x = +matrix.left.replace(/[^-\d.]/g, '');
+ y = +matrix.top.replace(/[^-\d.]/g, '');
+ }
+
+ return { x: x, y: y };
+ },
+
+ _initIndicators: function () {
+ var interactive = this.options.interactiveScrollbars,
+ customStyle = typeof this.options.scrollbars != 'string',
+ indicators = [],
+ indicator;
+
+ var that = this;
+
+ this.indicators = [];
+
+ if ( this.options.scrollbars ) {
+ // Vertical scrollbar
+ if ( this.options.scrollY ) {
+ indicator = {
+ el: createDefaultScrollbar('v', interactive, this.options.scrollbars),
+ interactive: interactive,
+ defaultScrollbars: true,
+ customStyle: customStyle,
+ resize: this.options.resizeScrollbars,
+ shrink: this.options.shrinkScrollbars,
+ fade: this.options.fadeScrollbars,
+ listenX: false
+ };
+
+ this.wrapper.appendChild(indicator.el);
+ indicators.push(indicator);
+ }
+
+ // Horizontal scrollbar
+ if ( this.options.scrollX ) {
+ indicator = {
+ el: createDefaultScrollbar('h', interactive, this.options.scrollbars),
+ interactive: interactive,
+ defaultScrollbars: true,
+ customStyle: customStyle,
+ resize: this.options.resizeScrollbars,
+ shrink: this.options.shrinkScrollbars,
+ fade: this.options.fadeScrollbars,
+ listenY: false
+ };
+
+ this.wrapper.appendChild(indicator.el);
+ indicators.push(indicator);
+ }
+ }
+
+ if ( this.options.indicators ) {
+ // TODO: check concat compatibility
+ indicators = indicators.concat(this.options.indicators);
+ }
+
+ for ( var i = indicators.length; i--; ) {
+ this.indicators.push( new Indicator(this, indicators[i]) );
+ }
+
+ // TODO: check if we can use array.map (wide compatibility and performance issues)
+ function _indicatorsMap (fn) {
+ for ( var i = that.indicators.length; i--; ) {
+ fn.call(that.indicators[i]);
+ }
+ }
+
+ if ( this.options.fadeScrollbars ) {
+ this.on('scrollEnd', function () {
+ _indicatorsMap(function () {
+ this.fade();
+ });
+ });
+
+ this.on('scrollCancel', function () {
+ _indicatorsMap(function () {
+ this.fade();
+ });
+ });
+
+ this.on('scrollStart', function () {
+ _indicatorsMap(function () {
+ this.fade(1);
+ });
+ });
+
+ this.on('beforeScrollStart', function () {
+ _indicatorsMap(function () {
+ this.fade(1, true);
+ });
+ });
+ }
+
+
+ this.on('refresh', function () {
+ _indicatorsMap(function () {
+ this.refresh();
+ });
+ });
+
+ this.on('destroy', function () {
+ _indicatorsMap(function () {
+ this.destroy();
+ });
+
+ delete this.indicators;
+ });
+ },
+
+ _initZoom: function () {
+ this.scrollerStyle[utils.style.transformOrigin] = '0 0';
+ },
+
+ _zoomStart: function (e) {
+ var c1 = Math.abs( e.touches[0].pageX - e.touches[1].pageX ),
+ c2 = Math.abs( e.touches[0].pageY - e.touches[1].pageY );
+
+ this.touchesDistanceStart = Math.sqrt(c1 * c1 + c2 * c2);
+ this.startScale = this.scale;
+
+ this.originX = Math.abs(e.touches[0].pageX + e.touches[1].pageX) / 2 + this.wrapperOffset.left - this.x;
+ this.originY = Math.abs(e.touches[0].pageY + e.touches[1].pageY) / 2 + this.wrapperOffset.top - this.y;
+
+ this._execEvent('zoomStart');
+ },
+
+ _zoom: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault ) {
+ e.preventDefault();
+ }
+
+ var c1 = Math.abs( e.touches[0].pageX - e.touches[1].pageX ),
+ c2 = Math.abs( e.touches[0].pageY - e.touches[1].pageY ),
+ distance = Math.sqrt( c1 * c1 + c2 * c2 ),
+ scale = 1 / this.touchesDistanceStart * distance * this.startScale,
+ lastScale,
+ x, y;
+
+ this.scaled = true;
+
+ if ( scale < this.options.zoomMin ) {
+ scale = 0.5 * this.options.zoomMin * Math.pow(2.0, scale / this.options.zoomMin);
+ } else if ( scale > this.options.zoomMax ) {
+ scale = 2.0 * this.options.zoomMax * Math.pow(0.5, this.options.zoomMax / scale);
+ }
+
+ lastScale = scale / this.startScale;
+ x = this.originX - this.originX * lastScale + this.startX;
+ y = this.originY - this.originY * lastScale + this.startY;
+
+ this.scale = scale;
+
+ this.scrollTo(x, y, 0);
+ },
+
+ _zoomEnd: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault ) {
+ e.preventDefault();
+ }
+
+ var newX, newY,
+ lastScale;
+
+ this.isInTransition = 0;
+ this.initiated = 0;
+
+ if ( this.scale > this.options.zoomMax ) {
+ this.scale = this.options.zoomMax;
+ } else if ( this.scale < this.options.zoomMin ) {
+ this.scale = this.options.zoomMin;
+ }
+
+ // Update boundaries
+ this.refresh();
+
+ lastScale = this.scale / this.startScale;
+
+ newX = this.originX - this.originX * lastScale + this.startX;
+ newY = this.originY - this.originY * lastScale + this.startY;
+
+ if ( newX > 0 ) {
+ newX = 0;
+ } else if ( newX < this.maxScrollX ) {
+ newX = this.maxScrollX;
+ }
+
+ if ( newY > 0 ) {
+ newY = 0;
+ } else if ( newY < this.maxScrollY ) {
+ newY = this.maxScrollY;
+ }
+
+ if ( this.x != newX || this.y != newY ) {
+ this.scrollTo(newX, newY, this.options.bounceTime);
+ }
+
+ this.scaled = false;
+
+ this._execEvent('zoomEnd');
+ },
+
+ zoom: function (scale, x, y, time) {
+ if ( scale < this.options.zoomMin ) {
+ scale = this.options.zoomMin;
+ } else if ( scale > this.options.zoomMax ) {
+ scale = this.options.zoomMax;
+ }
+
+ if ( scale == this.scale ) {
+ return;
+ }
+
+ var relScale = scale / this.scale;
+
+ x = x === undefined ? this.wrapperWidth / 2 : x;
+ y = y === undefined ? this.wrapperHeight / 2 : y;
+ time = time === undefined ? 300 : time;
+
+ x = x + this.wrapperOffset.left - this.x;
+ y = y + this.wrapperOffset.top - this.y;
+
+ x = x - x * relScale + this.x;
+ y = y - y * relScale + this.y;
+
+ this.scale = scale;
+
+ this.refresh(); // update boundaries
+
+ if ( x > 0 ) {
+ x = 0;
+ } else if ( x < this.maxScrollX ) {
+ x = this.maxScrollX;
+ }
+
+ if ( y > 0 ) {
+ y = 0;
+ } else if ( y < this.maxScrollY ) {
+ y = this.maxScrollY;
+ }
+
+ this.scrollTo(x, y, time);
+ },
+
+ _wheelZoom: function (e) {
+ var wheelDeltaY,
+ deltaScale,
+ that = this;
+
+ // Execute the zoomEnd event after 400ms the wheel stopped scrolling
+ clearTimeout(this.wheelTimeout);
+ this.wheelTimeout = setTimeout(function () {
+ that._execEvent('zoomEnd');
+ }, 400);
+
+ if ( 'deltaX' in e ) {
+ wheelDeltaY = -e.deltaY / Math.abs(e.deltaY);
+ } else if ('wheelDeltaX' in e) {
+ wheelDeltaY = e.wheelDeltaY / Math.abs(e.wheelDeltaY);
+ } else if('wheelDelta' in e) {
+ wheelDeltaY = e.wheelDelta / Math.abs(e.wheelDelta);
+ } else if ('detail' in e) {
+ wheelDeltaY = -e.detail / Math.abs(e.wheelDelta);
+ } else {
+ return;
+ }
+
+ deltaScale = this.scale + wheelDeltaY / 5;
+
+ this.zoom(deltaScale, e.pageX, e.pageY, 0);
+ },
+
+ _initWheel: function () {
+ utils.addEvent(this.wrapper, 'wheel', this);
+ utils.addEvent(this.wrapper, 'mousewheel', this);
+ utils.addEvent(this.wrapper, 'DOMMouseScroll', this);
+
+ this.on('destroy', function () {
+ utils.removeEvent(this.wrapper, 'wheel', this);
+ utils.removeEvent(this.wrapper, 'mousewheel', this);
+ utils.removeEvent(this.wrapper, 'DOMMouseScroll', this);
+ });
+ },
+
+ _wheel: function (e) {
+ if ( !this.enabled ) {
+ return;
+ }
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ var wheelDeltaX, wheelDeltaY,
+ newX, newY,
+ that = this;
+
+ if ( this.wheelTimeout === undefined ) {
+ that._execEvent('scrollStart');
+ }
+
+ // Execute the scrollEnd event after 400ms the wheel stopped scrolling
+ clearTimeout(this.wheelTimeout);
+ this.wheelTimeout = setTimeout(function () {
+ that._execEvent('scrollEnd');
+ that.wheelTimeout = undefined;
+ }, 400);
+
+ if ( 'deltaX' in e ) {
+ wheelDeltaX = -e.deltaX;
+ wheelDeltaY = -e.deltaY;
+ } else if ( 'wheelDeltaX' in e ) {
+ wheelDeltaX = e.wheelDeltaX / 120 * this.options.mouseWheelSpeed;
+ wheelDeltaY = e.wheelDeltaY / 120 * this.options.mouseWheelSpeed;
+ } else if ( 'wheelDelta' in e ) {
+ wheelDeltaX = wheelDeltaY = e.wheelDelta / 120 * this.options.mouseWheelSpeed;
+ } else if ( 'detail' in e ) {
+ wheelDeltaX = wheelDeltaY = -e.detail / 3 * this.options.mouseWheelSpeed;
+ } else {
+ return;
+ }
+
+ wheelDeltaX *= this.options.invertWheelDirection;
+ wheelDeltaY *= this.options.invertWheelDirection;
+
+ if ( !this.hasVerticalScroll ) {
+ wheelDeltaX = wheelDeltaY;
+ wheelDeltaY = 0;
+ }
+
+ if ( this.options.snap ) {
+ newX = this.currentPage.pageX;
+ newY = this.currentPage.pageY;
+
+ if ( wheelDeltaX > 0 ) {
+ newX--;
+ } else if ( wheelDeltaX < 0 ) {
+ newX++;
+ }
+
+ if ( wheelDeltaY > 0 ) {
+ newY--;
+ } else if ( wheelDeltaY < 0 ) {
+ newY++;
+ }
+
+ this.goToPage(newX, newY);
+
+ return;
+ }
+
+ newX = this.x + Math.round(this.hasHorizontalScroll ? wheelDeltaX : 0);
+ newY = this.y + Math.round(this.hasVerticalScroll ? wheelDeltaY : 0);
+
+ if ( newX > 0 ) {
+ newX = 0;
+ } else if ( newX < this.maxScrollX ) {
+ newX = this.maxScrollX;
+ }
+
+ if ( newY > 0 ) {
+ newY = 0;
+ } else if ( newY < this.maxScrollY ) {
+ newY = this.maxScrollY;
+ }
+
+ this.scrollTo(newX, newY, 0);
+
+// INSERT POINT: _wheel
+ },
+
+ _initSnap: function () {
+ this.currentPage = {};
+
+ if ( typeof this.options.snap == 'string' ) {
+ this.options.snap = this.scroller.querySelectorAll(this.options.snap);
+ }
+
+ this.on('refresh', function () {
+ var i = 0, l,
+ m = 0, n,
+ cx, cy,
+ x = 0, y,
+ stepX = this.options.snapStepX || this.wrapperWidth,
+ stepY = this.options.snapStepY || this.wrapperHeight,
+ el;
+
+ this.pages = [];
+
+ if ( !this.wrapperWidth || !this.wrapperHeight || !this.scrollerWidth || !this.scrollerHeight ) {
+ return;
+ }
+
+ if ( this.options.snap === true ) {
+ cx = Math.round( stepX / 2 );
+ cy = Math.round( stepY / 2 );
+
+ while ( x > -this.scrollerWidth ) {
+ this.pages[i] = [];
+ l = 0;
+ y = 0;
+
+ while ( y > -this.scrollerHeight ) {
+ this.pages[i][l] = {
+ x: Math.max(x, this.maxScrollX),
+ y: Math.max(y, this.maxScrollY),
+ width: stepX,
+ height: stepY,
+ cx: x - cx,
+ cy: y - cy
+ };
+
+ y -= stepY;
+ l++;
+ }
+
+ x -= stepX;
+ i++;
+ }
+ } else {
+ el = this.options.snap;
+ l = el.length;
+ n = -1;
+
+ for ( ; i < l; i++ ) {
+ if ( i === 0 || el[i].offsetLeft <= el[i-1].offsetLeft ) {
+ m = 0;
+ n++;
+ }
+
+ if ( !this.pages[m] ) {
+ this.pages[m] = [];
+ }
+
+ x = Math.max(-el[i].offsetLeft, this.maxScrollX);
+ y = Math.max(-el[i].offsetTop, this.maxScrollY);
+ cx = x - Math.round(el[i].offsetWidth / 2);
+ cy = y - Math.round(el[i].offsetHeight / 2);
+
+ this.pages[m][n] = {
+ x: x,
+ y: y,
+ width: el[i].offsetWidth,
+ height: el[i].offsetHeight,
+ cx: cx,
+ cy: cy
+ };
+
+ if ( x > this.maxScrollX ) {
+ m++;
+ }
+ }
+ }
+
+ this.goToPage(this.currentPage.pageX || 0, this.currentPage.pageY || 0, 0);
+
+ // Update snap threshold if needed
+ if ( this.options.snapThreshold % 1 === 0 ) {
+ this.snapThresholdX = this.options.snapThreshold;
+ this.snapThresholdY = this.options.snapThreshold;
+ } else {
+ this.snapThresholdX = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width * this.options.snapThreshold);
+ this.snapThresholdY = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height * this.options.snapThreshold);
+ }
+ });
+
+ this.on('flick', function () {
+ var time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(this.x - this.startX), 1000),
+ Math.min(Math.abs(this.y - this.startY), 1000)
+ ), 300);
+
+ this.goToPage(
+ this.currentPage.pageX + this.directionX,
+ this.currentPage.pageY + this.directionY,
+ time
+ );
+ });
+ },
+
+ _nearestSnap: function (x, y) {
+ if ( !this.pages.length ) {
+ return { x: 0, y: 0, pageX: 0, pageY: 0 };
+ }
+
+ var i = 0,
+ l = this.pages.length,
+ m = 0;
+
+ // Check if we exceeded the snap threshold
+ if ( Math.abs(x - this.absStartX) < this.snapThresholdX &&
+ Math.abs(y - this.absStartY) < this.snapThresholdY ) {
+ return this.currentPage;
+ }
+
+ if ( x > 0 ) {
+ x = 0;
+ } else if ( x < this.maxScrollX ) {
+ x = this.maxScrollX;
+ }
+
+ if ( y > 0 ) {
+ y = 0;
+ } else if ( y < this.maxScrollY ) {
+ y = this.maxScrollY;
+ }
+
+ for ( ; i < l; i++ ) {
+ if ( x >= this.pages[i][0].cx ) {
+ x = this.pages[i][0].x;
+ break;
+ }
+ }
+
+ l = this.pages[i].length;
+
+ for ( ; m < l; m++ ) {
+ if ( y >= this.pages[0][m].cy ) {
+ y = this.pages[0][m].y;
+ break;
+ }
+ }
+
+ if ( i == this.currentPage.pageX ) {
+ i += this.directionX;
+
+ if ( i < 0 ) {
+ i = 0;
+ } else if ( i >= this.pages.length ) {
+ i = this.pages.length - 1;
+ }
+
+ x = this.pages[i][0].x;
+ }
+
+ if ( m == this.currentPage.pageY ) {
+ m += this.directionY;
+
+ if ( m < 0 ) {
+ m = 0;
+ } else if ( m >= this.pages[0].length ) {
+ m = this.pages[0].length - 1;
+ }
+
+ y = this.pages[0][m].y;
+ }
+
+ return {
+ x: x,
+ y: y,
+ pageX: i,
+ pageY: m
+ };
+ },
+
+ goToPage: function (x, y, time, easing) {
+ easing = easing || this.options.bounceEasing;
+
+ if ( x >= this.pages.length ) {
+ x = this.pages.length - 1;
+ } else if ( x < 0 ) {
+ x = 0;
+ }
+
+ if ( y >= this.pages[x].length ) {
+ y = this.pages[x].length - 1;
+ } else if ( y < 0 ) {
+ y = 0;
+ }
+
+ var posX = this.pages[x][y].x,
+ posY = this.pages[x][y].y;
+
+ time = time === undefined ? this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(posX - this.x), 1000),
+ Math.min(Math.abs(posY - this.y), 1000)
+ ), 300) : time;
+
+ this.currentPage = {
+ x: posX,
+ y: posY,
+ pageX: x,
+ pageY: y
+ };
+
+ this.scrollTo(posX, posY, time, easing);
+ },
+
+ next: function (time, easing) {
+ var x = this.currentPage.pageX,
+ y = this.currentPage.pageY;
+
+ x++;
+
+ if ( x >= this.pages.length && this.hasVerticalScroll ) {
+ x = 0;
+ y++;
+ }
+
+ this.goToPage(x, y, time, easing);
+ },
+
+ prev: function (time, easing) {
+ var x = this.currentPage.pageX,
+ y = this.currentPage.pageY;
+
+ x--;
+
+ if ( x < 0 && this.hasVerticalScroll ) {
+ x = 0;
+ y--;
+ }
+
+ this.goToPage(x, y, time, easing);
+ },
+
+ _initKeys: function (e) {
+ // default key bindings
+ var keys = {
+ pageUp: 33,
+ pageDown: 34,
+ end: 35,
+ home: 36,
+ left: 37,
+ up: 38,
+ right: 39,
+ down: 40
+ };
+ var i;
+
+ // if you give me characters I give you keycode
+ if ( typeof this.options.keyBindings == 'object' ) {
+ for ( i in this.options.keyBindings ) {
+ if ( typeof this.options.keyBindings[i] == 'string' ) {
+ this.options.keyBindings[i] = this.options.keyBindings[i].toUpperCase().charCodeAt(0);
+ }
+ }
+ } else {
+ this.options.keyBindings = {};
+ }
+
+ for ( i in keys ) {
+ this.options.keyBindings[i] = this.options.keyBindings[i] || keys[i];
+ }
+
+ utils.addEvent(window, 'keydown', this);
+
+ this.on('destroy', function () {
+ utils.removeEvent(window, 'keydown', this);
+ });
+ },
+
+ _key: function (e) {
+ if ( !this.enabled ) {
+ return;
+ }
+
+ var snap = this.options.snap, // we are using this alot, better to cache it
+ newX = snap ? this.currentPage.pageX : this.x,
+ newY = snap ? this.currentPage.pageY : this.y,
+ now = utils.getTime(),
+ prevTime = this.keyTime || 0,
+ acceleration = 0.250,
+ pos;
+
+ if ( this.options.useTransition && this.isInTransition ) {
+ pos = this.getComputedPosition();
+
+ this._translate(Math.round(pos.x), Math.round(pos.y));
+ this.isInTransition = false;
+ }
+
+ this.keyAcceleration = now - prevTime < 200 ? Math.min(this.keyAcceleration + acceleration, 50) : 0;
+
+ switch ( e.keyCode ) {
+ case this.options.keyBindings.pageUp:
+ if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
+ newX += snap ? 1 : this.wrapperWidth;
+ } else {
+ newY += snap ? 1 : this.wrapperHeight;
+ }
+ break;
+ case this.options.keyBindings.pageDown:
+ if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
+ newX -= snap ? 1 : this.wrapperWidth;
+ } else {
+ newY -= snap ? 1 : this.wrapperHeight;
+ }
+ break;
+ case this.options.keyBindings.end:
+ newX = snap ? this.pages.length-1 : this.maxScrollX;
+ newY = snap ? this.pages[0].length-1 : this.maxScrollY;
+ break;
+ case this.options.keyBindings.home:
+ newX = 0;
+ newY = 0;
+ break;
+ case this.options.keyBindings.left:
+ newX += snap ? -1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.up:
+ newY += snap ? 1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.right:
+ newX -= snap ? -1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.down:
+ newY -= snap ? 1 : 5 + this.keyAcceleration>>0;
+ break;
+ default:
+ return;
+ }
+
+ if ( snap ) {
+ this.goToPage(newX, newY);
+ return;
+ }
+
+ if ( newX > 0 ) {
+ newX = 0;
+ this.keyAcceleration = 0;
+ } else if ( newX < this.maxScrollX ) {
+ newX = this.maxScrollX;
+ this.keyAcceleration = 0;
+ }
+
+ if ( newY > 0 ) {
+ newY = 0;
+ this.keyAcceleration = 0;
+ } else if ( newY < this.maxScrollY ) {
+ newY = this.maxScrollY;
+ this.keyAcceleration = 0;
+ }
+
+ this.scrollTo(newX, newY, 0);
+
+ this.keyTime = now;
+ },
+
+ _animate: function (destX, destY, duration, easingFn) {
+ var that = this,
+ startX = this.x,
+ startY = this.y,
+ startTime = utils.getTime(),
+ destTime = startTime + duration;
+
+ function step () {
+ var now = utils.getTime(),
+ newX, newY,
+ easing;
+
+ if ( now >= destTime ) {
+ that.isAnimating = false;
+ that._translate(destX, destY);
+
+ if ( !that.resetPosition(that.options.bounceTime) ) {
+ that._execEvent('scrollEnd');
+ }
+
+ return;
+ }
+
+ now = ( now - startTime ) / duration;
+ easing = easingFn(now);
+ newX = ( destX - startX ) * easing + startX;
+ newY = ( destY - startY ) * easing + startY;
+ that._translate(newX, newY);
+
+ if ( that.isAnimating ) {
+ rAF(step);
+ }
+ }
+
+ this.isAnimating = true;
+ step();
+ },
+ handleEvent: function (e) {
+ switch ( e.type ) {
+ case 'touchstart':
+ case 'MSPointerDown':
+ case 'mousedown':
+ this._start(e);
+
+ if ( this.options.zoom && e.touches && e.touches.length > 1 ) {
+ this._zoomStart(e);
+ }
+ break;
+ case 'touchmove':
+ case 'MSPointerMove':
+ case 'mousemove':
+ if ( this.options.zoom && e.touches && e.touches[1] ) {
+ this._zoom(e);
+ return;
+ }
+ this._move(e);
+ break;
+ case 'touchend':
+ case 'MSPointerUp':
+ case 'mouseup':
+ case 'touchcancel':
+ case 'MSPointerCancel':
+ case 'mousecancel':
+ if ( this.scaled ) {
+ this._zoomEnd(e);
+ return;
+ }
+ this._end(e);
+ break;
+ case 'orientationchange':
+ case 'resize':
+ this._resize();
+ break;
+ case 'transitionend':
+ case 'webkitTransitionEnd':
+ case 'oTransitionEnd':
+ case 'MSTransitionEnd':
+ this._transitionEnd(e);
+ break;
+ case 'wheel':
+ case 'DOMMouseScroll':
+ case 'mousewheel':
+ if ( this.options.wheelAction == 'zoom' ) {
+ this._wheelZoom(e);
+ return;
+ }
+ this._wheel(e);
+ break;
+ case 'keydown':
+ this._key(e);
+ break;
+ }
+ }
+
+};
+function createDefaultScrollbar (direction, interactive, type) {
+ var scrollbar = document.createElement('div'),
+ indicator = document.createElement('div');
+
+ if ( type === true ) {
+ scrollbar.style.cssText = 'position:absolute;z-index:9999';
+ indicator.style.cssText = '-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px';
+ }
+
+ indicator.className = 'iScrollIndicator';
+
+ if ( direction == 'h' ) {
+ if ( type === true ) {
+ scrollbar.style.cssText += ';height:7px;left:2px;right:2px;bottom:0';
+ indicator.style.height = '100%';
+ }
+ scrollbar.className = 'iScrollHorizontalScrollbar';
+ } else {
+ if ( type === true ) {
+ scrollbar.style.cssText += ';width:7px;bottom:2px;top:2px;right:1px';
+ indicator.style.width = '100%';
+ }
+ scrollbar.className = 'iScrollVerticalScrollbar';
+ }
+
+ scrollbar.style.cssText += ';overflow:hidden';
+
+ if ( !interactive ) {
+ scrollbar.style.pointerEvents = 'none';
+ }
+
+ scrollbar.appendChild(indicator);
+
+ return scrollbar;
+}
+
+function Indicator (scroller, options) {
+ this.wrapper = typeof options.el == 'string' ? document.querySelector(options.el) : options.el;
+ this.wrapperStyle = this.wrapper.style;
+ this.indicator = this.wrapper.children[0];
+ this.indicatorStyle = this.indicator.style;
+ this.scroller = scroller;
+
+ this.options = {
+ listenX: true,
+ listenY: true,
+ interactive: false,
+ resize: true,
+ defaultScrollbars: false,
+ shrink: false,
+ fade: false,
+ speedRatioX: 0,
+ speedRatioY: 0
+ };
+
+ for ( var i in options ) {
+ this.options[i] = options[i];
+ }
+
+ this.sizeRatioX = 1;
+ this.sizeRatioY = 1;
+ this.maxPosX = 0;
+ this.maxPosY = 0;
+
+ if ( this.options.interactive ) {
+ if ( !this.options.disableTouch ) {
+ utils.addEvent(this.indicator, 'touchstart', this);
+ utils.addEvent(window, 'touchend', this);
+ }
+ if ( !this.options.disablePointer ) {
+ utils.addEvent(this.indicator, 'MSPointerDown', this);
+ utils.addEvent(window, 'MSPointerUp', this);
+ }
+ if ( !this.options.disableMouse ) {
+ utils.addEvent(this.indicator, 'mousedown', this);
+ utils.addEvent(window, 'mouseup', this);
+ }
+ }
+
+ if ( this.options.fade ) {
+ this.wrapperStyle[utils.style.transform] = this.scroller.translateZ;
+ this.wrapperStyle[utils.style.transitionDuration] = utils.isBadAndroid ? '0.001s' : '0ms';
+ this.wrapperStyle.opacity = '0';
+ }
+}
+
+Indicator.prototype = {
+ handleEvent: function (e) {
+ switch ( e.type ) {
+ case 'touchstart':
+ case 'MSPointerDown':
+ case 'mousedown':
+ this._start(e);
+ break;
+ case 'touchmove':
+ case 'MSPointerMove':
+ case 'mousemove':
+ this._move(e);
+ break;
+ case 'touchend':
+ case 'MSPointerUp':
+ case 'mouseup':
+ case 'touchcancel':
+ case 'MSPointerCancel':
+ case 'mousecancel':
+ this._end(e);
+ break;
+ }
+ },
+
+ destroy: function () {
+ if ( this.options.interactive ) {
+ utils.removeEvent(this.indicator, 'touchstart', this);
+ utils.removeEvent(this.indicator, 'MSPointerDown', this);
+ utils.removeEvent(this.indicator, 'mousedown', this);
+
+ utils.removeEvent(window, 'touchmove', this);
+ utils.removeEvent(window, 'MSPointerMove', this);
+ utils.removeEvent(window, 'mousemove', this);
+
+ utils.removeEvent(window, 'touchend', this);
+ utils.removeEvent(window, 'MSPointerUp', this);
+ utils.removeEvent(window, 'mouseup', this);
+ }
+
+ if ( this.options.defaultScrollbars ) {
+ this.wrapper.parentNode.removeChild(this.wrapper);
+ }
+ },
+
+ _start: function (e) {
+ var point = e.touches ? e.touches[0] : e;
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ this.transitionTime();
+
+ this.initiated = true;
+ this.moved = false;
+ this.lastPointX = point.pageX;
+ this.lastPointY = point.pageY;
+
+ this.startTime = utils.getTime();
+
+ if ( !this.options.disableTouch ) {
+ utils.addEvent(window, 'touchmove', this);
+ }
+ if ( !this.options.disablePointer ) {
+ utils.addEvent(window, 'MSPointerMove', this);
+ }
+ if ( !this.options.disableMouse ) {
+ utils.addEvent(window, 'mousemove', this);
+ }
+
+ this.scroller._execEvent('beforeScrollStart');
+ },
+
+ _move: function (e) {
+ var point = e.touches ? e.touches[0] : e,
+ deltaX, deltaY,
+ newX, newY,
+ timestamp = utils.getTime();
+
+ if ( !this.moved ) {
+ this.scroller._execEvent('scrollStart');
+ }
+
+ this.moved = true;
+
+ deltaX = point.pageX - this.lastPointX;
+ this.lastPointX = point.pageX;
+
+ deltaY = point.pageY - this.lastPointY;
+ this.lastPointY = point.pageY;
+
+ newX = this.x + deltaX;
+ newY = this.y + deltaY;
+
+ this._pos(newX, newY);
+
+// INSERT POINT: indicator._move
+
+ e.preventDefault();
+ e.stopPropagation();
+ },
+
+ _end: function (e) {
+ if ( !this.initiated ) {
+ return;
+ }
+
+ this.initiated = false;
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ utils.removeEvent(window, 'touchmove', this);
+ utils.removeEvent(window, 'MSPointerMove', this);
+ utils.removeEvent(window, 'mousemove', this);
+
+ if ( this.scroller.options.snap ) {
+ var snap = this.scroller._nearestSnap(this.scroller.x, this.scroller.y);
+
+ var time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(this.scroller.x - snap.x), 1000),
+ Math.min(Math.abs(this.scroller.y - snap.y), 1000)
+ ), 300);
+
+ if ( this.scroller.x != snap.x || this.scroller.y != snap.y ) {
+ this.scroller.directionX = 0;
+ this.scroller.directionY = 0;
+ this.scroller.currentPage = snap;
+ this.scroller.scrollTo(snap.x, snap.y, time, this.scroller.options.bounceEasing);
+ }
+ }
+
+ if ( this.moved ) {
+ this.scroller._execEvent('scrollEnd');
+ }
+ },
+
+ transitionTime: function (time) {
+ time = time || 0;
+ this.indicatorStyle[utils.style.transitionDuration] = time + 'ms';
+
+ if ( !time && utils.isBadAndroid ) {
+ this.indicatorStyle[utils.style.transitionDuration] = '0.001s';
+ }
+ },
+
+ transitionTimingFunction: function (easing) {
+ this.indicatorStyle[utils.style.transitionTimingFunction] = easing;
+ },
+
+ refresh: function () {
+ this.transitionTime();
+
+ if ( this.options.listenX && !this.options.listenY ) {
+ this.indicatorStyle.display = this.scroller.hasHorizontalScroll ? 'block' : 'none';
+ } else if ( this.options.listenY && !this.options.listenX ) {
+ this.indicatorStyle.display = this.scroller.hasVerticalScroll ? 'block' : 'none';
+ } else {
+ this.indicatorStyle.display = this.scroller.hasHorizontalScroll || this.scroller.hasVerticalScroll ? 'block' : 'none';
+ }
+
+ if ( this.scroller.hasHorizontalScroll && this.scroller.hasVerticalScroll ) {
+ utils.addClass(this.wrapper, 'iScrollBothScrollbars');
+ utils.removeClass(this.wrapper, 'iScrollLoneScrollbar');
+
+ if ( this.options.defaultScrollbars && this.options.customStyle ) {
+ if ( this.options.listenX ) {
+ this.wrapper.style.right = '8px';
+ } else {
+ this.wrapper.style.bottom = '8px';
+ }
+ }
+ } else {
+ utils.removeClass(this.wrapper, 'iScrollBothScrollbars');
+ utils.addClass(this.wrapper, 'iScrollLoneScrollbar');
+
+ if ( this.options.defaultScrollbars && this.options.customStyle ) {
+ if ( this.options.listenX ) {
+ this.wrapper.style.right = '2px';
+ } else {
+ this.wrapper.style.bottom = '2px';
+ }
+ }
+ }
+
+ var r = this.wrapper.offsetHeight; // force refresh
+
+ if ( this.options.listenX ) {
+ this.wrapperWidth = this.wrapper.clientWidth;
+ if ( this.options.resize ) {
+ this.indicatorWidth = Math.max(Math.round(this.wrapperWidth * this.wrapperWidth / (this.scroller.scrollerWidth || this.wrapperWidth || 1)), 8);
+ this.indicatorStyle.width = this.indicatorWidth + 'px';
+ } else {
+ this.indicatorWidth = this.indicator.clientWidth;
+ }
+
+ this.maxPosX = this.wrapperWidth - this.indicatorWidth;
+
+ if ( this.options.shrink == 'clip' ) {
+ this.minBoundaryX = -this.indicatorWidth + 8;
+ this.maxBoundaryX = this.wrapperWidth - 8;
+ } else {
+ this.minBoundaryX = 0;
+ this.maxBoundaryX = this.maxPosX;
+ }
+
+ this.sizeRatioX = this.options.speedRatioX || (this.scroller.maxScrollX && (this.maxPosX / this.scroller.maxScrollX));
+ }
+
+ if ( this.options.listenY ) {
+ this.wrapperHeight = this.wrapper.clientHeight;
+ if ( this.options.resize ) {
+ this.indicatorHeight = Math.max(Math.round(this.wrapperHeight * this.wrapperHeight / (this.scroller.scrollerHeight || this.wrapperHeight || 1)), 8);
+ this.indicatorStyle.height = this.indicatorHeight + 'px';
+ } else {
+ this.indicatorHeight = this.indicator.clientHeight;
+ }
+
+ this.maxPosY = this.wrapperHeight - this.indicatorHeight;
+
+ if ( this.options.shrink == 'clip' ) {
+ this.minBoundaryY = -this.indicatorHeight + 8;
+ this.maxBoundaryY = this.wrapperHeight - 8;
+ } else {
+ 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 x = this.options.listenX && Math.round(this.sizeRatioX * this.scroller.x) || 0,
+ y = this.options.listenY && Math.round(this.sizeRatioY * this.scroller.y) || 0;
+
+ if ( !this.options.ignoreBoundaries ) {
+ if ( x < this.minBoundaryX ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.width = Math.max(this.indicatorWidth + x, 8);
+ this.indicatorStyle.width = this.width + 'px';
+ }
+ x = this.minBoundaryX;
+ } else if ( x > this.maxBoundaryX ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.width = Math.max(this.indicatorWidth - (x - this.maxPosX), 8);
+ this.indicatorStyle.width = this.width + 'px';
+ x = this.maxPosX + this.indicatorWidth - this.width;
+ } else {
+ x = this.maxBoundaryX;
+ }
+ } else if ( this.options.shrink == 'scale' && this.width != this.indicatorWidth ) {
+ this.width = this.indicatorWidth;
+ this.indicatorStyle.width = this.width + 'px';
+ }
+
+ if ( y < this.minBoundaryY ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.height = Math.max(this.indicatorHeight + y * 3, 8);
+ this.indicatorStyle.height = this.height + 'px';
+ }
+ y = this.minBoundaryY;
+ } else if ( y > this.maxBoundaryY ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.height = Math.max(this.indicatorHeight - (y - this.maxPosY) * 3, 8);
+ this.indicatorStyle.height = this.height + 'px';
+ y = this.maxPosY + this.indicatorHeight - this.height;
+ } else {
+ y = this.maxBoundaryY;
+ }
+ } else if ( this.options.shrink == 'scale' && this.height != this.indicatorHeight ) {
+ this.height = this.indicatorHeight;
+ this.indicatorStyle.height = this.height + 'px';
+ }
+ }
+
+ this.x = x;
+ this.y = y;
+
+ if ( this.scroller.options.useTransform ) {
+ this.indicatorStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.scroller.translateZ;
+ } else {
+ this.indicatorStyle.left = x + 'px';
+ this.indicatorStyle.top = y + 'px';
+ }
+ },
+
+ _pos: function (x, y) {
+ if ( x < 0 ) {
+ x = 0;
+ } else if ( x > this.maxPosX ) {
+ x = this.maxPosX;
+ }
+
+ if ( y < 0 ) {
+ y = 0;
+ } else if ( y > this.maxPosY ) {
+ y = this.maxPosY;
+ }
+
+ x = this.options.listenX ? Math.round(x / this.sizeRatioX) : this.scroller.x;
+ y = this.options.listenY ? Math.round(y / this.sizeRatioY) : this.scroller.y;
+
+ this.scroller.scrollTo(x, y);
+ },
+
+ fade: function (val, hold) {
+ if ( hold && !this.visible ) {
+ return;
+ }
+
+ clearTimeout(this.fadeTimeout);
+ this.fadeTimeout = null;
+
+ var time = val ? 250 : 500,
+ delay = val ? 0 : 300;
+
+ val = val ? '1' : '0';
+
+ this.wrapperStyle[utils.style.transitionDuration] = time + 'ms';
+
+ this.fadeTimeout = setTimeout((function (val) {
+ this.wrapperStyle.opacity = val;
+ this.visible = +val;
+ }).bind(this, val), delay);
+ }
+};
+
+IScroll.utils = utils;
+
+if ( typeof module != 'undefined' && module.exports ) {
+ module.exports = IScroll;
+} else {
+ window.IScroll = IScroll;
+}
+
+})(window, document, Math);
\ No newline at end of file
diff --git a/build/iscroll.js b/build/iscroll.js
new file mode 100644
index 0000000..6ccf0e2
--- /dev/null
+++ b/build/iscroll.js
@@ -0,0 +1,1988 @@
+/*! iScroll v5.1.1 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
+(function (window, document, Math) {
+var rAF = window.requestAnimationFrame ||
+ window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame ||
+ window.msRequestAnimationFrame ||
+ function (callback) { window.setTimeout(callback, 1000 / 60); };
+
+var utils = (function () {
+ var me = {};
+
+ var _elementStyle = document.createElement('div').style;
+ var _vendor = (function () {
+ var vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'],
+ transform,
+ i = 0,
+ l = vendors.length;
+
+ for ( ; i < l; i++ ) {
+ transform = vendors[i] + 'ransform';
+ if ( transform in _elementStyle ) return vendors[i].substr(0, vendors[i].length-1);
+ }
+
+ return false;
+ })();
+
+ function _prefixStyle (style) {
+ if ( _vendor === false ) return false;
+ if ( _vendor === '' ) return style;
+ return _vendor + style.charAt(0).toUpperCase() + style.substr(1);
+ }
+
+ me.getTime = Date.now || function getTime () { return new Date().getTime(); };
+
+ me.extend = function (target, obj) {
+ for ( var i in obj ) {
+ target[i] = obj[i];
+ }
+ };
+
+ me.addEvent = function (el, type, fn, capture) {
+ el.addEventListener(type, fn, !!capture);
+ };
+
+ me.removeEvent = function (el, type, fn, capture) {
+ el.removeEventListener(type, fn, !!capture);
+ };
+
+ me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
+ var distance = current - start,
+ speed = Math.abs(distance) / time,
+ destination,
+ duration;
+
+ deceleration = deceleration === undefined ? 0.0006 : deceleration;
+
+ destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );
+ duration = speed / deceleration;
+
+ if ( destination < lowerMargin ) {
+ destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin;
+ distance = Math.abs(destination - current);
+ duration = distance / speed;
+ } else if ( destination > 0 ) {
+ destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0;
+ distance = Math.abs(current) + destination;
+ duration = distance / speed;
+ }
+
+ return {
+ destination: Math.round(destination),
+ duration: duration
+ };
+ };
+
+ var _transform = _prefixStyle('transform');
+
+ me.extend(me, {
+ hasTransform: _transform !== false,
+ hasPerspective: _prefixStyle('perspective') in _elementStyle,
+ hasTouch: 'ontouchstart' in window,
+ hasPointer: navigator.msPointerEnabled,
+ hasTransition: _prefixStyle('transition') in _elementStyle
+ });
+
+ // This should find all Android browsers lower than build 535.19 (both stock browser and webview)
+ me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
+
+ me.extend(me.style = {}, {
+ transform: _transform,
+ transitionTimingFunction: _prefixStyle('transitionTimingFunction'),
+ transitionDuration: _prefixStyle('transitionDuration'),
+ transitionDelay: _prefixStyle('transitionDelay'),
+ transformOrigin: _prefixStyle('transformOrigin')
+ });
+
+ me.hasClass = function (e, c) {
+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)");
+ return re.test(e.className);
+ };
+
+ me.addClass = function (e, c) {
+ if ( me.hasClass(e, c) ) {
+ return;
+ }
+
+ var newclass = e.className.split(' ');
+ newclass.push(c);
+ e.className = newclass.join(' ');
+ };
+
+ me.removeClass = function (e, c) {
+ if ( !me.hasClass(e, c) ) {
+ return;
+ }
+
+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)", 'g');
+ e.className = e.className.replace(re, ' ');
+ };
+
+ me.offset = function (el) {
+ var left = -el.offsetLeft,
+ top = -el.offsetTop;
+
+ // jshint -W084
+ while (el = el.offsetParent) {
+ left -= el.offsetLeft;
+ top -= el.offsetTop;
+ }
+ // jshint +W084
+
+ return {
+ left: left,
+ top: top
+ };
+ };
+
+ me.preventDefaultException = function (el, exceptions) {
+ for ( var i in exceptions ) {
+ if ( exceptions[i].test(el[i]) ) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ me.extend(me.eventType = {}, {
+ touchstart: 1,
+ touchmove: 1,
+ touchend: 1,
+
+ mousedown: 2,
+ mousemove: 2,
+ mouseup: 2,
+
+ MSPointerDown: 3,
+ MSPointerMove: 3,
+ MSPointerUp: 3
+ });
+
+ me.extend(me.ease = {}, {
+ quadratic: {
+ style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
+ fn: function (k) {
+ return k * ( 2 - k );
+ }
+ },
+ circular: {
+ 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)
+ fn: function (k) {
+ return Math.sqrt( 1 - ( --k * k ) );
+ }
+ },
+ back: {
+ style: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
+ fn: function (k) {
+ var b = 4;
+ return ( k = k - 1 ) * k * ( ( b + 1 ) * k + b ) + 1;
+ }
+ },
+ bounce: {
+ style: '',
+ fn: function (k) {
+ if ( ( k /= 1 ) < ( 1 / 2.75 ) ) {
+ return 7.5625 * k * k;
+ } else if ( k < ( 2 / 2.75 ) ) {
+ return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75;
+ } else if ( k < ( 2.5 / 2.75 ) ) {
+ return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375;
+ } else {
+ return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375;
+ }
+ }
+ },
+ elastic: {
+ style: '',
+ fn: function (k) {
+ var f = 0.22,
+ e = 0.4;
+
+ if ( k === 0 ) { return 0; }
+ if ( k == 1 ) { return 1; }
+
+ return ( e * Math.pow( 2, - 10 * k ) * Math.sin( ( k - f / 4 ) * ( 2 * Math.PI ) / f ) + 1 );
+ }
+ }
+ });
+
+ me.tap = function (e, eventName) {
+ var ev = document.createEvent('Event');
+ ev.initEvent(eventName, true, true);
+ ev.pageX = e.pageX;
+ ev.pageY = e.pageY;
+ e.target.dispatchEvent(ev);
+ };
+
+ me.click = function (e) {
+ var target = e.target,
+ ev;
+
+ if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) {
+ ev = document.createEvent('MouseEvents');
+ ev.initMouseEvent('click', true, true, e.view, 1,
+ target.screenX, target.screenY, target.clientX, target.clientY,
+ e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
+ 0, null);
+
+ ev._constructed = true;
+ target.dispatchEvent(ev);
+ }
+ };
+
+ return me;
+})();
+
+function IScroll (el, options) {
+ this.wrapper = typeof el == 'string' ? document.querySelector(el) : el;
+ this.scroller = this.wrapper.children[0];
+ this.scrollerStyle = this.scroller.style; // cache style for better performance
+
+ this.options = {
+
+ resizeScrollbars: true,
+
+ mouseWheelSpeed: 20,
+
+ snapThreshold: 0.334,
+
+// INSERT POINT: OPTIONS
+
+ startX: 0,
+ startY: 0,
+ scrollY: true,
+ directionLockThreshold: 5,
+ momentum: true,
+
+ bounce: true,
+ bounceTime: 600,
+ bounceEasing: '',
+
+ preventDefault: true,
+ preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ },
+
+ HWCompositing: true,
+ useTransition: true,
+ useTransform: true
+ };
+
+ for ( var i in options ) {
+ this.options[i] = options[i];
+ }
+
+ // Normalize options
+ this.translateZ = this.options.HWCompositing && utils.hasPerspective ? ' translateZ(0)' : '';
+
+ this.options.useTransition = utils.hasTransition && this.options.useTransition;
+ this.options.useTransform = utils.hasTransform && this.options.useTransform;
+
+ this.options.eventPassthrough = this.options.eventPassthrough === true ? 'vertical' : this.options.eventPassthrough;
+ this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault;
+
+ // If you want eventPassthrough I have to lock one of the axes
+ this.options.scrollY = this.options.eventPassthrough == 'vertical' ? false : this.options.scrollY;
+ this.options.scrollX = this.options.eventPassthrough == 'horizontal' ? false : this.options.scrollX;
+
+ // With eventPassthrough we also need lockDirection mechanism
+ this.options.freeScroll = this.options.freeScroll && !this.options.eventPassthrough;
+ this.options.directionLockThreshold = this.options.eventPassthrough ? 0 : this.options.directionLockThreshold;
+
+ this.options.bounceEasing = typeof this.options.bounceEasing == 'string' ? utils.ease[this.options.bounceEasing] || utils.ease.circular : this.options.bounceEasing;
+
+ this.options.resizePolling = this.options.resizePolling === undefined ? 60 : this.options.resizePolling;
+
+ if ( this.options.tap === true ) {
+ this.options.tap = 'tap';
+ }
+
+ if ( this.options.shrinkScrollbars == 'scale' ) {
+ this.options.useTransition = false;
+ }
+
+ this.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1;
+
+// INSERT POINT: NORMALIZATION
+
+ // Some defaults
+ this.x = 0;
+ this.y = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+ this._events = {};
+
+// INSERT POINT: DEFAULTS
+
+ this._init();
+ this.refresh();
+
+ this.scrollTo(this.options.startX, this.options.startY);
+ this.enable();
+}
+
+IScroll.prototype = {
+ version: '5.1.1',
+
+ _init: function () {
+ this._initEvents();
+
+ if ( this.options.scrollbars || this.options.indicators ) {
+ this._initIndicators();
+ }
+
+ if ( this.options.mouseWheel ) {
+ this._initWheel();
+ }
+
+ if ( this.options.snap ) {
+ this._initSnap();
+ }
+
+ if ( this.options.keyBindings ) {
+ this._initKeys();
+ }
+
+// INSERT POINT: _init
+
+ },
+
+ destroy: function () {
+ this._initEvents(true);
+
+ this._execEvent('destroy');
+ },
+
+ _transitionEnd: function (e) {
+ if ( e.target != this.scroller || !this.isInTransition ) {
+ return;
+ }
+
+ this._transitionTime();
+ if ( !this.resetPosition(this.options.bounceTime) ) {
+ this.isInTransition = false;
+ this._execEvent('scrollEnd');
+ }
+ },
+
+ _start: function (e) {
+ // React to left mouse button only
+ if ( utils.eventType[e.type] != 1 ) {
+ if ( e.button !== 0 ) {
+ return;
+ }
+ }
+
+ if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) {
+ return;
+ }
+
+ if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
+ e.preventDefault();
+ }
+
+ var point = e.touches ? e.touches[0] : e,
+ pos;
+
+ this.initiated = utils.eventType[e.type];
+ this.moved = false;
+ this.distX = 0;
+ this.distY = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+ this.directionLocked = 0;
+
+ this._transitionTime();
+
+ this.startTime = utils.getTime();
+
+ if ( this.options.useTransition && this.isInTransition ) {
+ this.isInTransition = false;
+ pos = this.getComputedPosition();
+ this._translate(Math.round(pos.x), Math.round(pos.y));
+ this._execEvent('scrollEnd');
+ } else if ( !this.options.useTransition && this.isAnimating ) {
+ this.isAnimating = false;
+ this._execEvent('scrollEnd');
+ }
+
+ this.startX = this.x;
+ this.startY = this.y;
+ this.absStartX = this.x;
+ this.absStartY = this.y;
+ this.pointX = point.pageX;
+ this.pointY = point.pageY;
+
+ this._execEvent('beforeScrollStart');
+ },
+
+ _move: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault ) { // increases performance on Android? TODO: check!
+ e.preventDefault();
+ }
+
+ var point = e.touches ? e.touches[0] : e,
+ deltaX = point.pageX - this.pointX,
+ deltaY = point.pageY - this.pointY,
+ timestamp = utils.getTime(),
+ newX, newY,
+ absDistX, absDistY;
+
+ this.pointX = point.pageX;
+ this.pointY = point.pageY;
+
+ this.distX += deltaX;
+ this.distY += deltaY;
+ absDistX = Math.abs(this.distX);
+ absDistY = Math.abs(this.distY);
+
+ // We need to move at least 10 pixels for the scrolling to initiate
+ if ( timestamp - this.endTime > 300 && (absDistX < 10 && absDistY < 10) ) {
+ return;
+ }
+
+ // If you are scrolling in one direction lock the other
+ if ( !this.directionLocked && !this.options.freeScroll ) {
+ if ( absDistX > absDistY + this.options.directionLockThreshold ) {
+ this.directionLocked = 'h'; // lock horizontally
+ } else if ( absDistY >= absDistX + this.options.directionLockThreshold ) {
+ this.directionLocked = 'v'; // lock vertically
+ } else {
+ this.directionLocked = 'n'; // no lock
+ }
+ }
+
+ if ( this.directionLocked == 'h' ) {
+ if ( this.options.eventPassthrough == 'vertical' ) {
+ e.preventDefault();
+ } else if ( this.options.eventPassthrough == 'horizontal' ) {
+ this.initiated = false;
+ return;
+ }
+
+ deltaY = 0;
+ } else if ( this.directionLocked == 'v' ) {
+ if ( this.options.eventPassthrough == 'horizontal' ) {
+ e.preventDefault();
+ } else if ( this.options.eventPassthrough == 'vertical' ) {
+ this.initiated = false;
+ return;
+ }
+
+ deltaX = 0;
+ }
+
+ deltaX = this.hasHorizontalScroll ? deltaX : 0;
+ deltaY = this.hasVerticalScroll ? deltaY : 0;
+
+ newX = this.x + deltaX;
+ newY = this.y + deltaY;
+
+ // Slow down if outside of the boundaries
+ if ( newX > 0 || newX < this.maxScrollX ) {
+ newX = this.options.bounce ? this.x + deltaX / 3 : newX > 0 ? 0 : this.maxScrollX;
+ }
+ if ( newY > 0 || newY < this.maxScrollY ) {
+ newY = this.options.bounce ? this.y + deltaY / 3 : newY > 0 ? 0 : this.maxScrollY;
+ }
+
+ this.directionX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
+ this.directionY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
+
+ if ( !this.moved ) {
+ this._execEvent('scrollStart');
+ }
+
+ this.moved = true;
+
+ this._translate(newX, newY);
+
+/* REPLACE START: _move */
+
+ if ( timestamp - this.startTime > 300 ) {
+ this.startTime = timestamp;
+ this.startX = this.x;
+ this.startY = this.y;
+ }
+
+/* REPLACE END: _move */
+
+ },
+
+ _end: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
+ e.preventDefault();
+ }
+
+ var point = e.changedTouches ? e.changedTouches[0] : e,
+ momentumX,
+ momentumY,
+ duration = utils.getTime() - this.startTime,
+ newX = Math.round(this.x),
+ newY = Math.round(this.y),
+ distanceX = Math.abs(newX - this.startX),
+ distanceY = Math.abs(newY - this.startY),
+ time = 0,
+ easing = '';
+
+ this.isInTransition = 0;
+ this.initiated = 0;
+ this.endTime = utils.getTime();
+
+ // reset if we are outside of the boundaries
+ if ( this.resetPosition(this.options.bounceTime) ) {
+ return;
+ }
+
+ this.scrollTo(newX, newY); // ensures that the last position is rounded
+
+ // we scrolled less than 10 pixels
+ if ( !this.moved ) {
+ if ( this.options.tap ) {
+ utils.tap(e, this.options.tap);
+ }
+
+ if ( this.options.click ) {
+ utils.click(e);
+ }
+
+ this._execEvent('scrollCancel');
+ return;
+ }
+
+ if ( this._events.flick && duration < 200 && distanceX < 100 && distanceY < 100 ) {
+ this._execEvent('flick');
+ return;
+ }
+
+ // start momentum animation if needed
+ if ( this.options.momentum && duration < 300 ) {
+ momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 };
+ momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 };
+ newX = momentumX.destination;
+ newY = momentumY.destination;
+ time = Math.max(momentumX.duration, momentumY.duration);
+ this.isInTransition = 1;
+ }
+
+
+ if ( this.options.snap ) {
+ var snap = this._nearestSnap(newX, newY);
+ this.currentPage = snap;
+ time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(newX - snap.x), 1000),
+ Math.min(Math.abs(newY - snap.y), 1000)
+ ), 300);
+ newX = snap.x;
+ newY = snap.y;
+
+ this.directionX = 0;
+ this.directionY = 0;
+ easing = this.options.bounceEasing;
+ }
+
+// INSERT POINT: _end
+
+ if ( newX != this.x || newY != this.y ) {
+ // change easing function when scroller goes out of the boundaries
+ if ( newX > 0 || newX < this.maxScrollX || newY > 0 || newY < this.maxScrollY ) {
+ easing = utils.ease.quadratic;
+ }
+
+ this.scrollTo(newX, newY, time, easing);
+ return;
+ }
+
+ this._execEvent('scrollEnd');
+ },
+
+ _resize: function () {
+ var that = this;
+
+ clearTimeout(this.resizeTimeout);
+
+ this.resizeTimeout = setTimeout(function () {
+ that.refresh();
+ }, this.options.resizePolling);
+ },
+
+ resetPosition: function (time) {
+ var x = this.x,
+ y = this.y;
+
+ time = time || 0;
+
+ if ( !this.hasHorizontalScroll || this.x > 0 ) {
+ x = 0;
+ } else if ( this.x < this.maxScrollX ) {
+ x = this.maxScrollX;
+ }
+
+ if ( !this.hasVerticalScroll || this.y > 0 ) {
+ y = 0;
+ } else if ( this.y < this.maxScrollY ) {
+ y = this.maxScrollY;
+ }
+
+ if ( x == this.x && y == this.y ) {
+ return false;
+ }
+
+ this.scrollTo(x, y, time, this.options.bounceEasing);
+
+ return true;
+ },
+
+ disable: function () {
+ this.enabled = false;
+ },
+
+ enable: function () {
+ this.enabled = true;
+ },
+
+ refresh: function () {
+ var rf = this.wrapper.offsetHeight; // Force reflow
+
+ this.wrapperWidth = this.wrapper.clientWidth;
+ this.wrapperHeight = this.wrapper.clientHeight;
+
+/* REPLACE START: refresh */
+
+ this.scrollerWidth = this.scroller.offsetWidth;
+ this.scrollerHeight = this.scroller.offsetHeight;
+
+ this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
+ this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
+
+/* REPLACE END: refresh */
+
+ this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
+ this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
+
+ if ( !this.hasHorizontalScroll ) {
+ this.maxScrollX = 0;
+ this.scrollerWidth = this.wrapperWidth;
+ }
+
+ if ( !this.hasVerticalScroll ) {
+ this.maxScrollY = 0;
+ this.scrollerHeight = this.wrapperHeight;
+ }
+
+ this.endTime = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+
+ this.wrapperOffset = utils.offset(this.wrapper);
+
+ this._execEvent('refresh');
+
+ this.resetPosition();
+
+// INSERT POINT: _refresh
+
+ },
+
+ on: function (type, fn) {
+ if ( !this._events[type] ) {
+ this._events[type] = [];
+ }
+
+ this._events[type].push(fn);
+ },
+
+ off: function (type, fn) {
+ if ( !this._events[type] ) {
+ return;
+ }
+
+ var index = this._events[type].indexOf(fn);
+
+ if ( index > -1 ) {
+ this._events[type].splice(index, 1);
+ }
+ },
+
+ _execEvent: function (type) {
+ if ( !this._events[type] ) {
+ return;
+ }
+
+ var i = 0,
+ l = this._events[type].length;
+
+ if ( !l ) {
+ return;
+ }
+
+ for ( ; i < l; i++ ) {
+ this._events[type][i].apply(this, [].slice.call(arguments, 1));
+ }
+ },
+
+ scrollBy: function (x, y, time, easing) {
+ x = this.x + x;
+ y = this.y + y;
+ time = time || 0;
+
+ this.scrollTo(x, y, time, easing);
+ },
+
+ scrollTo: function (x, y, time, easing) {
+ easing = easing || utils.ease.circular;
+
+ this.isInTransition = this.options.useTransition && time > 0;
+
+ if ( !time || (this.options.useTransition && easing.style) ) {
+ this._transitionTimingFunction(easing.style);
+ this._transitionTime(time);
+ this._translate(x, y);
+ } else {
+ this._animate(x, y, time, easing.fn);
+ }
+ },
+
+ scrollToElement: function (el, time, offsetX, offsetY, easing) {
+ el = el.nodeType ? el : this.scroller.querySelector(el);
+
+ if ( !el ) {
+ return;
+ }
+
+ var pos = utils.offset(el);
+
+ pos.left -= this.wrapperOffset.left;
+ pos.top -= this.wrapperOffset.top;
+
+ // if offsetX/Y are true we center the element to the screen
+ if ( offsetX === true ) {
+ offsetX = Math.round(el.offsetWidth / 2 - this.wrapper.offsetWidth / 2);
+ }
+ if ( offsetY === true ) {
+ offsetY = Math.round(el.offsetHeight / 2 - this.wrapper.offsetHeight / 2);
+ }
+
+ pos.left -= offsetX || 0;
+ pos.top -= offsetY || 0;
+
+ pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left;
+ pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top;
+
+ time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(this.x-pos.left), Math.abs(this.y-pos.top)) : time;
+
+ this.scrollTo(pos.left, pos.top, time, easing);
+ },
+
+ _transitionTime: function (time) {
+ time = time || 0;
+
+ this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';
+
+ if ( !time && utils.isBadAndroid ) {
+ this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
+ }
+
+
+ if ( this.indicators ) {
+ for ( var i = this.indicators.length; i--; ) {
+ this.indicators[i].transitionTime(time);
+ }
+ }
+
+
+// INSERT POINT: _transitionTime
+
+ },
+
+ _transitionTimingFunction: function (easing) {
+ this.scrollerStyle[utils.style.transitionTimingFunction] = easing;
+
+
+ if ( this.indicators ) {
+ for ( var i = this.indicators.length; i--; ) {
+ this.indicators[i].transitionTimingFunction(easing);
+ }
+ }
+
+
+// INSERT POINT: _transitionTimingFunction
+
+ },
+
+ _translate: function (x, y) {
+ if ( this.options.useTransform ) {
+
+/* REPLACE START: _translate */
+
+ this.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.translateZ;
+
+/* REPLACE END: _translate */
+
+ } else {
+ x = Math.round(x);
+ y = Math.round(y);
+ this.scrollerStyle.left = x + 'px';
+ this.scrollerStyle.top = y + 'px';
+ }
+
+ this.x = x;
+ this.y = y;
+
+
+ if ( this.indicators ) {
+ for ( var i = this.indicators.length; i--; ) {
+ this.indicators[i].updatePosition();
+ }
+ }
+
+
+// INSERT POINT: _translate
+
+ },
+
+ _initEvents: function (remove) {
+ var eventType = remove ? utils.removeEvent : utils.addEvent,
+ target = this.options.bindToWrapper ? this.wrapper : window;
+
+ eventType(window, 'orientationchange', this);
+ eventType(window, 'resize', this);
+
+ if ( this.options.click ) {
+ eventType(this.wrapper, 'click', this, true);
+ }
+
+ if ( !this.options.disableMouse ) {
+ eventType(this.wrapper, 'mousedown', this);
+ eventType(target, 'mousemove', this);
+ eventType(target, 'mousecancel', this);
+ eventType(target, 'mouseup', this);
+ }
+
+ if ( utils.hasPointer && !this.options.disablePointer ) {
+ eventType(this.wrapper, 'MSPointerDown', this);
+ eventType(target, 'MSPointerMove', this);
+ eventType(target, 'MSPointerCancel', this);
+ eventType(target, 'MSPointerUp', this);
+ }
+
+ if ( utils.hasTouch && !this.options.disableTouch ) {
+ eventType(this.wrapper, 'touchstart', this);
+ eventType(target, 'touchmove', this);
+ eventType(target, 'touchcancel', this);
+ eventType(target, 'touchend', this);
+ }
+
+ eventType(this.scroller, 'transitionend', this);
+ eventType(this.scroller, 'webkitTransitionEnd', this);
+ eventType(this.scroller, 'oTransitionEnd', this);
+ eventType(this.scroller, 'MSTransitionEnd', this);
+ },
+
+ getComputedPosition: function () {
+ var matrix = window.getComputedStyle(this.scroller, null),
+ x, y;
+
+ if ( this.options.useTransform ) {
+ matrix = matrix[utils.style.transform].split(')')[0].split(', ');
+ x = +(matrix[12] || matrix[4]);
+ y = +(matrix[13] || matrix[5]);
+ } else {
+ x = +matrix.left.replace(/[^-\d.]/g, '');
+ y = +matrix.top.replace(/[^-\d.]/g, '');
+ }
+
+ return { x: x, y: y };
+ },
+
+ _initIndicators: function () {
+ var interactive = this.options.interactiveScrollbars,
+ customStyle = typeof this.options.scrollbars != 'string',
+ indicators = [],
+ indicator;
+
+ var that = this;
+
+ this.indicators = [];
+
+ if ( this.options.scrollbars ) {
+ // Vertical scrollbar
+ if ( this.options.scrollY ) {
+ indicator = {
+ el: createDefaultScrollbar('v', interactive, this.options.scrollbars),
+ interactive: interactive,
+ defaultScrollbars: true,
+ customStyle: customStyle,
+ resize: this.options.resizeScrollbars,
+ shrink: this.options.shrinkScrollbars,
+ fade: this.options.fadeScrollbars,
+ listenX: false
+ };
+
+ this.wrapper.appendChild(indicator.el);
+ indicators.push(indicator);
+ }
+
+ // Horizontal scrollbar
+ if ( this.options.scrollX ) {
+ indicator = {
+ el: createDefaultScrollbar('h', interactive, this.options.scrollbars),
+ interactive: interactive,
+ defaultScrollbars: true,
+ customStyle: customStyle,
+ resize: this.options.resizeScrollbars,
+ shrink: this.options.shrinkScrollbars,
+ fade: this.options.fadeScrollbars,
+ listenY: false
+ };
+
+ this.wrapper.appendChild(indicator.el);
+ indicators.push(indicator);
+ }
+ }
+
+ if ( this.options.indicators ) {
+ // TODO: check concat compatibility
+ indicators = indicators.concat(this.options.indicators);
+ }
+
+ for ( var i = indicators.length; i--; ) {
+ this.indicators.push( new Indicator(this, indicators[i]) );
+ }
+
+ // TODO: check if we can use array.map (wide compatibility and performance issues)
+ function _indicatorsMap (fn) {
+ for ( var i = that.indicators.length; i--; ) {
+ fn.call(that.indicators[i]);
+ }
+ }
+
+ if ( this.options.fadeScrollbars ) {
+ this.on('scrollEnd', function () {
+ _indicatorsMap(function () {
+ this.fade();
+ });
+ });
+
+ this.on('scrollCancel', function () {
+ _indicatorsMap(function () {
+ this.fade();
+ });
+ });
+
+ this.on('scrollStart', function () {
+ _indicatorsMap(function () {
+ this.fade(1);
+ });
+ });
+
+ this.on('beforeScrollStart', function () {
+ _indicatorsMap(function () {
+ this.fade(1, true);
+ });
+ });
+ }
+
+
+ this.on('refresh', function () {
+ _indicatorsMap(function () {
+ this.refresh();
+ });
+ });
+
+ this.on('destroy', function () {
+ _indicatorsMap(function () {
+ this.destroy();
+ });
+
+ delete this.indicators;
+ });
+ },
+
+ _initWheel: function () {
+ utils.addEvent(this.wrapper, 'wheel', this);
+ utils.addEvent(this.wrapper, 'mousewheel', this);
+ utils.addEvent(this.wrapper, 'DOMMouseScroll', this);
+
+ this.on('destroy', function () {
+ utils.removeEvent(this.wrapper, 'wheel', this);
+ utils.removeEvent(this.wrapper, 'mousewheel', this);
+ utils.removeEvent(this.wrapper, 'DOMMouseScroll', this);
+ });
+ },
+
+ _wheel: function (e) {
+ if ( !this.enabled ) {
+ return;
+ }
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ var wheelDeltaX, wheelDeltaY,
+ newX, newY,
+ that = this;
+
+ if ( this.wheelTimeout === undefined ) {
+ that._execEvent('scrollStart');
+ }
+
+ // Execute the scrollEnd event after 400ms the wheel stopped scrolling
+ clearTimeout(this.wheelTimeout);
+ this.wheelTimeout = setTimeout(function () {
+ that._execEvent('scrollEnd');
+ that.wheelTimeout = undefined;
+ }, 400);
+
+ if ( 'deltaX' in e ) {
+ wheelDeltaX = -e.deltaX;
+ wheelDeltaY = -e.deltaY;
+ } else if ( 'wheelDeltaX' in e ) {
+ wheelDeltaX = e.wheelDeltaX / 120 * this.options.mouseWheelSpeed;
+ wheelDeltaY = e.wheelDeltaY / 120 * this.options.mouseWheelSpeed;
+ } else if ( 'wheelDelta' in e ) {
+ wheelDeltaX = wheelDeltaY = e.wheelDelta / 120 * this.options.mouseWheelSpeed;
+ } else if ( 'detail' in e ) {
+ wheelDeltaX = wheelDeltaY = -e.detail / 3 * this.options.mouseWheelSpeed;
+ } else {
+ return;
+ }
+
+ wheelDeltaX *= this.options.invertWheelDirection;
+ wheelDeltaY *= this.options.invertWheelDirection;
+
+ if ( !this.hasVerticalScroll ) {
+ wheelDeltaX = wheelDeltaY;
+ wheelDeltaY = 0;
+ }
+
+ if ( this.options.snap ) {
+ newX = this.currentPage.pageX;
+ newY = this.currentPage.pageY;
+
+ if ( wheelDeltaX > 0 ) {
+ newX--;
+ } else if ( wheelDeltaX < 0 ) {
+ newX++;
+ }
+
+ if ( wheelDeltaY > 0 ) {
+ newY--;
+ } else if ( wheelDeltaY < 0 ) {
+ newY++;
+ }
+
+ this.goToPage(newX, newY);
+
+ return;
+ }
+
+ newX = this.x + Math.round(this.hasHorizontalScroll ? wheelDeltaX : 0);
+ newY = this.y + Math.round(this.hasVerticalScroll ? wheelDeltaY : 0);
+
+ if ( newX > 0 ) {
+ newX = 0;
+ } else if ( newX < this.maxScrollX ) {
+ newX = this.maxScrollX;
+ }
+
+ if ( newY > 0 ) {
+ newY = 0;
+ } else if ( newY < this.maxScrollY ) {
+ newY = this.maxScrollY;
+ }
+
+ this.scrollTo(newX, newY, 0);
+
+// INSERT POINT: _wheel
+ },
+
+ _initSnap: function () {
+ this.currentPage = {};
+
+ if ( typeof this.options.snap == 'string' ) {
+ this.options.snap = this.scroller.querySelectorAll(this.options.snap);
+ }
+
+ this.on('refresh', function () {
+ var i = 0, l,
+ m = 0, n,
+ cx, cy,
+ x = 0, y,
+ stepX = this.options.snapStepX || this.wrapperWidth,
+ stepY = this.options.snapStepY || this.wrapperHeight,
+ el;
+
+ this.pages = [];
+
+ if ( !this.wrapperWidth || !this.wrapperHeight || !this.scrollerWidth || !this.scrollerHeight ) {
+ return;
+ }
+
+ if ( this.options.snap === true ) {
+ cx = Math.round( stepX / 2 );
+ cy = Math.round( stepY / 2 );
+
+ while ( x > -this.scrollerWidth ) {
+ this.pages[i] = [];
+ l = 0;
+ y = 0;
+
+ while ( y > -this.scrollerHeight ) {
+ this.pages[i][l] = {
+ x: Math.max(x, this.maxScrollX),
+ y: Math.max(y, this.maxScrollY),
+ width: stepX,
+ height: stepY,
+ cx: x - cx,
+ cy: y - cy
+ };
+
+ y -= stepY;
+ l++;
+ }
+
+ x -= stepX;
+ i++;
+ }
+ } else {
+ el = this.options.snap;
+ l = el.length;
+ n = -1;
+
+ for ( ; i < l; i++ ) {
+ if ( i === 0 || el[i].offsetLeft <= el[i-1].offsetLeft ) {
+ m = 0;
+ n++;
+ }
+
+ if ( !this.pages[m] ) {
+ this.pages[m] = [];
+ }
+
+ x = Math.max(-el[i].offsetLeft, this.maxScrollX);
+ y = Math.max(-el[i].offsetTop, this.maxScrollY);
+ cx = x - Math.round(el[i].offsetWidth / 2);
+ cy = y - Math.round(el[i].offsetHeight / 2);
+
+ this.pages[m][n] = {
+ x: x,
+ y: y,
+ width: el[i].offsetWidth,
+ height: el[i].offsetHeight,
+ cx: cx,
+ cy: cy
+ };
+
+ if ( x > this.maxScrollX ) {
+ m++;
+ }
+ }
+ }
+
+ this.goToPage(this.currentPage.pageX || 0, this.currentPage.pageY || 0, 0);
+
+ // Update snap threshold if needed
+ if ( this.options.snapThreshold % 1 === 0 ) {
+ this.snapThresholdX = this.options.snapThreshold;
+ this.snapThresholdY = this.options.snapThreshold;
+ } else {
+ this.snapThresholdX = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width * this.options.snapThreshold);
+ this.snapThresholdY = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height * this.options.snapThreshold);
+ }
+ });
+
+ this.on('flick', function () {
+ var time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(this.x - this.startX), 1000),
+ Math.min(Math.abs(this.y - this.startY), 1000)
+ ), 300);
+
+ this.goToPage(
+ this.currentPage.pageX + this.directionX,
+ this.currentPage.pageY + this.directionY,
+ time
+ );
+ });
+ },
+
+ _nearestSnap: function (x, y) {
+ if ( !this.pages.length ) {
+ return { x: 0, y: 0, pageX: 0, pageY: 0 };
+ }
+
+ var i = 0,
+ l = this.pages.length,
+ m = 0;
+
+ // Check if we exceeded the snap threshold
+ if ( Math.abs(x - this.absStartX) < this.snapThresholdX &&
+ Math.abs(y - this.absStartY) < this.snapThresholdY ) {
+ return this.currentPage;
+ }
+
+ if ( x > 0 ) {
+ x = 0;
+ } else if ( x < this.maxScrollX ) {
+ x = this.maxScrollX;
+ }
+
+ if ( y > 0 ) {
+ y = 0;
+ } else if ( y < this.maxScrollY ) {
+ y = this.maxScrollY;
+ }
+
+ for ( ; i < l; i++ ) {
+ if ( x >= this.pages[i][0].cx ) {
+ x = this.pages[i][0].x;
+ break;
+ }
+ }
+
+ l = this.pages[i].length;
+
+ for ( ; m < l; m++ ) {
+ if ( y >= this.pages[0][m].cy ) {
+ y = this.pages[0][m].y;
+ break;
+ }
+ }
+
+ if ( i == this.currentPage.pageX ) {
+ i += this.directionX;
+
+ if ( i < 0 ) {
+ i = 0;
+ } else if ( i >= this.pages.length ) {
+ i = this.pages.length - 1;
+ }
+
+ x = this.pages[i][0].x;
+ }
+
+ if ( m == this.currentPage.pageY ) {
+ m += this.directionY;
+
+ if ( m < 0 ) {
+ m = 0;
+ } else if ( m >= this.pages[0].length ) {
+ m = this.pages[0].length - 1;
+ }
+
+ y = this.pages[0][m].y;
+ }
+
+ return {
+ x: x,
+ y: y,
+ pageX: i,
+ pageY: m
+ };
+ },
+
+ goToPage: function (x, y, time, easing) {
+ easing = easing || this.options.bounceEasing;
+
+ if ( x >= this.pages.length ) {
+ x = this.pages.length - 1;
+ } else if ( x < 0 ) {
+ x = 0;
+ }
+
+ if ( y >= this.pages[x].length ) {
+ y = this.pages[x].length - 1;
+ } else if ( y < 0 ) {
+ y = 0;
+ }
+
+ var posX = this.pages[x][y].x,
+ posY = this.pages[x][y].y;
+
+ time = time === undefined ? this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(posX - this.x), 1000),
+ Math.min(Math.abs(posY - this.y), 1000)
+ ), 300) : time;
+
+ this.currentPage = {
+ x: posX,
+ y: posY,
+ pageX: x,
+ pageY: y
+ };
+
+ this.scrollTo(posX, posY, time, easing);
+ },
+
+ next: function (time, easing) {
+ var x = this.currentPage.pageX,
+ y = this.currentPage.pageY;
+
+ x++;
+
+ if ( x >= this.pages.length && this.hasVerticalScroll ) {
+ x = 0;
+ y++;
+ }
+
+ this.goToPage(x, y, time, easing);
+ },
+
+ prev: function (time, easing) {
+ var x = this.currentPage.pageX,
+ y = this.currentPage.pageY;
+
+ x--;
+
+ if ( x < 0 && this.hasVerticalScroll ) {
+ x = 0;
+ y--;
+ }
+
+ this.goToPage(x, y, time, easing);
+ },
+
+ _initKeys: function (e) {
+ // default key bindings
+ var keys = {
+ pageUp: 33,
+ pageDown: 34,
+ end: 35,
+ home: 36,
+ left: 37,
+ up: 38,
+ right: 39,
+ down: 40
+ };
+ var i;
+
+ // if you give me characters I give you keycode
+ if ( typeof this.options.keyBindings == 'object' ) {
+ for ( i in this.options.keyBindings ) {
+ if ( typeof this.options.keyBindings[i] == 'string' ) {
+ this.options.keyBindings[i] = this.options.keyBindings[i].toUpperCase().charCodeAt(0);
+ }
+ }
+ } else {
+ this.options.keyBindings = {};
+ }
+
+ for ( i in keys ) {
+ this.options.keyBindings[i] = this.options.keyBindings[i] || keys[i];
+ }
+
+ utils.addEvent(window, 'keydown', this);
+
+ this.on('destroy', function () {
+ utils.removeEvent(window, 'keydown', this);
+ });
+ },
+
+ _key: function (e) {
+ if ( !this.enabled ) {
+ return;
+ }
+
+ var snap = this.options.snap, // we are using this alot, better to cache it
+ newX = snap ? this.currentPage.pageX : this.x,
+ newY = snap ? this.currentPage.pageY : this.y,
+ now = utils.getTime(),
+ prevTime = this.keyTime || 0,
+ acceleration = 0.250,
+ pos;
+
+ if ( this.options.useTransition && this.isInTransition ) {
+ pos = this.getComputedPosition();
+
+ this._translate(Math.round(pos.x), Math.round(pos.y));
+ this.isInTransition = false;
+ }
+
+ this.keyAcceleration = now - prevTime < 200 ? Math.min(this.keyAcceleration + acceleration, 50) : 0;
+
+ switch ( e.keyCode ) {
+ case this.options.keyBindings.pageUp:
+ if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
+ newX += snap ? 1 : this.wrapperWidth;
+ } else {
+ newY += snap ? 1 : this.wrapperHeight;
+ }
+ break;
+ case this.options.keyBindings.pageDown:
+ if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
+ newX -= snap ? 1 : this.wrapperWidth;
+ } else {
+ newY -= snap ? 1 : this.wrapperHeight;
+ }
+ break;
+ case this.options.keyBindings.end:
+ newX = snap ? this.pages.length-1 : this.maxScrollX;
+ newY = snap ? this.pages[0].length-1 : this.maxScrollY;
+ break;
+ case this.options.keyBindings.home:
+ newX = 0;
+ newY = 0;
+ break;
+ case this.options.keyBindings.left:
+ newX += snap ? -1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.up:
+ newY += snap ? 1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.right:
+ newX -= snap ? -1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.down:
+ newY -= snap ? 1 : 5 + this.keyAcceleration>>0;
+ break;
+ default:
+ return;
+ }
+
+ if ( snap ) {
+ this.goToPage(newX, newY);
+ return;
+ }
+
+ if ( newX > 0 ) {
+ newX = 0;
+ this.keyAcceleration = 0;
+ } else if ( newX < this.maxScrollX ) {
+ newX = this.maxScrollX;
+ this.keyAcceleration = 0;
+ }
+
+ if ( newY > 0 ) {
+ newY = 0;
+ this.keyAcceleration = 0;
+ } else if ( newY < this.maxScrollY ) {
+ newY = this.maxScrollY;
+ this.keyAcceleration = 0;
+ }
+
+ this.scrollTo(newX, newY, 0);
+
+ this.keyTime = now;
+ },
+
+ _animate: function (destX, destY, duration, easingFn) {
+ var that = this,
+ startX = this.x,
+ startY = this.y,
+ startTime = utils.getTime(),
+ destTime = startTime + duration;
+
+ function step () {
+ var now = utils.getTime(),
+ newX, newY,
+ easing;
+
+ if ( now >= destTime ) {
+ that.isAnimating = false;
+ that._translate(destX, destY);
+
+ if ( !that.resetPosition(that.options.bounceTime) ) {
+ that._execEvent('scrollEnd');
+ }
+
+ return;
+ }
+
+ now = ( now - startTime ) / duration;
+ easing = easingFn(now);
+ newX = ( destX - startX ) * easing + startX;
+ newY = ( destY - startY ) * easing + startY;
+ that._translate(newX, newY);
+
+ if ( that.isAnimating ) {
+ rAF(step);
+ }
+ }
+
+ this.isAnimating = true;
+ step();
+ },
+ handleEvent: function (e) {
+ switch ( e.type ) {
+ case 'touchstart':
+ case 'MSPointerDown':
+ case 'mousedown':
+ this._start(e);
+ break;
+ case 'touchmove':
+ case 'MSPointerMove':
+ case 'mousemove':
+ this._move(e);
+ break;
+ case 'touchend':
+ case 'MSPointerUp':
+ case 'mouseup':
+ case 'touchcancel':
+ case 'MSPointerCancel':
+ case 'mousecancel':
+ this._end(e);
+ break;
+ case 'orientationchange':
+ case 'resize':
+ this._resize();
+ break;
+ case 'transitionend':
+ case 'webkitTransitionEnd':
+ case 'oTransitionEnd':
+ case 'MSTransitionEnd':
+ this._transitionEnd(e);
+ break;
+ case 'wheel':
+ case 'DOMMouseScroll':
+ case 'mousewheel':
+ this._wheel(e);
+ break;
+ case 'keydown':
+ this._key(e);
+ break;
+ case 'click':
+ if ( !e._constructed ) {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ break;
+ }
+ }
+};
+function createDefaultScrollbar (direction, interactive, type) {
+ var scrollbar = document.createElement('div'),
+ indicator = document.createElement('div');
+
+ if ( type === true ) {
+ scrollbar.style.cssText = 'position:absolute;z-index:9999';
+ indicator.style.cssText = '-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px';
+ }
+
+ indicator.className = 'iScrollIndicator';
+
+ if ( direction == 'h' ) {
+ if ( type === true ) {
+ scrollbar.style.cssText += ';height:7px;left:2px;right:2px;bottom:0';
+ indicator.style.height = '100%';
+ }
+ scrollbar.className = 'iScrollHorizontalScrollbar';
+ } else {
+ if ( type === true ) {
+ scrollbar.style.cssText += ';width:7px;bottom:2px;top:2px;right:1px';
+ indicator.style.width = '100%';
+ }
+ scrollbar.className = 'iScrollVerticalScrollbar';
+ }
+
+ scrollbar.style.cssText += ';overflow:hidden';
+
+ if ( !interactive ) {
+ scrollbar.style.pointerEvents = 'none';
+ }
+
+ scrollbar.appendChild(indicator);
+
+ return scrollbar;
+}
+
+function Indicator (scroller, options) {
+ this.wrapper = typeof options.el == 'string' ? document.querySelector(options.el) : options.el;
+ this.wrapperStyle = this.wrapper.style;
+ this.indicator = this.wrapper.children[0];
+ this.indicatorStyle = this.indicator.style;
+ this.scroller = scroller;
+
+ this.options = {
+ listenX: true,
+ listenY: true,
+ interactive: false,
+ resize: true,
+ defaultScrollbars: false,
+ shrink: false,
+ fade: false,
+ speedRatioX: 0,
+ speedRatioY: 0
+ };
+
+ for ( var i in options ) {
+ this.options[i] = options[i];
+ }
+
+ this.sizeRatioX = 1;
+ this.sizeRatioY = 1;
+ this.maxPosX = 0;
+ this.maxPosY = 0;
+
+ if ( this.options.interactive ) {
+ if ( !this.options.disableTouch ) {
+ utils.addEvent(this.indicator, 'touchstart', this);
+ utils.addEvent(window, 'touchend', this);
+ }
+ if ( !this.options.disablePointer ) {
+ utils.addEvent(this.indicator, 'MSPointerDown', this);
+ utils.addEvent(window, 'MSPointerUp', this);
+ }
+ if ( !this.options.disableMouse ) {
+ utils.addEvent(this.indicator, 'mousedown', this);
+ utils.addEvent(window, 'mouseup', this);
+ }
+ }
+
+ if ( this.options.fade ) {
+ this.wrapperStyle[utils.style.transform] = this.scroller.translateZ;
+ this.wrapperStyle[utils.style.transitionDuration] = utils.isBadAndroid ? '0.001s' : '0ms';
+ this.wrapperStyle.opacity = '0';
+ }
+}
+
+Indicator.prototype = {
+ handleEvent: function (e) {
+ switch ( e.type ) {
+ case 'touchstart':
+ case 'MSPointerDown':
+ case 'mousedown':
+ this._start(e);
+ break;
+ case 'touchmove':
+ case 'MSPointerMove':
+ case 'mousemove':
+ this._move(e);
+ break;
+ case 'touchend':
+ case 'MSPointerUp':
+ case 'mouseup':
+ case 'touchcancel':
+ case 'MSPointerCancel':
+ case 'mousecancel':
+ this._end(e);
+ break;
+ }
+ },
+
+ destroy: function () {
+ if ( this.options.interactive ) {
+ utils.removeEvent(this.indicator, 'touchstart', this);
+ utils.removeEvent(this.indicator, 'MSPointerDown', this);
+ utils.removeEvent(this.indicator, 'mousedown', this);
+
+ utils.removeEvent(window, 'touchmove', this);
+ utils.removeEvent(window, 'MSPointerMove', this);
+ utils.removeEvent(window, 'mousemove', this);
+
+ utils.removeEvent(window, 'touchend', this);
+ utils.removeEvent(window, 'MSPointerUp', this);
+ utils.removeEvent(window, 'mouseup', this);
+ }
+
+ if ( this.options.defaultScrollbars ) {
+ this.wrapper.parentNode.removeChild(this.wrapper);
+ }
+ },
+
+ _start: function (e) {
+ var point = e.touches ? e.touches[0] : e;
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ this.transitionTime();
+
+ this.initiated = true;
+ this.moved = false;
+ this.lastPointX = point.pageX;
+ this.lastPointY = point.pageY;
+
+ this.startTime = utils.getTime();
+
+ if ( !this.options.disableTouch ) {
+ utils.addEvent(window, 'touchmove', this);
+ }
+ if ( !this.options.disablePointer ) {
+ utils.addEvent(window, 'MSPointerMove', this);
+ }
+ if ( !this.options.disableMouse ) {
+ utils.addEvent(window, 'mousemove', this);
+ }
+
+ this.scroller._execEvent('beforeScrollStart');
+ },
+
+ _move: function (e) {
+ var point = e.touches ? e.touches[0] : e,
+ deltaX, deltaY,
+ newX, newY,
+ timestamp = utils.getTime();
+
+ if ( !this.moved ) {
+ this.scroller._execEvent('scrollStart');
+ }
+
+ this.moved = true;
+
+ deltaX = point.pageX - this.lastPointX;
+ this.lastPointX = point.pageX;
+
+ deltaY = point.pageY - this.lastPointY;
+ this.lastPointY = point.pageY;
+
+ newX = this.x + deltaX;
+ newY = this.y + deltaY;
+
+ this._pos(newX, newY);
+
+// INSERT POINT: indicator._move
+
+ e.preventDefault();
+ e.stopPropagation();
+ },
+
+ _end: function (e) {
+ if ( !this.initiated ) {
+ return;
+ }
+
+ this.initiated = false;
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ utils.removeEvent(window, 'touchmove', this);
+ utils.removeEvent(window, 'MSPointerMove', this);
+ utils.removeEvent(window, 'mousemove', this);
+
+ if ( this.scroller.options.snap ) {
+ var snap = this.scroller._nearestSnap(this.scroller.x, this.scroller.y);
+
+ var time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(this.scroller.x - snap.x), 1000),
+ Math.min(Math.abs(this.scroller.y - snap.y), 1000)
+ ), 300);
+
+ if ( this.scroller.x != snap.x || this.scroller.y != snap.y ) {
+ this.scroller.directionX = 0;
+ this.scroller.directionY = 0;
+ this.scroller.currentPage = snap;
+ this.scroller.scrollTo(snap.x, snap.y, time, this.scroller.options.bounceEasing);
+ }
+ }
+
+ if ( this.moved ) {
+ this.scroller._execEvent('scrollEnd');
+ }
+ },
+
+ transitionTime: function (time) {
+ time = time || 0;
+ this.indicatorStyle[utils.style.transitionDuration] = time + 'ms';
+
+ if ( !time && utils.isBadAndroid ) {
+ this.indicatorStyle[utils.style.transitionDuration] = '0.001s';
+ }
+ },
+
+ transitionTimingFunction: function (easing) {
+ this.indicatorStyle[utils.style.transitionTimingFunction] = easing;
+ },
+
+ refresh: function () {
+ this.transitionTime();
+
+ if ( this.options.listenX && !this.options.listenY ) {
+ this.indicatorStyle.display = this.scroller.hasHorizontalScroll ? 'block' : 'none';
+ } else if ( this.options.listenY && !this.options.listenX ) {
+ this.indicatorStyle.display = this.scroller.hasVerticalScroll ? 'block' : 'none';
+ } else {
+ this.indicatorStyle.display = this.scroller.hasHorizontalScroll || this.scroller.hasVerticalScroll ? 'block' : 'none';
+ }
+
+ if ( this.scroller.hasHorizontalScroll && this.scroller.hasVerticalScroll ) {
+ utils.addClass(this.wrapper, 'iScrollBothScrollbars');
+ utils.removeClass(this.wrapper, 'iScrollLoneScrollbar');
+
+ if ( this.options.defaultScrollbars && this.options.customStyle ) {
+ if ( this.options.listenX ) {
+ this.wrapper.style.right = '8px';
+ } else {
+ this.wrapper.style.bottom = '8px';
+ }
+ }
+ } else {
+ utils.removeClass(this.wrapper, 'iScrollBothScrollbars');
+ utils.addClass(this.wrapper, 'iScrollLoneScrollbar');
+
+ if ( this.options.defaultScrollbars && this.options.customStyle ) {
+ if ( this.options.listenX ) {
+ this.wrapper.style.right = '2px';
+ } else {
+ this.wrapper.style.bottom = '2px';
+ }
+ }
+ }
+
+ var r = this.wrapper.offsetHeight; // force refresh
+
+ if ( this.options.listenX ) {
+ this.wrapperWidth = this.wrapper.clientWidth;
+ if ( this.options.resize ) {
+ this.indicatorWidth = Math.max(Math.round(this.wrapperWidth * this.wrapperWidth / (this.scroller.scrollerWidth || this.wrapperWidth || 1)), 8);
+ this.indicatorStyle.width = this.indicatorWidth + 'px';
+ } else {
+ this.indicatorWidth = this.indicator.clientWidth;
+ }
+
+ this.maxPosX = this.wrapperWidth - this.indicatorWidth;
+
+ if ( this.options.shrink == 'clip' ) {
+ this.minBoundaryX = -this.indicatorWidth + 8;
+ this.maxBoundaryX = this.wrapperWidth - 8;
+ } else {
+ this.minBoundaryX = 0;
+ this.maxBoundaryX = this.maxPosX;
+ }
+
+ this.sizeRatioX = this.options.speedRatioX || (this.scroller.maxScrollX && (this.maxPosX / this.scroller.maxScrollX));
+ }
+
+ if ( this.options.listenY ) {
+ this.wrapperHeight = this.wrapper.clientHeight;
+ if ( this.options.resize ) {
+ this.indicatorHeight = Math.max(Math.round(this.wrapperHeight * this.wrapperHeight / (this.scroller.scrollerHeight || this.wrapperHeight || 1)), 8);
+ this.indicatorStyle.height = this.indicatorHeight + 'px';
+ } else {
+ this.indicatorHeight = this.indicator.clientHeight;
+ }
+
+ this.maxPosY = this.wrapperHeight - this.indicatorHeight;
+
+ if ( this.options.shrink == 'clip' ) {
+ this.minBoundaryY = -this.indicatorHeight + 8;
+ this.maxBoundaryY = this.wrapperHeight - 8;
+ } else {
+ 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 x = this.options.listenX && Math.round(this.sizeRatioX * this.scroller.x) || 0,
+ y = this.options.listenY && Math.round(this.sizeRatioY * this.scroller.y) || 0;
+
+ if ( !this.options.ignoreBoundaries ) {
+ if ( x < this.minBoundaryX ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.width = Math.max(this.indicatorWidth + x, 8);
+ this.indicatorStyle.width = this.width + 'px';
+ }
+ x = this.minBoundaryX;
+ } else if ( x > this.maxBoundaryX ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.width = Math.max(this.indicatorWidth - (x - this.maxPosX), 8);
+ this.indicatorStyle.width = this.width + 'px';
+ x = this.maxPosX + this.indicatorWidth - this.width;
+ } else {
+ x = this.maxBoundaryX;
+ }
+ } else if ( this.options.shrink == 'scale' && this.width != this.indicatorWidth ) {
+ this.width = this.indicatorWidth;
+ this.indicatorStyle.width = this.width + 'px';
+ }
+
+ if ( y < this.minBoundaryY ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.height = Math.max(this.indicatorHeight + y * 3, 8);
+ this.indicatorStyle.height = this.height + 'px';
+ }
+ y = this.minBoundaryY;
+ } else if ( y > this.maxBoundaryY ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.height = Math.max(this.indicatorHeight - (y - this.maxPosY) * 3, 8);
+ this.indicatorStyle.height = this.height + 'px';
+ y = this.maxPosY + this.indicatorHeight - this.height;
+ } else {
+ y = this.maxBoundaryY;
+ }
+ } else if ( this.options.shrink == 'scale' && this.height != this.indicatorHeight ) {
+ this.height = this.indicatorHeight;
+ this.indicatorStyle.height = this.height + 'px';
+ }
+ }
+
+ this.x = x;
+ this.y = y;
+
+ if ( this.scroller.options.useTransform ) {
+ this.indicatorStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.scroller.translateZ;
+ } else {
+ this.indicatorStyle.left = x + 'px';
+ this.indicatorStyle.top = y + 'px';
+ }
+ },
+
+ _pos: function (x, y) {
+ if ( x < 0 ) {
+ x = 0;
+ } else if ( x > this.maxPosX ) {
+ x = this.maxPosX;
+ }
+
+ if ( y < 0 ) {
+ y = 0;
+ } else if ( y > this.maxPosY ) {
+ y = this.maxPosY;
+ }
+
+ x = this.options.listenX ? Math.round(x / this.sizeRatioX) : this.scroller.x;
+ y = this.options.listenY ? Math.round(y / this.sizeRatioY) : this.scroller.y;
+
+ this.scroller.scrollTo(x, y);
+ },
+
+ fade: function (val, hold) {
+ if ( hold && !this.visible ) {
+ return;
+ }
+
+ clearTimeout(this.fadeTimeout);
+ this.fadeTimeout = null;
+
+ var time = val ? 250 : 500,
+ delay = val ? 0 : 300;
+
+ val = val ? '1' : '0';
+
+ this.wrapperStyle[utils.style.transitionDuration] = time + 'ms';
+
+ this.fadeTimeout = setTimeout((function (val) {
+ this.wrapperStyle.opacity = val;
+ this.visible = +val;
+ }).bind(this, val), delay);
+ }
+};
+
+IScroll.utils = utils;
+
+if ( typeof module != 'undefined' && module.exports ) {
+ module.exports = IScroll;
+} else {
+ window.IScroll = IScroll;
+}
+
+})(window, document, Math);
\ No newline at end of file
diff --git a/demos/2d-scroll/index.html b/demos/2d-scroll/index.html
new file mode 100644
index 0000000..f9ad195
--- /dev/null
+++ b/demos/2d-scroll/index.html
@@ -0,0 +1,138 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: 2d scroll</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', { scrollX: true, freeScroll: true });
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#header {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#footer {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 48px;
+ background: #444;
+ padding: 0;
+ border-top: 1px solid #444;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 45px;
+ bottom: 48px;
+ left: 0;
+ width: 100%;
+ background: #ccc;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 2000px;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+ background: #fff;
+}
+
+p {
+ font-size: 16px;
+ padding: 1.2em;
+ line-height: 200%;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+<div id="header">iScroll</div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur [...]
+
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur [...]
+
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur [...]
+
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur [...]
+
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur [...]
+
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur [...]
+ </div>
+</div>
+
+<div id="footer"></div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/barebone/index.html b/demos/barebone/index.html
new file mode 100644
index 0000000..9bdff05
--- /dev/null
+++ b/demos/barebone/index.html
@@ -0,0 +1,84 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: barebone</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper');
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style>
+body {
+ /* On modern browsers, prevent the whole page to bounce */
+ overflow: hidden;
+}
+
+#wrapper {
+ position: relative;
+ width: 300px;
+ height: 300px;
+ overflow: hidden;
+
+ /* Prevent native touch events on Windows */
+ -ms-touch-action: none;
+
+ /* Prevent the callout on tap-hold and text selection */
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+
+ /* Prevent text resize on orientation change, useful for web-apps */
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller {
+ position: absolute;
+
+ /* Prevent elements to be highlighted on tap */
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+
+ /* Put the scroller into the HW Compositing layer right from the start */
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+}
+</style>
+
+</head>
+<body onload="loaded()">
+
+<div id="wrapper">
+ <div id="scroller">
+ <p><strong>This demo shows the minimum CSS/HTML/JS configuration you need to run the iScroll. Look at the source code for details.</strong></p>
+
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+
+ <p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam e [...]
+
+ <p>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis [...]
+ </div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/bounce-easing/index.html b/demos/bounce-easing/index.html
new file mode 100644
index 0000000..c5a9f62
--- /dev/null
+++ b/demos/bounce-easing/index.html
@@ -0,0 +1,190 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: bounce easing</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', { bounceEasing: 'elastic', bounceTime: 1200 });
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#header {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#footer {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 48px;
+ background: #444;
+ padding: 0;
+ border-top: 1px solid #444;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 45px;
+ bottom: 48px;
+ left: 0;
+ width: 100%;
+ background: #ccc;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 100%;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ text-align: left;
+}
+
+#scroller li {
+ padding: 0 10px;
+ height: 40px;
+ line-height: 40px;
+ border-bottom: 1px solid #ccc;
+ border-top: 1px solid #fff;
+ background-color: #fafafa;
+ font-size: 14px;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+<div id="header">iScroll</div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li>Pretty row 1</li>
+ <li>Pretty row 2</li>
+ <li>Pretty row 3</li>
+ <li>Pretty row 4</li>
+ <li>Pretty row 5</li>
+ <li>Pretty row 6</li>
+ <li>Pretty row 7</li>
+ <li>Pretty row 8</li>
+ <li>Pretty row 9</li>
+ <li>Pretty row 10</li>
+ <li>Pretty row 11</li>
+ <li>Pretty row 12</li>
+ <li>Pretty row 13</li>
+ <li>Pretty row 14</li>
+ <li>Pretty row 15</li>
+ <li>Pretty row 16</li>
+ <li>Pretty row 17</li>
+ <li>Pretty row 18</li>
+ <li>Pretty row 19</li>
+ <li>Pretty row 20</li>
+ <li>Pretty row 21</li>
+ <li>Pretty row 22</li>
+ <li>Pretty row 23</li>
+ <li>Pretty row 24</li>
+ <li>Pretty row 25</li>
+ <li>Pretty row 26</li>
+ <li>Pretty row 27</li>
+ <li>Pretty row 28</li>
+ <li>Pretty row 29</li>
+ <li>Pretty row 30</li>
+ <li>Pretty row 31</li>
+ <li>Pretty row 32</li>
+ <li>Pretty row 33</li>
+ <li>Pretty row 34</li>
+ <li>Pretty row 35</li>
+ <li>Pretty row 36</li>
+ <li>Pretty row 37</li>
+ <li>Pretty row 38</li>
+ <li>Pretty row 39</li>
+ <li>Pretty row 40</li>
+ <li>Pretty row 41</li>
+ <li>Pretty row 42</li>
+ <li>Pretty row 43</li>
+ <li>Pretty row 44</li>
+ <li>Pretty row 45</li>
+ <li>Pretty row 46</li>
+ <li>Pretty row 47</li>
+ <li>Pretty row 48</li>
+ <li>Pretty row 49</li>
+ <li>Pretty row 50</li>
+ </ul>
+ </div>
+</div>
+
+<div id="footer"></div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/carousel/gaugin.jpg b/demos/carousel/gaugin.jpg
new file mode 100644
index 0000000..ad5ecf8
Binary files /dev/null and b/demos/carousel/gaugin.jpg differ
diff --git a/demos/carousel/giotto.jpg b/demos/carousel/giotto.jpg
new file mode 100644
index 0000000..16e2a87
Binary files /dev/null and b/demos/carousel/giotto.jpg differ
diff --git a/demos/carousel/index.html b/demos/carousel/index.html
new file mode 100644
index 0000000..6744d30
--- /dev/null
+++ b/demos/carousel/index.html
@@ -0,0 +1,173 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: carousel</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', {
+ scrollX: true,
+ scrollY: false,
+ momentum: false,
+ snap: true,
+ snapSpeed: 400,
+ keyBindings: true,
+ indicators: {
+ el: document.getElementById('indicator'),
+ resize: false
+ }
+ });
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body, ul, li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#viewport {
+ position: relative;
+ width: 320px;
+ height: 240px;
+ margin: 0 auto;
+ background: #444;
+ overflow: hidden;
+}
+
+#wrapper {
+ width: 200px;
+ height: 240px;
+ margin: 0 auto;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 800px;
+ height: 240px;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+ background-color: #444;
+}
+
+.slide {
+ width: 200px;
+ height: 240px;
+ float: left;
+}
+
+.painting {
+ width: 140px;
+ height: 200px;
+ border-radius: 10px;
+ margin: 20px auto;
+ border: 1px solid #000;
+ box-shadow:
+ inset 2px 2px 6px rgba(255,255,255,0.6),
+ inset -2px -2px 6px rgba(0,0,0,0.6),
+ 0 1px 8px rgba(0,0,0,0.8);
+}
+
+.giotto {
+ background: url(giotto.jpg);
+}
+
+.leonardo {
+ background: url(leonardo.jpg);
+}
+
+.gaugin {
+ background: url(gaugin.jpg);
+}
+
+.warhol {
+ background: url(warhol.jpg);
+}
+
+#indicator {
+ position: relative;
+ width: 110px;
+ height: 20px;
+ margin: 10px auto;
+ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAUBAMAAABohZD3AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QUGCDYztyDUJgAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAAGFBMVEUAAADNzc3Nzc3Nzc3Nzc3Nzc3Nzc3///8aWwwLAAAABnRSTlMAX5Ks3/nRD0HIAAAAAWJLR0QHFmGI6wAAAFtJREFUGFdjYGBgEHYNMWRAAJE0IHCEc5nSwEABxleD8JOgXMY0KBCA8FlgfAcIXwzGT4TwzWD8ZAjfDcZPgfDDYPxU7Hx09ejmoduH7h5096L7B8O/6OGBGl4APYg8TQ0XAScAAAAASUVORK5CYII=);
+}
+
+#dotty {
+ position: absolute;
+ width: 20px;
+ height: 20px;
+ border-radius: 10px;
+ background: #777;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+
+<div id="viewport">
+ <div id="wrapper">
+ <div id="scroller">
+ <div class="slide">
+ <div class="painting giotto"></div>
+ </div>
+ <div class="slide">
+ <div class="painting leonardo"></div>
+ </div>
+ <div class="slide">
+ <div class="painting gaugin"></div>
+ </div>
+ <div class="slide">
+ <div class="painting warhol"></div>
+ </div>
+ </div>
+ </div>
+</div>
+
+<div id="indicator">
+ <div id="dotty"></div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/carousel/leonardo.jpg b/demos/carousel/leonardo.jpg
new file mode 100644
index 0000000..96d4d2f
Binary files /dev/null and b/demos/carousel/leonardo.jpg differ
diff --git a/demos/carousel/warhol.jpg b/demos/carousel/warhol.jpg
new file mode 100644
index 0000000..9eee300
Binary files /dev/null and b/demos/carousel/warhol.jpg differ
diff --git a/demos/click/index.html b/demos/click/index.html
new file mode 100644
index 0000000..45b97f6
--- /dev/null
+++ b/demos/click/index.html
@@ -0,0 +1,190 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: click</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', { mouseWheel: true, click: true });
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#header {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#footer {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 48px;
+ background: #444;
+ padding: 0;
+ border-top: 1px solid #444;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 45px;
+ bottom: 48px;
+ left: 0;
+ width: 100%;
+ background: #ccc;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 100%;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ text-align: left;
+}
+
+#scroller li {
+ padding: 0 10px;
+ height: 40px;
+ line-height: 40px;
+ border-bottom: 1px solid #ccc;
+ border-top: 1px solid #fff;
+ background-color: #fafafa;
+ font-size: 14px;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+<div id="header">iScroll</div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li>Pretty row 1</li>
+ <li>Pretty row 2</li>
+ <li>Pretty row 3</li>
+ <li>Pretty row 4</li>
+ <li>Pretty row 5</li>
+ <li id="me"><a href="#" onclick="console.log(this.parentNode.style.backgroundColor);this.parentNode.style.backgroundColor=this.parentNode.style.backgroundColor==''?'#a00':'';return false">Click me!</a></li>
+ <li>Pretty row 7</li>
+ <li>Pretty row 8</li>
+ <li>Pretty row 9</li>
+ <li>Pretty row 10</li>
+ <li>Pretty row 11</li>
+ <li>Pretty row 12</li>
+ <li>Pretty row 13</li>
+ <li>Pretty row 14</li>
+ <li>Pretty row 15</li>
+ <li>Pretty row 16</li>
+ <li>Pretty row 17</li>
+ <li>Pretty row 18</li>
+ <li>Pretty row 19</li>
+ <li>Pretty row 20</li>
+ <li>Pretty row 21</li>
+ <li>Pretty row 22</li>
+ <li>Pretty row 23</li>
+ <li>Pretty row 24</li>
+ <li>Pretty row 25</li>
+ <li>Pretty row 26</li>
+ <li>Pretty row 27</li>
+ <li>Pretty row 28</li>
+ <li>Pretty row 29</li>
+ <li>Pretty row 30</li>
+ <li>Pretty row 31</li>
+ <li>Pretty row 32</li>
+ <li>Pretty row 33</li>
+ <li>Pretty row 34</li>
+ <li>Pretty row 35</li>
+ <li>Pretty row 36</li>
+ <li>Pretty row 37</li>
+ <li>Pretty row 38</li>
+ <li>Pretty row 39</li>
+ <li>Pretty row 40</li>
+ <li>Pretty row 41</li>
+ <li>Pretty row 42</li>
+ <li>Pretty row 43</li>
+ <li>Pretty row 44</li>
+ <li>Pretty row 45</li>
+ <li>Pretty row 46</li>
+ <li>Pretty row 47</li>
+ <li>Pretty row 48</li>
+ <li>Pretty row 49</li>
+ <li>Pretty row 50</li>
+ </ul>
+ </div>
+</div>
+
+<div id="footer"></div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/event-passthrough/index.html b/demos/event-passthrough/index.html
new file mode 100644
index 0000000..1f4ec8b
--- /dev/null
+++ b/demos/event-passthrough/index.html
@@ -0,0 +1,155 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: Event Passthrough</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', { eventPassthrough: true, scrollX: true, scrollY: false, preventDefault: false });
+}
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+}
+
+#header {
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#wrapper {
+ position: relative;
+ z-index: 1;
+ height: 160px;
+ width: 100%;
+ background: #ccc;
+ overflow: hidden;
+ -ms-touch-action: none;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 2400px;
+ height: 160px;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller ul {
+ list-style: none;
+ width: 100%;
+ padding: 0;
+ margin: 0;
+}
+
+#scroller li {
+ width: 120px;
+ height: 160px;
+ float: left;
+ line-height: 160px;
+ border-right: 1px solid #ccc;
+ border-bottom: 1px solid #ccc;
+ background-color: #fafafa;
+ font-size: 14px;
+ overflow: hidden;
+ text-align: center;
+}
+
+p {
+ font-size: 16px;
+ padding: 1.2em;
+ line-height: 200%;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+<div id="header">iScroll</div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li>Pretty cell 1</li>
+ <li>Pretty cell 2</li>
+ <li>Pretty cell 3</li>
+ <li>Pretty cell 4</li>
+ <li>Pretty cell 5</li>
+ <li>Pretty cell 6</li>
+ <li>Pretty cell 7</li>
+ <li>Pretty cell 8</li>
+ <li>Pretty cell 9</li>
+ <li>Pretty cell 10</li>
+ <li>Pretty cell 11</li>
+ <li>Pretty cell 12</li>
+ <li>Pretty cell 13</li>
+ <li>Pretty cell 14</li>
+ <li>Pretty cell 15</li>
+ <li>Pretty cell 16</li>
+ <li>Pretty cell 17</li>
+ <li>Pretty cell 18</li>
+ <li>Pretty cell 19</li>
+ <li>Pretty cell 20</li>
+ </ul>
+ </div>
+</div>
+
+<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+
+<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+
+<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+
+<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+
+<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+
+<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/forms/index.html b/demos/forms/index.html
new file mode 100644
index 0000000..2dc8f5c
--- /dev/null
+++ b/demos/forms/index.html
@@ -0,0 +1,190 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: simple</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', { mouseWheel: true });
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#header {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#footer {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 48px;
+ background: #444;
+ padding: 0;
+ border-top: 1px solid #444;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 45px;
+ bottom: 48px;
+ left: 0;
+ width: 100%;
+ background: #ccc;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 100%;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ text-align: left;
+}
+
+#scroller li {
+ padding: 0 10px;
+ height: 40px;
+ line-height: 40px;
+ border-bottom: 1px solid #ccc;
+ border-top: 1px solid #fff;
+ background-color: #fafafa;
+ font-size: 14px;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+<div id="header">iScroll</div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li>Pretty row 1</li>
+ <li>Pretty row 2</li>
+ <li>Pretty row 3</li>
+ <li>Pretty row 4</li>
+ <li><input type="text"></li>
+ <li>Pretty row 6</li>
+ <li>Pretty row 7</li>
+ <li>Pretty row 8</li>
+ <li><input type="checkbox"></li>
+ <li>Pretty row 10</li>
+ <li>Pretty row 11</li>
+ <li>Pretty row 12</li>
+ <li><input type="radio"></li>
+ <li>Pretty row 14</li>
+ <li>Pretty row 15</li>
+ <li>Pretty row 16</li>
+ <li><textarea></textarea></li>
+ <li>Pretty row 18</li>
+ <li>Pretty row 19</li>
+ <li>Pretty row 20</li>
+ <li><select><option>option</option></select></li>
+ <li>Pretty row 22</li>
+ <li>Pretty row 23</li>
+ <li>Pretty row 24</li>
+ <li>Pretty row 25</li>
+ <li>Pretty row 26</li>
+ <li>Pretty row 27</li>
+ <li>Pretty row 28</li>
+ <li>Pretty row 29</li>
+ <li>Pretty row 30</li>
+ <li>Pretty row 31</li>
+ <li>Pretty row 32</li>
+ <li>Pretty row 33</li>
+ <li>Pretty row 34</li>
+ <li>Pretty row 35</li>
+ <li>Pretty row 36</li>
+ <li>Pretty row 37</li>
+ <li>Pretty row 38</li>
+ <li>Pretty row 39</li>
+ <li>Pretty row 40</li>
+ <li>Pretty row 41</li>
+ <li>Pretty row 42</li>
+ <li>Pretty row 43</li>
+ <li>Pretty row 44</li>
+ <li>Pretty row 45</li>
+ <li>Pretty row 46</li>
+ <li>Pretty row 47</li>
+ <li>Pretty row 48</li>
+ <li>Pretty row 49</li>
+ <li>Pretty row 50</li>
+ </ul>
+ </div>
+</div>
+
+<div id="footer"></div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/horizontal/index.html b/demos/horizontal/index.html
new file mode 100644
index 0000000..e442f7d
--- /dev/null
+++ b/demos/horizontal/index.html
@@ -0,0 +1,193 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: horizontal scrolling</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', { scrollX: true, scrollY: false, mouseWheel: true });
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#header {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#footer {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 48px;
+ background: #444;
+ padding: 0;
+ border-top: 1px solid #444;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 45px;
+ bottom: 48px;
+ left: 0;
+ width: 100%;
+ background: #ccc;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 5000px;
+ height: 100%;
+ background-color: #a00;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ height: 100%;
+ text-align: center;
+}
+
+#scroller li {
+ display: block;
+ float: left;
+ width: 100px;
+ height: 100%;
+ border-right: 1px solid #ccc;
+ background-color: #fafafa;
+ font-size: 14px;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+<div id="header">iScroll</div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li>Cell 1</li>
+ <li>Cell 2</li>
+ <li>Cell 3</li>
+ <li>Cell 4</li>
+ <li>Cell 5</li>
+ <li>Cell 6</li>
+ <li>Cell 7</li>
+ <li>Cell 8</li>
+ <li>Cell 9</li>
+ <li>Cell 10</li>
+ <li>Cell 11</li>
+ <li>Cell 12</li>
+ <li>Cell 13</li>
+ <li>Cell 14</li>
+ <li>Cell 15</li>
+ <li>Cell 16</li>
+ <li>Cell 17</li>
+ <li>Cell 18</li>
+ <li>Cell 19</li>
+ <li>Cell 20</li>
+ <li>Cell 21</li>
+ <li>Cell 22</li>
+ <li>Cell 23</li>
+ <li>Cell 24</li>
+ <li>Cell 25</li>
+ <li>Cell 26</li>
+ <li>Cell 27</li>
+ <li>Cell 28</li>
+ <li>Cell 29</li>
+ <li>Cell 30</li>
+ <li>Cell 31</li>
+ <li>Cell 32</li>
+ <li>Cell 33</li>
+ <li>Cell 34</li>
+ <li>Cell 35</li>
+ <li>Cell 36</li>
+ <li>Cell 37</li>
+ <li>Cell 38</li>
+ <li>Cell 39</li>
+ <li>Cell 40</li>
+ <li>Cell 41</li>
+ <li>Cell 42</li>
+ <li>Cell 43</li>
+ <li>Cell 44</li>
+ <li>Cell 45</li>
+ <li>Cell 46</li>
+ <li>Cell 47</li>
+ <li>Cell 48</li>
+ <li>Cell 49</li>
+ <li>Cell 50</li>
+ </ul>
+ </div>
+</div>
+
+<div id="footer"></div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/infinite/dataset.php b/demos/infinite/dataset.php
new file mode 100644
index 0000000..16212d0
--- /dev/null
+++ b/demos/infinite/dataset.php
@@ -0,0 +1,14 @@
+<?php
+//header('Cache-Control: no-cache, must-revalidate');
+//header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
+header('Content-type: application/json');
+
+$start = isset($_GET['start']) ? (int)$_GET['start'] : 0;
+$count = isset($_GET['count']) ? min((int)$_GET['count'], 2000) : 100;
+
+$data = array();
+for ( $i = $start; $i < $start+$count; $i++ ) {
+ $data[] = $i;
+}
+
+echo json_encode($data);
diff --git a/demos/infinite/index.html b/demos/infinite/index.html
new file mode 100644
index 0000000..2acd5c5
--- /dev/null
+++ b/demos/infinite/index.html
@@ -0,0 +1,247 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: infinite scrolling</title>
+
+<script type="text/javascript" src="../../build/iscroll-infinite.js"></script>
+
+<script type="text/javascript">
+/******************************************************************************
+ *
+ * For the sake of keeping the script dependecy free I'm including a custom
+ * AJAX function. You should probably use a third party plugin
+ *
+ */
+function ajax (url, parms) {
+ parms = parms || {};
+ var req = new XMLHttpRequest(),
+ post = parms.post || null,
+ callback = parms.callback || null,
+ timeout = parms.timeout || null;
+
+ req.onreadystatechange = function () {
+ if ( req.readyState != 4 ) return;
+
+ // Error
+ if ( req.status != 200 && req.status != 304 ) {
+ if ( callback ) callback(false);
+ return;
+ }
+
+ if ( callback ) callback(req.responseText);
+ };
+
+ if ( post ) {
+ req.open('POST', url, true);
+ req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+ } else {
+ req.open('GET', url, true);
+ }
+
+ req.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
+
+ req.send(post);
+
+ if ( timeout ) {
+ setTimeout(function () {
+ req.onreadystatechange = function () {};
+ req.abort();
+ if ( callback ) callback(false);
+ }, timeout);
+ }
+}
+/*
+ *****************************************************************************/
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', {
+ mouseWheel: true,
+ infiniteElements: '#scroller .row',
+ //infiniteLimit: 2000,
+ dataset: requestData,
+ dataFiller: updateContent,
+ cacheSize: 1000
+ });
+}
+
+function requestData (start, count) {
+ ajax('dataset.php?start=' + +start + '&count=' + +count, {
+ callback: function (data) {
+ data = JSON.parse(data);
+ myScroll.updateCache(start, data);
+ }
+ });
+}
+
+function updateContent (el, data) {
+ el.innerHTML = data;
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#header {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#footer {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 48px;
+ background: #444;
+ padding: 0;
+ border-top: 1px solid #444;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 45px;
+ bottom: 48px;
+ left: 0;
+ width: 100%;
+ background: #ccc;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 100%;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ text-align: left;
+ position: relative;
+}
+
+#scroller li {
+ position: absolute;
+ width: 100%;
+ top: 0;
+ left: 0;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ padding: 0 10px;
+ height: 40px;
+ line-height: 40px;
+ border-bottom: 1px solid #ccc;
+ border-top: 1px solid #fff;
+ background-color: #fafafa;
+ font-size: 16px;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+<div id="header">iScroll</div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li class="row">Row 1</li>
+ <li class="row">Row 2</li>
+ <li class="row">Row 3</li>
+ <li class="row">Row 4</li>
+ <li class="row">Row 5</li>
+ <li class="row">Row 6</li>
+ <li class="row">Row 7</li>
+ <li class="row">Row 8</li>
+ <li class="row">Row 9</li>
+ <li class="row">Row 10</li>
+ <li class="row">Row 11</li>
+ <li class="row">Row 12</li>
+ <li class="row">Row 13</li>
+ <li class="row">Row 14</li>
+ <li class="row">Row 15</li>
+
+ <li class="row">Row 16</li>
+ <li class="row">Row 17</li>
+ <li class="row">Row 18</li>
+ <li class="row">Row 19</li>
+ <li class="row">Row 20</li>
+ <li class="row">Row 21</li>
+ <li class="row">Row 22</li>
+ <li class="row">Row 23</li>
+ <li class="row">Row 24</li>
+ <li class="row">Row 25</li>
+ <li class="row">Row 26</li>
+ <li class="row">Row 27</li>
+ <li class="row">Row 28</li>
+ <li class="row">Row 29</li>
+ <li class="row">Row 30</li>
+ </ul>
+ </div>
+</div>
+
+<div id="footer"></div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/key-bindings/index.html b/demos/key-bindings/index.html
new file mode 100644
index 0000000..06cad1d
--- /dev/null
+++ b/demos/key-bindings/index.html
@@ -0,0 +1,190 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: key bindings</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', { keyBindings: true });
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#header {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#footer {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 48px;
+ background: #444;
+ padding: 0;
+ border-top: 1px solid #444;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 45px;
+ bottom: 48px;
+ left: 0;
+ width: 100%;
+ background: #ccc;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 100%;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ text-align: left;
+}
+
+#scroller li {
+ padding: 0 10px;
+ height: 40px;
+ line-height: 40px;
+ border-bottom: 1px solid #ccc;
+ border-top: 1px solid #fff;
+ background-color: #fafafa;
+ font-size: 14px;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+<div id="header">iScroll</div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li>Pretty row 1</li>
+ <li>Pretty row 2</li>
+ <li>Pretty row 3</li>
+ <li>Pretty row 4</li>
+ <li>Pretty row 5</li>
+ <li>Pretty row 6</li>
+ <li>Pretty row 7</li>
+ <li>Pretty row 8</li>
+ <li>Pretty row 9</li>
+ <li>Pretty row 10</li>
+ <li>Pretty row 11</li>
+ <li>Pretty row 12</li>
+ <li>Pretty row 13</li>
+ <li>Pretty row 14</li>
+ <li>Pretty row 15</li>
+ <li>Pretty row 16</li>
+ <li>Pretty row 17</li>
+ <li>Pretty row 18</li>
+ <li>Pretty row 19</li>
+ <li>Pretty row 20</li>
+ <li>Pretty row 21</li>
+ <li>Pretty row 22</li>
+ <li>Pretty row 23</li>
+ <li>Pretty row 24</li>
+ <li>Pretty row 25</li>
+ <li>Pretty row 26</li>
+ <li>Pretty row 27</li>
+ <li>Pretty row 28</li>
+ <li>Pretty row 29</li>
+ <li>Pretty row 30</li>
+ <li>Pretty row 31</li>
+ <li>Pretty row 32</li>
+ <li>Pretty row 33</li>
+ <li>Pretty row 34</li>
+ <li>Pretty row 35</li>
+ <li>Pretty row 36</li>
+ <li>Pretty row 37</li>
+ <li>Pretty row 38</li>
+ <li>Pretty row 39</li>
+ <li>Pretty row 40</li>
+ <li>Pretty row 41</li>
+ <li>Pretty row 42</li>
+ <li>Pretty row 43</li>
+ <li>Pretty row 44</li>
+ <li>Pretty row 45</li>
+ <li>Pretty row 46</li>
+ <li>Pretty row 47</li>
+ <li>Pretty row 48</li>
+ <li>Pretty row 49</li>
+ <li>Pretty row 50</li>
+ </ul>
+ </div>
+</div>
+
+<div id="footer"></div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/minimap/ermine.jpg b/demos/minimap/ermine.jpg
new file mode 100644
index 0000000..3319189
Binary files /dev/null and b/demos/minimap/ermine.jpg differ
diff --git a/demos/minimap/index.html b/demos/minimap/index.html
new file mode 100644
index 0000000..f7a3145
--- /dev/null
+++ b/demos/minimap/index.html
@@ -0,0 +1,174 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: minimap</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', {
+ startX: -359,
+ startY: -85,
+ scrollY: true,
+ scrollX: true,
+ freeScroll: true,
+ mouseWheel: true,
+ indicators: {
+ el: document.getElementById('minimap'),
+ interactive: true
+ }
+ });
+}
+
+//document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#header {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#footer {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 48px;
+ background: #444;
+ padding: 0;
+ border-top: 1px solid #444;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ width: 235px;
+ height: 321px;
+ top: 0;
+ left: 0;
+ background: #555;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ width: 797px;
+ height: 1087px;
+ background: url(ermine.jpg);
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#minimap {
+ position: absolute;
+ z-index: 1;
+ width: 235px;
+ height: 321px;
+ background: url(ermine.jpg);
+ background-size: 235px 321px;
+ top: 0px;
+ left: 245px;
+}
+
+#minimap-indicator {
+ position: absolute;
+ z-index: 1;
+ border: 1px solid #fe0;
+ box-shadow: 0 0 5px #000;
+ background: rgba(255,255,255,0.15);
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+}
+
+#bookmarks {
+ position: absolute;
+ left: 520px;
+ font-size: 1.4em;
+}
+
+#bookmarks li {
+ margin: 5px 0;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+
+<div id="wrapper">
+ <div id="scroller"></div>
+</div>
+
+<div id="minimap">
+ <div id="minimap-indicator"></div>
+</div>
+
+<ul id="bookmarks">
+ <li><a href="javascript:myScroll.scrollTo(-359, -85, 400, IScroll.utils.ease.back)">Face</a></li>
+ <li><a href="javascript:myScroll.scrollTo(-288, -342, 400, IScroll.utils.ease.back)">Necklace</a></li>
+ <li><a href="javascript:myScroll.scrollTo(-264, -658, 400, IScroll.utils.ease.back)">Hand</a></li>
+ <li><a href="javascript:myScroll.scrollTo(-383, -539, 400, IScroll.utils.ease.back)">Ermine</a></li>
+</ul>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/no-transition/index.html b/demos/no-transition/index.html
new file mode 100644
index 0000000..68d08dc
--- /dev/null
+++ b/demos/no-transition/index.html
@@ -0,0 +1,190 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: No transition</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', { useTransition: false });
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#header {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#footer {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 48px;
+ background: #444;
+ padding: 0;
+ border-top: 1px solid #444;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 45px;
+ bottom: 48px;
+ left: 0;
+ width: 100%;
+ background: #ccc;
+ overflow: hidden;
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 100%;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+}
+
+#scroller ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ text-align: left;
+}
+
+#scroller li {
+ padding: 0 10px;
+ height: 40px;
+ line-height: 40px;
+ border-bottom: 1px solid #ccc;
+ border-top: 1px solid #fff;
+ background-color: #fafafa;
+ font-size: 14px;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+<div id="header">iScroll</div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li>Pretty row 1</li>
+ <li>Pretty row 2</li>
+ <li>Pretty row 3</li>
+ <li>Pretty row 4</li>
+ <li>Pretty row 5</li>
+ <li>Pretty row 6</li>
+ <li>Pretty row 7</li>
+ <li>Pretty row 8</li>
+ <li>Pretty row 9</li>
+ <li>Pretty row 10</li>
+ <li>Pretty row 11</li>
+ <li>Pretty row 12</li>
+ <li>Pretty row 13</li>
+ <li>Pretty row 14</li>
+ <li>Pretty row 15</li>
+ <li>Pretty row 16</li>
+ <li>Pretty row 17</li>
+ <li>Pretty row 18</li>
+ <li>Pretty row 19</li>
+ <li>Pretty row 20</li>
+ <li>Pretty row 21</li>
+ <li>Pretty row 22</li>
+ <li>Pretty row 23</li>
+ <li>Pretty row 24</li>
+ <li>Pretty row 25</li>
+ <li>Pretty row 26</li>
+ <li>Pretty row 27</li>
+ <li>Pretty row 28</li>
+ <li>Pretty row 29</li>
+ <li>Pretty row 30</li>
+ <li>Pretty row 31</li>
+ <li>Pretty row 32</li>
+ <li>Pretty row 33</li>
+ <li>Pretty row 34</li>
+ <li>Pretty row 35</li>
+ <li>Pretty row 36</li>
+ <li>Pretty row 37</li>
+ <li>Pretty row 38</li>
+ <li>Pretty row 39</li>
+ <li>Pretty row 40</li>
+ <li>Pretty row 41</li>
+ <li>Pretty row 42</li>
+ <li>Pretty row 43</li>
+ <li>Pretty row 44</li>
+ <li>Pretty row 45</li>
+ <li>Pretty row 46</li>
+ <li>Pretty row 47</li>
+ <li>Pretty row 48</li>
+ <li>Pretty row 49</li>
+ <li>Pretty row 50</li>
+ </ul>
+ </div>
+</div>
+
+<div id="footer"></div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/parallax/galaxies1.png b/demos/parallax/galaxies1.png
new file mode 100644
index 0000000..cbcd10c
Binary files /dev/null and b/demos/parallax/galaxies1.png differ
diff --git a/demos/parallax/galaxies2.png b/demos/parallax/galaxies2.png
new file mode 100644
index 0000000..171cf18
Binary files /dev/null and b/demos/parallax/galaxies2.png differ
diff --git a/demos/parallax/index.html b/demos/parallax/index.html
new file mode 100644
index 0000000..3713de8
--- /dev/null
+++ b/demos/parallax/index.html
@@ -0,0 +1,152 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: starfield</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', {
+ mouseWheel: true,
+ indicators: [{
+ el: document.getElementById('starfield1'),
+ resize: false,
+ ignoreBoundaries: true,
+ speedRatioY: 0.4
+ }, {
+ el: document.getElementById('starfield2'),
+ resize: false,
+ ignoreBoundaries: true,
+ speedRatioY: 0.2
+ }]
+ });
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+ background: #000;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 3;
+ width: 100%;
+ top: 0;
+ bottom: 0;
+ left: 0;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 3;
+ width: 100%;
+ height: 4000px;
+ overflow: hidden;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+ background: url(galaxies1.png);
+}
+
+.starfield {
+ position: absolute;
+ width: 100%;
+ top: 0;
+ left: 0;
+ bottom: 0;
+ overflow: hidden;
+}
+
+.starfield div {
+ position: absolute;
+ width: 100%;
+ overflow: hidden;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+}
+
+#starfield1 {
+ z-index: 2;
+}
+
+#stars1 {
+ z-index: 2;
+ height: 3000px;
+ background: url(galaxies2.png);
+}
+
+#starfield2 {
+ z-index: 1;
+}
+
+#stars2 {
+ z-index: 1;
+ height: 2000px;
+ background: url(stars.jpg);
+}
+
+</style>
+</head>
+<body onload="loaded()">
+
+<div id="wrapper">
+ <div id="scroller"></div>
+</div>
+
+<div class="starfield" id="starfield1">
+ <div id="stars1"></div>
+</div>
+
+<div class="starfield" id="starfield2">
+ <div id="stars2"></div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/parallax/stars.jpg b/demos/parallax/stars.jpg
new file mode 100644
index 0000000..91079b4
Binary files /dev/null and b/demos/parallax/stars.jpg differ
diff --git a/demos/probe/index.html b/demos/probe/index.html
new file mode 100644
index 0000000..38e9a4b
--- /dev/null
+++ b/demos/probe/index.html
@@ -0,0 +1,176 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: probe</title>
+
+<script type="text/javascript" src="../../build/iscroll-probe.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+var position;
+
+function updatePosition () {
+ position.innerHTML = this.y>>0;
+}
+
+function loaded () {
+ position = document.getElementById('position');
+
+ myScroll = new IScroll('#wrapper', { probeType: 3, mouseWheel: true });
+
+ myScroll.on('scroll', updatePosition);
+ myScroll.on('scrollEnd', updatePosition);
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 0;
+ bottom: 0;
+ left: 0;
+ width: 50%;
+ background: #ccc;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 100%;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ text-align: left;
+}
+
+#scroller li {
+ padding: 0 10px;
+ height: 40px;
+ line-height: 40px;
+ border-bottom: 1px solid #ccc;
+ border-top: 1px solid #fff;
+ background-color: #fafafa;
+ font-size: 14px;
+}
+
+#monitor {
+ position: absolute;
+ left: 51%;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+
+<div id="monitor">Y position: <strong id="position">0</strong></div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li>Pretty row 1</li>
+ <li>Pretty row 2</li>
+ <li>Pretty row 3</li>
+ <li>Pretty row 4</li>
+ <li>Pretty row 5</li>
+ <li>Pretty row 6</li>
+ <li>Pretty row 7</li>
+ <li>Pretty row 8</li>
+ <li>Pretty row 9</li>
+ <li>Pretty row 10</li>
+ <li>Pretty row 11</li>
+ <li>Pretty row 12</li>
+ <li>Pretty row 13</li>
+ <li>Pretty row 14</li>
+ <li>Pretty row 15</li>
+ <li>Pretty row 16</li>
+ <li>Pretty row 17</li>
+ <li>Pretty row 18</li>
+ <li>Pretty row 19</li>
+ <li>Pretty row 20</li>
+ <li>Pretty row 21</li>
+ <li>Pretty row 22</li>
+ <li>Pretty row 23</li>
+ <li>Pretty row 24</li>
+ <li>Pretty row 25</li>
+ <li>Pretty row 26</li>
+ <li>Pretty row 27</li>
+ <li>Pretty row 28</li>
+ <li>Pretty row 29</li>
+ <li>Pretty row 30</li>
+ <li>Pretty row 31</li>
+ <li>Pretty row 32</li>
+ <li>Pretty row 33</li>
+ <li>Pretty row 34</li>
+ <li>Pretty row 35</li>
+ <li>Pretty row 36</li>
+ <li>Pretty row 37</li>
+ <li>Pretty row 38</li>
+ <li>Pretty row 39</li>
+ <li>Pretty row 40</li>
+ <li>Pretty row 41</li>
+ <li>Pretty row 42</li>
+ <li>Pretty row 43</li>
+ <li>Pretty row 44</li>
+ <li>Pretty row 45</li>
+ <li>Pretty row 46</li>
+ <li>Pretty row 47</li>
+ <li>Pretty row 48</li>
+ <li>Pretty row 49</li>
+ <li>Pretty row 50</li>
+ </ul>
+ </div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/scroll-to-element/index.html b/demos/scroll-to-element/index.html
new file mode 100644
index 0000000..d69bbb2
--- /dev/null
+++ b/demos/scroll-to-element/index.html
@@ -0,0 +1,190 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: scroll to element</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', { mouseWheel: true, click: true });
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#header {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#footer {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 48px;
+ background: #444;
+ padding: 0;
+ border-top: 1px solid #444;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 45px;
+ bottom: 48px;
+ left: 0;
+ width: 100%;
+ background: #ccc;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 100%;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ text-align: left;
+}
+
+#scroller li {
+ padding: 0 10px;
+ height: 40px;
+ line-height: 40px;
+ border-bottom: 1px solid #ccc;
+ border-top: 1px solid #fff;
+ background-color: #fafafa;
+ font-size: 14px;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+<div id="header">iScroll</div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li><a href="javascript:myScroll.scrollToElement(document.querySelector('#scroller li:nth-child(10)'))">Scroll to element 10</a></li>
+ <li>Pretty row 2</li>
+ <li>Pretty row 3</li>
+ <li>Pretty row 4</li>
+ <li>Pretty row 5</li>
+ <li>Pretty row 6</li>
+ <li>Pretty row 7</li>
+ <li>Pretty row 8</li>
+ <li>Pretty row 9</li>
+ <li><a href="javascript:myScroll.scrollToElement(document.querySelector('#scroller li:nth-child(25)'), null, null, true)">Center element 25 to screen</a></li>
+ <li>Pretty row 11</li>
+ <li>Pretty row 12</li>
+ <li>Pretty row 13</li>
+ <li>Pretty row 14</li>
+ <li>Pretty row 15</li>
+ <li>Pretty row 16</li>
+ <li>Pretty row 17</li>
+ <li>Pretty row 18</li>
+ <li>Pretty row 19</li>
+ <li>Pretty row 20</li>
+ <li>Pretty row 21</li>
+ <li>Pretty row 22</li>
+ <li>Pretty row 23</li>
+ <li>Pretty row 24</li>
+ <li><a href="javascript:myScroll.scrollToElement(document.querySelector('#scroller li:nth-child(50)'), 1200, null, null, IScroll.utils.ease.elastic)">Scroll to the last element with elastic easing</a></li>
+ <li>Pretty row 26</li>
+ <li>Pretty row 27</li>
+ <li>Pretty row 28</li>
+ <li>Pretty row 29</li>
+ <li>Pretty row 30</li>
+ <li>Pretty row 31</li>
+ <li>Pretty row 32</li>
+ <li>Pretty row 33</li>
+ <li>Pretty row 34</li>
+ <li>Pretty row 35</li>
+ <li>Pretty row 36</li>
+ <li>Pretty row 37</li>
+ <li>Pretty row 38</li>
+ <li>Pretty row 39</li>
+ <li>Pretty row 40</li>
+ <li>Pretty row 41</li>
+ <li>Pretty row 42</li>
+ <li>Pretty row 43</li>
+ <li>Pretty row 44</li>
+ <li>Pretty row 45</li>
+ <li>Pretty row 46</li>
+ <li>Pretty row 47</li>
+ <li>Pretty row 48</li>
+ <li>Pretty row 49</li>
+ <li>Pretty row 50</li>
+ </ul>
+ </div>
+</div>
+
+<div id="footer"></div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/scrollbars/index.html b/demos/scrollbars/index.html
new file mode 100644
index 0000000..f31ca21
--- /dev/null
+++ b/demos/scrollbars/index.html
@@ -0,0 +1,196 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: scrollbars</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', {
+ scrollbars: true,
+ mouseWheel: true,
+ interactiveScrollbars: true,
+ shrinkScrollbars: 'scale',
+ fadeScrollbars: true
+ });
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#header {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#footer {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 48px;
+ background: #444;
+ padding: 0;
+ border-top: 1px solid #444;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 45px;
+ bottom: 48px;
+ left: 0;
+ width: 100%;
+ background: #ccc;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 100%;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ text-align: left;
+}
+
+#scroller li {
+ padding: 0 10px;
+ height: 40px;
+ line-height: 40px;
+ border-bottom: 1px solid #ccc;
+ border-top: 1px solid #fff;
+ background-color: #fafafa;
+ font-size: 14px;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+<div id="header">iScroll</div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li>Pretty row 1</li>
+ <li>Pretty row 2</li>
+ <li>Pretty row 3</li>
+ <li>Pretty row 4</li>
+ <li>Pretty row 5</li>
+ <li>Pretty row 6</li>
+ <li>Pretty row 7</li>
+ <li>Pretty row 8</li>
+ <li>Pretty row 9</li>
+ <li>Pretty row 10</li>
+ <li>Pretty row 11</li>
+ <li>Pretty row 12</li>
+ <li>Pretty row 13</li>
+ <li>Pretty row 14</li>
+ <li>Pretty row 15</li>
+ <li>Pretty row 16</li>
+ <li>Pretty row 17</li>
+ <li>Pretty row 18</li>
+ <li>Pretty row 19</li>
+ <li>Pretty row 20</li>
+ <li>Pretty row 21</li>
+ <li>Pretty row 22</li>
+ <li>Pretty row 23</li>
+ <li>Pretty row 24</li>
+ <li>Pretty row 25</li>
+ <li>Pretty row 26</li>
+ <li>Pretty row 27</li>
+ <li>Pretty row 28</li>
+ <li>Pretty row 29</li>
+ <li>Pretty row 30</li>
+ <li>Pretty row 31</li>
+ <li>Pretty row 32</li>
+ <li>Pretty row 33</li>
+ <li>Pretty row 34</li>
+ <li>Pretty row 35</li>
+ <li>Pretty row 36</li>
+ <li>Pretty row 37</li>
+ <li>Pretty row 38</li>
+ <li>Pretty row 39</li>
+ <li>Pretty row 40</li>
+ <li>Pretty row 41</li>
+ <li>Pretty row 42</li>
+ <li>Pretty row 43</li>
+ <li>Pretty row 44</li>
+ <li>Pretty row 45</li>
+ <li>Pretty row 46</li>
+ <li>Pretty row 47</li>
+ <li>Pretty row 48</li>
+ <li>Pretty row 49</li>
+ <li>Pretty row 50</li>
+ </ul>
+ </div>
+</div>
+
+<div id="footer"></div>
+
+</body>
+</html>
diff --git a/demos/simple/index.html b/demos/simple/index.html
new file mode 100644
index 0000000..be88d88
--- /dev/null
+++ b/demos/simple/index.html
@@ -0,0 +1,190 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: simple</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', { mouseWheel: true });
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#header {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#footer {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 48px;
+ background: #444;
+ padding: 0;
+ border-top: 1px solid #444;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 45px;
+ bottom: 48px;
+ left: 0;
+ width: 100%;
+ background: #ccc;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 100%;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ text-align: left;
+}
+
+#scroller li {
+ padding: 0 10px;
+ height: 40px;
+ line-height: 40px;
+ border-bottom: 1px solid #ccc;
+ border-top: 1px solid #fff;
+ background-color: #fafafa;
+ font-size: 14px;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+<div id="header">iScroll</div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li>Pretty row 1</li>
+ <li>Pretty row 2</li>
+ <li>Pretty row 3</li>
+ <li>Pretty row 4</li>
+ <li>Pretty row 5</li>
+ <li>Pretty row 6</li>
+ <li>Pretty row 7</li>
+ <li>Pretty row 8</li>
+ <li>Pretty row 9</li>
+ <li>Pretty row 10</li>
+ <li>Pretty row 11</li>
+ <li>Pretty row 12</li>
+ <li>Pretty row 13</li>
+ <li>Pretty row 14</li>
+ <li>Pretty row 15</li>
+ <li>Pretty row 16</li>
+ <li>Pretty row 17</li>
+ <li>Pretty row 18</li>
+ <li>Pretty row 19</li>
+ <li>Pretty row 20</li>
+ <li>Pretty row 21</li>
+ <li>Pretty row 22</li>
+ <li>Pretty row 23</li>
+ <li>Pretty row 24</li>
+ <li>Pretty row 25</li>
+ <li>Pretty row 26</li>
+ <li>Pretty row 27</li>
+ <li>Pretty row 28</li>
+ <li>Pretty row 29</li>
+ <li>Pretty row 30</li>
+ <li>Pretty row 31</li>
+ <li>Pretty row 32</li>
+ <li>Pretty row 33</li>
+ <li>Pretty row 34</li>
+ <li>Pretty row 35</li>
+ <li>Pretty row 36</li>
+ <li>Pretty row 37</li>
+ <li>Pretty row 38</li>
+ <li>Pretty row 39</li>
+ <li>Pretty row 40</li>
+ <li>Pretty row 41</li>
+ <li>Pretty row 42</li>
+ <li>Pretty row 43</li>
+ <li>Pretty row 44</li>
+ <li>Pretty row 45</li>
+ <li>Pretty row 46</li>
+ <li>Pretty row 47</li>
+ <li>Pretty row 48</li>
+ <li>Pretty row 49</li>
+ <li>Pretty row 50</li>
+ </ul>
+ </div>
+</div>
+
+<div id="footer"></div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/snap/index.html b/demos/snap/index.html
new file mode 100644
index 0000000..5d9ba21
--- /dev/null
+++ b/demos/snap/index.html
@@ -0,0 +1,256 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: snap</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', {
+ scrollX: true,
+ scrollY: true,
+ momentum: false,
+ snap: true
+ });
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#header {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#footer {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 48px;
+ background: #444;
+ padding: 0;
+ border-top: 1px solid #444;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 45px;
+ bottom: 48px;
+ left: 0;
+ width: 100%;
+ background: #ccc;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 2000px;
+ height: 2000px;
+ background-color: #a00;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ text-align: center;
+}
+
+#scroller li {
+ display: block;
+ float: left;
+ width: 200px;
+ height: 200px;
+ border-right: 1px solid #ccc;
+ border-bottom: 1px solid #ccc;
+ background-color: #fafafa;
+ font-size: 14px;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+<div id="header">iScroll</div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ <li>Cell</li>
+ </ul>
+ </div>
+</div>
+
+<div id="footer"></div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/styled-scrollbars/index.html b/demos/styled-scrollbars/index.html
new file mode 100644
index 0000000..61690aa
--- /dev/null
+++ b/demos/styled-scrollbars/index.html
@@ -0,0 +1,251 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: styled scrollbars</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', { scrollX: true, scrollbars: 'custom' });
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+
+/* Styled scrollbars */
+
+.iScrollHorizontalScrollbar {
+ position: absolute;
+ z-index: 9999;
+ height: 16px;
+ left: 2px;
+ right: 2px;
+ bottom: 2px;
+ overflow: hidden;
+}
+
+.iScrollHorizontalScrollbar.iScrollBothScrollbars {
+ right: 18px;
+}
+
+.iScrollVerticalScrollbar {
+ position: absolute;
+ z-index: 9999;
+ width: 16px;
+ bottom: 2px;
+ top: 2px;
+ right: 2px;
+ overflow: hidden;
+}
+
+.iScrollVerticalScrollbar.iScrollBothScrollbars {
+ bottom: 18px;
+}
+
+.iScrollIndicator {
+ position: absolute;
+ background: #cc3f6e;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #EB97B4 #7C2845 #7C2845 #EB97B4;
+ border-radius: 8px;
+}
+
+.iScrollHorizontalScrollbar .iScrollIndicator {
+ height: 100%;
+ background: -moz-linear-gradient(left, #cc3f6e 0%, #93004e 100%);
+ background: -webkit-linear-gradient(left, #cc3f6e 0%,#93004e 100%);
+ background: -o-linear-gradient(left, #cc3f6e 0%,#93004e 100%);
+ background: -ms-linear-gradient(left, #cc3f6e 0%,#93004e 100%);
+ background: linear-gradient(to right, #cc3f6e 0%,#93004e 100%);
+}
+
+.iScrollVerticalScrollbar .iScrollIndicator {
+ width: 100%;
+ background: -moz-linear-gradient(top, #cc3f6e 0%, #93004e 100%);
+ background: -webkit-linear-gradient(top, #cc3f6e 0%,#93004e 100%);
+ background: -o-linear-gradient(top, #cc3f6e 0%,#93004e 100%);
+ background: -ms-linear-gradient(top, #cc3f6e 0%,#93004e 100%);
+ background: linear-gradient(to bottom, #cc3f6e 0%,#93004e 100%);
+}
+
+
+/* end */
+
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#header {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#footer {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 48px;
+ background: #444;
+ padding: 0;
+ border-top: 1px solid #444;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 45px;
+ bottom: 48px;
+ left: 0;
+ width: 100%;
+ background: #ccc;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 2000px;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ text-align: left;
+}
+
+#scroller li {
+ padding: 0 10px;
+ height: 40px;
+ line-height: 40px;
+ border-bottom: 1px solid #ccc;
+ border-top: 1px solid #fff;
+ background-color: #fafafa;
+ font-size: 14px;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+<div id="header">iScroll</div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li>Pretty row 1</li>
+ <li>Pretty row 2</li>
+ <li>Pretty row 3</li>
+ <li>Pretty row 4</li>
+ <li>Pretty row 5</li>
+ <li>Pretty row 6</li>
+ <li>Pretty row 7</li>
+ <li>Pretty row 8</li>
+ <li>Pretty row 9</li>
+ <li>Pretty row 10</li>
+ <li>Pretty row 11</li>
+ <li>Pretty row 12</li>
+ <li>Pretty row 13</li>
+ <li>Pretty row 14</li>
+ <li>Pretty row 15</li>
+ <li>Pretty row 16</li>
+ <li>Pretty row 17</li>
+ <li>Pretty row 18</li>
+ <li>Pretty row 19</li>
+ <li>Pretty row 20</li>
+ <li>Pretty row 21</li>
+ <li>Pretty row 22</li>
+ <li>Pretty row 23</li>
+ <li>Pretty row 24</li>
+ <li>Pretty row 25</li>
+ <li>Pretty row 26</li>
+ <li>Pretty row 27</li>
+ <li>Pretty row 28</li>
+ <li>Pretty row 29</li>
+ <li>Pretty row 30</li>
+ <li>Pretty row 31</li>
+ <li>Pretty row 32</li>
+ <li>Pretty row 33</li>
+ <li>Pretty row 34</li>
+ <li>Pretty row 35</li>
+ <li>Pretty row 36</li>
+ <li>Pretty row 37</li>
+ <li>Pretty row 38</li>
+ <li>Pretty row 39</li>
+ <li>Pretty row 40</li>
+ <li>Pretty row 41</li>
+ <li>Pretty row 42</li>
+ <li>Pretty row 43</li>
+ <li>Pretty row 44</li>
+ <li>Pretty row 45</li>
+ <li>Pretty row 46</li>
+ <li>Pretty row 47</li>
+ <li>Pretty row 48</li>
+ <li>Pretty row 49</li>
+ <li>Pretty row 50</li>
+ </ul>
+ </div>
+</div>
+
+<div id="footer"></div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/tap/index.html b/demos/tap/index.html
new file mode 100644
index 0000000..6cb649c
--- /dev/null
+++ b/demos/tap/index.html
@@ -0,0 +1,194 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: simple</title>
+
+<script type="text/javascript" src="../../build/iscroll.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', { mouseWheel: true, tap: true });
+
+ document.getElementById('me').addEventListener('tap', function () {
+ this.style.background = !this.style.background ? '#a00' : '';
+ }, false);
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#header {
+ position: absolute;
+ z-index: 2;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 45px;
+ line-height: 45px;
+ background: #CD235C;
+ padding: 0;
+ color: #eee;
+ font-size: 20px;
+ text-align: center;
+ font-weight: bold;
+}
+
+#footer {
+ position: absolute;
+ z-index: 2;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 48px;
+ background: #444;
+ padding: 0;
+ border-top: 1px solid #444;
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 45px;
+ bottom: 48px;
+ left: 0;
+ width: 100%;
+ background: #ccc;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 100%;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ text-align: left;
+}
+
+#scroller li {
+ padding: 0 10px;
+ height: 40px;
+ line-height: 40px;
+ border-bottom: 1px solid #ccc;
+ border-top: 1px solid #fff;
+ background-color: #fafafa;
+ font-size: 14px;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+<div id="header">iScroll</div>
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li>Pretty row 1</li>
+ <li>Pretty row 2</li>
+ <li>Pretty row 3</li>
+ <li>Pretty row 4</li>
+ <li>Pretty row 5</li>
+ <li id="me"><strong>Tap me! Tap me! Tap me! Tap me!</strong></li>
+ <li>Pretty row 7</li>
+ <li>Pretty row 8</li>
+ <li>Pretty row 9</li>
+ <li>Pretty row 10</li>
+ <li>Pretty row 11</li>
+ <li>Pretty row 12</li>
+ <li>Pretty row 13</li>
+ <li>Pretty row 14</li>
+ <li>Pretty row 15</li>
+ <li>Pretty row 16</li>
+ <li>Pretty row 17</li>
+ <li>Pretty row 18</li>
+ <li>Pretty row 19</li>
+ <li>Pretty row 20</li>
+ <li>Pretty row 21</li>
+ <li>Pretty row 22</li>
+ <li>Pretty row 23</li>
+ <li>Pretty row 24</li>
+ <li>Pretty row 25</li>
+ <li>Pretty row 26</li>
+ <li>Pretty row 27</li>
+ <li>Pretty row 28</li>
+ <li>Pretty row 29</li>
+ <li>Pretty row 30</li>
+ <li>Pretty row 31</li>
+ <li>Pretty row 32</li>
+ <li>Pretty row 33</li>
+ <li>Pretty row 34</li>
+ <li>Pretty row 35</li>
+ <li>Pretty row 36</li>
+ <li>Pretty row 37</li>
+ <li>Pretty row 38</li>
+ <li>Pretty row 39</li>
+ <li>Pretty row 40</li>
+ <li>Pretty row 41</li>
+ <li>Pretty row 42</li>
+ <li>Pretty row 43</li>
+ <li>Pretty row 44</li>
+ <li>Pretty row 45</li>
+ <li>Pretty row 46</li>
+ <li>Pretty row 47</li>
+ <li>Pretty row 48</li>
+ <li>Pretty row 49</li>
+ <li>Pretty row 50</li>
+ </ul>
+ </div>
+</div>
+
+<div id="footer"></div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/demos/zoom/index.html b/demos/zoom/index.html
new file mode 100644
index 0000000..1359247
--- /dev/null
+++ b/demos/zoom/index.html
@@ -0,0 +1,165 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
+
+<title>iScroll demo: zoom</title>
+
+<script type="text/javascript" src="../../build/iscroll-zoom.js"></script>
+
+<script type="text/javascript">
+
+var myScroll;
+
+function loaded () {
+ myScroll = new IScroll('#wrapper', {
+ zoom: true,
+ scrollX: true,
+ scrollY: true,
+ mouseWheel: true,
+ wheelAction: 'zoom'
+ });
+}
+
+document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
+
+</script>
+
+<style type="text/css">
+* {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+html {
+ -ms-touch-action: none;
+}
+
+body,ul,li {
+ padding: 0;
+ margin: 0;
+ border: 0;
+}
+
+body {
+ font-size: 12px;
+ font-family: ubuntu, helvetica, arial;
+ overflow: hidden; /* this is important to prevent the whole page to bounce */
+}
+
+#wrapper {
+ position: absolute;
+ z-index: 1;
+ top: 50px;
+ bottom: 50px;
+ left: 50px;
+ right: 50px;
+ background: #ccc;
+ overflow: hidden;
+}
+
+#scroller {
+ position: absolute;
+ z-index: 1;
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+ width: 100%;
+ -webkit-transform: translateZ(0);
+ -moz-transform: translateZ(0);
+ -ms-transform: translateZ(0);
+ -o-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+ -webkit-text-size-adjust: none;
+ -moz-text-size-adjust: none;
+ -ms-text-size-adjust: none;
+ -o-text-size-adjust: none;
+ text-size-adjust: none;
+}
+
+#scroller ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ width: 100%;
+ text-align: left;
+}
+
+#scroller li {
+ padding: 0 10px;
+ height: 40px;
+ line-height: 40px;
+ border-bottom: 1px solid #ccc;
+ border-top: 1px solid #fff;
+ background-color: #fafafa;
+ font-size: 14px;
+}
+
+</style>
+</head>
+<body onload="loaded()">
+
+<div id="wrapper">
+ <div id="scroller">
+ <ul>
+ <li>Pretty row 1</li>
+ <li>Pretty row 2</li>
+ <li>Pretty row 3</li>
+ <li>Pretty row 4</li>
+ <li>Pretty row 5</li>
+ <li>Pretty row 6</li>
+ <li>Pretty row 7</li>
+ <li>Pretty row 8</li>
+ <li>Pretty row 9</li>
+ <li>Pretty row 10</li>
+ <li>Pretty row 11</li>
+ <li>Pretty row 12</li>
+ <li>Pretty row 13</li>
+ <li>Pretty row 14</li>
+ <li>Pretty row 15</li>
+ <li>Pretty row 16</li>
+ <li>Pretty row 17</li>
+ <li>Pretty row 18</li>
+ <li>Pretty row 19</li>
+ <li>Pretty row 20</li>
+ <li>Pretty row 21</li>
+ <li>Pretty row 22</li>
+ <li>Pretty row 23</li>
+ <li>Pretty row 24</li>
+ <li>Pretty row 25</li>
+ <li>Pretty row 26</li>
+ <li>Pretty row 27</li>
+ <li>Pretty row 28</li>
+ <li>Pretty row 29</li>
+ <li>Pretty row 30</li>
+ <li>Pretty row 31</li>
+ <li>Pretty row 32</li>
+ <li>Pretty row 33</li>
+ <li>Pretty row 34</li>
+ <li>Pretty row 35</li>
+ <li>Pretty row 36</li>
+ <li>Pretty row 37</li>
+ <li>Pretty row 38</li>
+ <li>Pretty row 39</li>
+ <li>Pretty row 40</li>
+ <li>Pretty row 41</li>
+ <li>Pretty row 42</li>
+ <li>Pretty row 43</li>
+ <li>Pretty row 44</li>
+ <li>Pretty row 45</li>
+ <li>Pretty row 46</li>
+ <li>Pretty row 47</li>
+ <li>Pretty row 48</li>
+ <li>Pretty row 49</li>
+ <li>Pretty row 50</li>
+ </ul>
+ </div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..32d26a3
--- /dev/null
+++ b/package.json
@@ -0,0 +1,29 @@
+{
+ "name": "iscroll",
+ "description": "Smooth scrolling for the web",
+ "version": "5.1.1",
+ "homepage": "http://cubiq.org/iscroll-4",
+ "author": "Matteo Spinelli <matteo at cubiq.org> (http://cubiq.org)",
+ "keywords": [
+ "scrolling",
+ "carousel",
+ "zoom",
+ "iphone",
+ "android",
+ "mobile",
+ "desktop"
+ ],
+ "main": "build/iscroll.js",
+ "devDependencies": {
+ "jshint": "~2.3.0",
+ "uglify-js": "~2.4.7"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/cubiq/iscroll.git"
+ },
+ "bugs": {
+ "url": "https://github.com/cubiq/iscroll/issues"
+ },
+ "license": "MIT"
+}
\ No newline at end of file
diff --git a/src/close.js b/src/close.js
new file mode 100644
index 0000000..1523cf2
--- /dev/null
+++ b/src/close.js
@@ -0,0 +1,10 @@
+
+IScroll.utils = utils;
+
+if ( typeof module != 'undefined' && module.exports ) {
+ module.exports = IScroll;
+} else {
+ window.IScroll = IScroll;
+}
+
+})(window, document, Math);
\ No newline at end of file
diff --git a/src/core.js b/src/core.js
new file mode 100644
index 0000000..9068af0
--- /dev/null
+++ b/src/core.js
@@ -0,0 +1,600 @@
+
+function IScroll (el, options) {
+ this.wrapper = typeof el == 'string' ? document.querySelector(el) : el;
+ this.scroller = this.wrapper.children[0];
+ this.scrollerStyle = this.scroller.style; // cache style for better performance
+
+ this.options = {
+
+// INSERT POINT: OPTIONS
+
+ startX: 0,
+ startY: 0,
+ scrollY: true,
+ directionLockThreshold: 5,
+ momentum: true,
+
+ bounce: true,
+ bounceTime: 600,
+ bounceEasing: '',
+
+ preventDefault: true,
+ preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ },
+
+ HWCompositing: true,
+ useTransition: true,
+ useTransform: true
+ };
+
+ for ( var i in options ) {
+ this.options[i] = options[i];
+ }
+
+ // Normalize options
+ this.translateZ = this.options.HWCompositing && utils.hasPerspective ? ' translateZ(0)' : '';
+
+ this.options.useTransition = utils.hasTransition && this.options.useTransition;
+ this.options.useTransform = utils.hasTransform && this.options.useTransform;
+
+ this.options.eventPassthrough = this.options.eventPassthrough === true ? 'vertical' : this.options.eventPassthrough;
+ this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault;
+
+ // If you want eventPassthrough I have to lock one of the axes
+ this.options.scrollY = this.options.eventPassthrough == 'vertical' ? false : this.options.scrollY;
+ this.options.scrollX = this.options.eventPassthrough == 'horizontal' ? false : this.options.scrollX;
+
+ // With eventPassthrough we also need lockDirection mechanism
+ this.options.freeScroll = this.options.freeScroll && !this.options.eventPassthrough;
+ this.options.directionLockThreshold = this.options.eventPassthrough ? 0 : this.options.directionLockThreshold;
+
+ this.options.bounceEasing = typeof this.options.bounceEasing == 'string' ? utils.ease[this.options.bounceEasing] || utils.ease.circular : this.options.bounceEasing;
+
+ this.options.resizePolling = this.options.resizePolling === undefined ? 60 : this.options.resizePolling;
+
+ if ( this.options.tap === true ) {
+ this.options.tap = 'tap';
+ }
+
+// INSERT POINT: NORMALIZATION
+
+ // Some defaults
+ this.x = 0;
+ this.y = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+ this._events = {};
+
+// INSERT POINT: DEFAULTS
+
+ this._init();
+ this.refresh();
+
+ this.scrollTo(this.options.startX, this.options.startY);
+ this.enable();
+}
+
+IScroll.prototype = {
+ version: '/* VERSION */',
+
+ _init: function () {
+ this._initEvents();
+
+// INSERT POINT: _init
+
+ },
+
+ destroy: function () {
+ this._initEvents(true);
+
+ this._execEvent('destroy');
+ },
+
+ _transitionEnd: function (e) {
+ if ( e.target != this.scroller || !this.isInTransition ) {
+ return;
+ }
+
+ this._transitionTime();
+ if ( !this.resetPosition(this.options.bounceTime) ) {
+ this.isInTransition = false;
+ this._execEvent('scrollEnd');
+ }
+ },
+
+ _start: function (e) {
+ // React to left mouse button only
+ if ( utils.eventType[e.type] != 1 ) {
+ if ( e.button !== 0 ) {
+ return;
+ }
+ }
+
+ if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) {
+ return;
+ }
+
+ if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
+ e.preventDefault();
+ }
+
+ var point = e.touches ? e.touches[0] : e,
+ pos;
+
+ this.initiated = utils.eventType[e.type];
+ this.moved = false;
+ this.distX = 0;
+ this.distY = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+ this.directionLocked = 0;
+
+ this._transitionTime();
+
+ this.startTime = utils.getTime();
+
+ if ( this.options.useTransition && this.isInTransition ) {
+ this.isInTransition = false;
+ pos = this.getComputedPosition();
+ this._translate(Math.round(pos.x), Math.round(pos.y));
+ this._execEvent('scrollEnd');
+ } else if ( !this.options.useTransition && this.isAnimating ) {
+ this.isAnimating = false;
+ this._execEvent('scrollEnd');
+ }
+
+ this.startX = this.x;
+ this.startY = this.y;
+ this.absStartX = this.x;
+ this.absStartY = this.y;
+ this.pointX = point.pageX;
+ this.pointY = point.pageY;
+
+ this._execEvent('beforeScrollStart');
+ },
+
+ _move: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault ) { // increases performance on Android? TODO: check!
+ e.preventDefault();
+ }
+
+ var point = e.touches ? e.touches[0] : e,
+ deltaX = point.pageX - this.pointX,
+ deltaY = point.pageY - this.pointY,
+ timestamp = utils.getTime(),
+ newX, newY,
+ absDistX, absDistY;
+
+ this.pointX = point.pageX;
+ this.pointY = point.pageY;
+
+ this.distX += deltaX;
+ this.distY += deltaY;
+ absDistX = Math.abs(this.distX);
+ absDistY = Math.abs(this.distY);
+
+ // We need to move at least 10 pixels for the scrolling to initiate
+ if ( timestamp - this.endTime > 300 && (absDistX < 10 && absDistY < 10) ) {
+ return;
+ }
+
+ // If you are scrolling in one direction lock the other
+ if ( !this.directionLocked && !this.options.freeScroll ) {
+ if ( absDistX > absDistY + this.options.directionLockThreshold ) {
+ this.directionLocked = 'h'; // lock horizontally
+ } else if ( absDistY >= absDistX + this.options.directionLockThreshold ) {
+ this.directionLocked = 'v'; // lock vertically
+ } else {
+ this.directionLocked = 'n'; // no lock
+ }
+ }
+
+ if ( this.directionLocked == 'h' ) {
+ if ( this.options.eventPassthrough == 'vertical' ) {
+ e.preventDefault();
+ } else if ( this.options.eventPassthrough == 'horizontal' ) {
+ this.initiated = false;
+ return;
+ }
+
+ deltaY = 0;
+ } else if ( this.directionLocked == 'v' ) {
+ if ( this.options.eventPassthrough == 'horizontal' ) {
+ e.preventDefault();
+ } else if ( this.options.eventPassthrough == 'vertical' ) {
+ this.initiated = false;
+ return;
+ }
+
+ deltaX = 0;
+ }
+
+ deltaX = this.hasHorizontalScroll ? deltaX : 0;
+ deltaY = this.hasVerticalScroll ? deltaY : 0;
+
+ newX = this.x + deltaX;
+ newY = this.y + deltaY;
+
+ // Slow down if outside of the boundaries
+ if ( newX > 0 || newX < this.maxScrollX ) {
+ newX = this.options.bounce ? this.x + deltaX / 3 : newX > 0 ? 0 : this.maxScrollX;
+ }
+ if ( newY > 0 || newY < this.maxScrollY ) {
+ newY = this.options.bounce ? this.y + deltaY / 3 : newY > 0 ? 0 : this.maxScrollY;
+ }
+
+ this.directionX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
+ this.directionY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
+
+ if ( !this.moved ) {
+ this._execEvent('scrollStart');
+ }
+
+ this.moved = true;
+
+ this._translate(newX, newY);
+
+/* REPLACE START: _move */
+
+ if ( timestamp - this.startTime > 300 ) {
+ this.startTime = timestamp;
+ this.startX = this.x;
+ this.startY = this.y;
+ }
+
+/* REPLACE END: _move */
+
+ },
+
+ _end: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
+ e.preventDefault();
+ }
+
+ var point = e.changedTouches ? e.changedTouches[0] : e,
+ momentumX,
+ momentumY,
+ duration = utils.getTime() - this.startTime,
+ newX = Math.round(this.x),
+ newY = Math.round(this.y),
+ distanceX = Math.abs(newX - this.startX),
+ distanceY = Math.abs(newY - this.startY),
+ time = 0,
+ easing = '';
+
+ this.isInTransition = 0;
+ this.initiated = 0;
+ this.endTime = utils.getTime();
+
+ // reset if we are outside of the boundaries
+ if ( this.resetPosition(this.options.bounceTime) ) {
+ return;
+ }
+
+ this.scrollTo(newX, newY); // ensures that the last position is rounded
+
+ // we scrolled less than 10 pixels
+ if ( !this.moved ) {
+ if ( this.options.tap ) {
+ utils.tap(e, this.options.tap);
+ }
+
+ if ( this.options.click ) {
+ utils.click(e);
+ }
+
+ this._execEvent('scrollCancel');
+ return;
+ }
+
+ if ( this._events.flick && duration < 200 && distanceX < 100 && distanceY < 100 ) {
+ this._execEvent('flick');
+ return;
+ }
+
+ // start momentum animation if needed
+ if ( this.options.momentum && duration < 300 ) {
+ momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 };
+ momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 };
+ newX = momentumX.destination;
+ newY = momentumY.destination;
+ time = Math.max(momentumX.duration, momentumY.duration);
+ this.isInTransition = 1;
+ }
+
+// INSERT POINT: _end
+
+ if ( newX != this.x || newY != this.y ) {
+ // change easing function when scroller goes out of the boundaries
+ if ( newX > 0 || newX < this.maxScrollX || newY > 0 || newY < this.maxScrollY ) {
+ easing = utils.ease.quadratic;
+ }
+
+ this.scrollTo(newX, newY, time, easing);
+ return;
+ }
+
+ this._execEvent('scrollEnd');
+ },
+
+ _resize: function () {
+ var that = this;
+
+ clearTimeout(this.resizeTimeout);
+
+ this.resizeTimeout = setTimeout(function () {
+ that.refresh();
+ }, this.options.resizePolling);
+ },
+
+ resetPosition: function (time) {
+ var x = this.x,
+ y = this.y;
+
+ time = time || 0;
+
+ if ( !this.hasHorizontalScroll || this.x > 0 ) {
+ x = 0;
+ } else if ( this.x < this.maxScrollX ) {
+ x = this.maxScrollX;
+ }
+
+ if ( !this.hasVerticalScroll || this.y > 0 ) {
+ y = 0;
+ } else if ( this.y < this.maxScrollY ) {
+ y = this.maxScrollY;
+ }
+
+ if ( x == this.x && y == this.y ) {
+ return false;
+ }
+
+ this.scrollTo(x, y, time, this.options.bounceEasing);
+
+ return true;
+ },
+
+ disable: function () {
+ this.enabled = false;
+ },
+
+ enable: function () {
+ this.enabled = true;
+ },
+
+ refresh: function () {
+ var rf = this.wrapper.offsetHeight; // Force reflow
+
+ this.wrapperWidth = this.wrapper.clientWidth;
+ this.wrapperHeight = this.wrapper.clientHeight;
+
+/* REPLACE START: refresh */
+
+ this.scrollerWidth = this.scroller.offsetWidth;
+ this.scrollerHeight = this.scroller.offsetHeight;
+
+ this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
+ this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
+
+/* REPLACE END: refresh */
+
+ this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
+ this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
+
+ if ( !this.hasHorizontalScroll ) {
+ this.maxScrollX = 0;
+ this.scrollerWidth = this.wrapperWidth;
+ }
+
+ if ( !this.hasVerticalScroll ) {
+ this.maxScrollY = 0;
+ this.scrollerHeight = this.wrapperHeight;
+ }
+
+ this.endTime = 0;
+ this.directionX = 0;
+ this.directionY = 0;
+
+ this.wrapperOffset = utils.offset(this.wrapper);
+
+ this._execEvent('refresh');
+
+ this.resetPosition();
+
+// INSERT POINT: _refresh
+
+ },
+
+ on: function (type, fn) {
+ if ( !this._events[type] ) {
+ this._events[type] = [];
+ }
+
+ this._events[type].push(fn);
+ },
+
+ off: function (type, fn) {
+ if ( !this._events[type] ) {
+ return;
+ }
+
+ var index = this._events[type].indexOf(fn);
+
+ if ( index > -1 ) {
+ this._events[type].splice(index, 1);
+ }
+ },
+
+ _execEvent: function (type) {
+ if ( !this._events[type] ) {
+ return;
+ }
+
+ var i = 0,
+ l = this._events[type].length;
+
+ if ( !l ) {
+ return;
+ }
+
+ for ( ; i < l; i++ ) {
+ this._events[type][i].apply(this, [].slice.call(arguments, 1));
+ }
+ },
+
+ scrollBy: function (x, y, time, easing) {
+ x = this.x + x;
+ y = this.y + y;
+ time = time || 0;
+
+ this.scrollTo(x, y, time, easing);
+ },
+
+ scrollTo: function (x, y, time, easing) {
+ easing = easing || utils.ease.circular;
+
+ this.isInTransition = this.options.useTransition && time > 0;
+
+ if ( !time || (this.options.useTransition && easing.style) ) {
+ this._transitionTimingFunction(easing.style);
+ this._transitionTime(time);
+ this._translate(x, y);
+ } else {
+ this._animate(x, y, time, easing.fn);
+ }
+ },
+
+ scrollToElement: function (el, time, offsetX, offsetY, easing) {
+ el = el.nodeType ? el : this.scroller.querySelector(el);
+
+ if ( !el ) {
+ return;
+ }
+
+ var pos = utils.offset(el);
+
+ pos.left -= this.wrapperOffset.left;
+ pos.top -= this.wrapperOffset.top;
+
+ // if offsetX/Y are true we center the element to the screen
+ if ( offsetX === true ) {
+ offsetX = Math.round(el.offsetWidth / 2 - this.wrapper.offsetWidth / 2);
+ }
+ if ( offsetY === true ) {
+ offsetY = Math.round(el.offsetHeight / 2 - this.wrapper.offsetHeight / 2);
+ }
+
+ pos.left -= offsetX || 0;
+ pos.top -= offsetY || 0;
+
+ pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left;
+ pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top;
+
+ time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(this.x-pos.left), Math.abs(this.y-pos.top)) : time;
+
+ this.scrollTo(pos.left, pos.top, time, easing);
+ },
+
+ _transitionTime: function (time) {
+ time = time || 0;
+
+ this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';
+
+ if ( !time && utils.isBadAndroid ) {
+ this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
+ }
+
+// INSERT POINT: _transitionTime
+
+ },
+
+ _transitionTimingFunction: function (easing) {
+ this.scrollerStyle[utils.style.transitionTimingFunction] = easing;
+
+// INSERT POINT: _transitionTimingFunction
+
+ },
+
+ _translate: function (x, y) {
+ if ( this.options.useTransform ) {
+
+/* REPLACE START: _translate */
+
+ this.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.translateZ;
+
+/* REPLACE END: _translate */
+
+ } else {
+ x = Math.round(x);
+ y = Math.round(y);
+ this.scrollerStyle.left = x + 'px';
+ this.scrollerStyle.top = y + 'px';
+ }
+
+ this.x = x;
+ this.y = y;
+
+// INSERT POINT: _translate
+
+ },
+
+ _initEvents: function (remove) {
+ var eventType = remove ? utils.removeEvent : utils.addEvent,
+ target = this.options.bindToWrapper ? this.wrapper : window;
+
+ eventType(window, 'orientationchange', this);
+ eventType(window, 'resize', this);
+
+ if ( this.options.click ) {
+ eventType(this.wrapper, 'click', this, true);
+ }
+
+ if ( !this.options.disableMouse ) {
+ eventType(this.wrapper, 'mousedown', this);
+ eventType(target, 'mousemove', this);
+ eventType(target, 'mousecancel', this);
+ eventType(target, 'mouseup', this);
+ }
+
+ if ( utils.hasPointer && !this.options.disablePointer ) {
+ eventType(this.wrapper, 'MSPointerDown', this);
+ eventType(target, 'MSPointerMove', this);
+ eventType(target, 'MSPointerCancel', this);
+ eventType(target, 'MSPointerUp', this);
+ }
+
+ if ( utils.hasTouch && !this.options.disableTouch ) {
+ eventType(this.wrapper, 'touchstart', this);
+ eventType(target, 'touchmove', this);
+ eventType(target, 'touchcancel', this);
+ eventType(target, 'touchend', this);
+ }
+
+ eventType(this.scroller, 'transitionend', this);
+ eventType(this.scroller, 'webkitTransitionEnd', this);
+ eventType(this.scroller, 'oTransitionEnd', this);
+ eventType(this.scroller, 'MSTransitionEnd', this);
+ },
+
+ getComputedPosition: function () {
+ var matrix = window.getComputedStyle(this.scroller, null),
+ x, y;
+
+ if ( this.options.useTransform ) {
+ matrix = matrix[utils.style.transform].split(')')[0].split(', ');
+ x = +(matrix[12] || matrix[4]);
+ y = +(matrix[13] || matrix[5]);
+ } else {
+ x = +matrix.left.replace(/[^-\d.]/g, '');
+ y = +matrix.top.replace(/[^-\d.]/g, '');
+ }
+
+ return { x: x, y: y };
+ },
diff --git a/src/default/_animate.js b/src/default/_animate.js
new file mode 100644
index 0000000..f2e160b
--- /dev/null
+++ b/src/default/_animate.js
@@ -0,0 +1,38 @@
+
+ _animate: function (destX, destY, duration, easingFn) {
+ var that = this,
+ startX = this.x,
+ startY = this.y,
+ startTime = utils.getTime(),
+ destTime = startTime + duration;
+
+ function step () {
+ var now = utils.getTime(),
+ newX, newY,
+ easing;
+
+ if ( now >= destTime ) {
+ that.isAnimating = false;
+ that._translate(destX, destY);
+
+ if ( !that.resetPosition(that.options.bounceTime) ) {
+ that._execEvent('scrollEnd');
+ }
+
+ return;
+ }
+
+ now = ( now - startTime ) / duration;
+ easing = easingFn(now);
+ newX = ( destX - startX ) * easing + startX;
+ newY = ( destY - startY ) * easing + startY;
+ that._translate(newX, newY);
+
+ if ( that.isAnimating ) {
+ rAF(step);
+ }
+ }
+
+ this.isAnimating = true;
+ step();
+ },
\ No newline at end of file
diff --git a/src/default/handleEvent.js b/src/default/handleEvent.js
new file mode 100644
index 0000000..046d0ce
--- /dev/null
+++ b/src/default/handleEvent.js
@@ -0,0 +1,48 @@
+
+ handleEvent: function (e) {
+ switch ( e.type ) {
+ case 'touchstart':
+ case 'MSPointerDown':
+ case 'mousedown':
+ this._start(e);
+ break;
+ case 'touchmove':
+ case 'MSPointerMove':
+ case 'mousemove':
+ this._move(e);
+ break;
+ case 'touchend':
+ case 'MSPointerUp':
+ case 'mouseup':
+ case 'touchcancel':
+ case 'MSPointerCancel':
+ case 'mousecancel':
+ this._end(e);
+ break;
+ case 'orientationchange':
+ case 'resize':
+ this._resize();
+ break;
+ case 'transitionend':
+ case 'webkitTransitionEnd':
+ case 'oTransitionEnd':
+ case 'MSTransitionEnd':
+ this._transitionEnd(e);
+ break;
+ case 'wheel':
+ case 'DOMMouseScroll':
+ case 'mousewheel':
+ this._wheel(e);
+ break;
+ case 'keydown':
+ this._key(e);
+ break;
+ case 'click':
+ if ( !e._constructed ) {
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ break;
+ }
+ }
+};
\ No newline at end of file
diff --git a/src/indicator/_initIndicators.js b/src/indicator/_initIndicators.js
new file mode 100644
index 0000000..492d56c
--- /dev/null
+++ b/src/indicator/_initIndicators.js
@@ -0,0 +1,104 @@
+
+ _initIndicators: function () {
+ var interactive = this.options.interactiveScrollbars,
+ customStyle = typeof this.options.scrollbars != 'string',
+ indicators = [],
+ indicator;
+
+ var that = this;
+
+ this.indicators = [];
+
+ if ( this.options.scrollbars ) {
+ // Vertical scrollbar
+ if ( this.options.scrollY ) {
+ indicator = {
+ el: createDefaultScrollbar('v', interactive, this.options.scrollbars),
+ interactive: interactive,
+ defaultScrollbars: true,
+ customStyle: customStyle,
+ resize: this.options.resizeScrollbars,
+ shrink: this.options.shrinkScrollbars,
+ fade: this.options.fadeScrollbars,
+ listenX: false
+ };
+
+ this.wrapper.appendChild(indicator.el);
+ indicators.push(indicator);
+ }
+
+ // Horizontal scrollbar
+ if ( this.options.scrollX ) {
+ indicator = {
+ el: createDefaultScrollbar('h', interactive, this.options.scrollbars),
+ interactive: interactive,
+ defaultScrollbars: true,
+ customStyle: customStyle,
+ resize: this.options.resizeScrollbars,
+ shrink: this.options.shrinkScrollbars,
+ fade: this.options.fadeScrollbars,
+ listenY: false
+ };
+
+ this.wrapper.appendChild(indicator.el);
+ indicators.push(indicator);
+ }
+ }
+
+ if ( this.options.indicators ) {
+ // TODO: check concat compatibility
+ indicators = indicators.concat(this.options.indicators);
+ }
+
+ for ( var i = indicators.length; i--; ) {
+ this.indicators.push( new Indicator(this, indicators[i]) );
+ }
+
+ // TODO: check if we can use array.map (wide compatibility and performance issues)
+ function _indicatorsMap (fn) {
+ for ( var i = that.indicators.length; i--; ) {
+ fn.call(that.indicators[i]);
+ }
+ }
+
+ if ( this.options.fadeScrollbars ) {
+ this.on('scrollEnd', function () {
+ _indicatorsMap(function () {
+ this.fade();
+ });
+ });
+
+ this.on('scrollCancel', function () {
+ _indicatorsMap(function () {
+ this.fade();
+ });
+ });
+
+ this.on('scrollStart', function () {
+ _indicatorsMap(function () {
+ this.fade(1);
+ });
+ });
+
+ this.on('beforeScrollStart', function () {
+ _indicatorsMap(function () {
+ this.fade(1, true);
+ });
+ });
+ }
+
+
+ this.on('refresh', function () {
+ _indicatorsMap(function () {
+ this.refresh();
+ });
+ });
+
+ this.on('destroy', function () {
+ _indicatorsMap(function () {
+ this.destroy();
+ });
+
+ delete this.indicators;
+ });
+ },
diff --git a/src/indicator/_transitionTime.js b/src/indicator/_transitionTime.js
new file mode 100644
index 0000000..79ad952
--- /dev/null
+++ b/src/indicator/_transitionTime.js
@@ -0,0 +1,6 @@
+
+ if ( this.indicators ) {
+ for ( var i = this.indicators.length; i--; ) {
+ this.indicators[i].transitionTime(time);
+ }
+ }
diff --git a/src/indicator/_transitionTimingFunction.js b/src/indicator/_transitionTimingFunction.js
new file mode 100644
index 0000000..f7963d1
--- /dev/null
+++ b/src/indicator/_transitionTimingFunction.js
@@ -0,0 +1,6 @@
+
+ if ( this.indicators ) {
+ for ( var i = this.indicators.length; i--; ) {
+ this.indicators[i].transitionTimingFunction(easing);
+ }
+ }
diff --git a/src/indicator/_translate.js b/src/indicator/_translate.js
new file mode 100644
index 0000000..59e277d
--- /dev/null
+++ b/src/indicator/_translate.js
@@ -0,0 +1,6 @@
+
+ if ( this.indicators ) {
+ for ( var i = this.indicators.length; i--; ) {
+ this.indicators[i].updatePosition();
+ }
+ }
diff --git a/src/indicator/build.json b/src/indicator/build.json
new file mode 100644
index 0000000..d597627
--- /dev/null
+++ b/src/indicator/build.json
@@ -0,0 +1,10 @@
+{
+ "insert": {
+ "OPTIONS": "\t\tresizeScrollbars: true,",
+ "NORMALIZATION": "\tif ( this.options.shrinkScrollbars == 'scale' ) {\n\t\tthis.options.useTransition = false;\n\t}",
+ "_init": "\t\tif ( this.options.scrollbars || this.options.indicators ) {\n\t\t\tthis._initIndicators();\n\t\t}",
+ "_transitionTime": "indicator/_transitionTime.js",
+ "_transitionTimingFunction": "indicator/_transitionTimingFunction.js",
+ "_translate": "indicator/_translate.js"
+ }
+}
\ No newline at end of file
diff --git a/src/indicator/indicator.js b/src/indicator/indicator.js
new file mode 100644
index 0000000..699e373
--- /dev/null
+++ b/src/indicator/indicator.js
@@ -0,0 +1,417 @@
+
+function createDefaultScrollbar (direction, interactive, type) {
+ var scrollbar = document.createElement('div'),
+ indicator = document.createElement('div');
+
+ if ( type === true ) {
+ scrollbar.style.cssText = 'position:absolute;z-index:9999';
+ indicator.style.cssText = '-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px';
+ }
+
+ indicator.className = 'iScrollIndicator';
+
+ if ( direction == 'h' ) {
+ if ( type === true ) {
+ scrollbar.style.cssText += ';height:7px;left:2px;right:2px;bottom:0';
+ indicator.style.height = '100%';
+ }
+ scrollbar.className = 'iScrollHorizontalScrollbar';
+ } else {
+ if ( type === true ) {
+ scrollbar.style.cssText += ';width:7px;bottom:2px;top:2px;right:1px';
+ indicator.style.width = '100%';
+ }
+ scrollbar.className = 'iScrollVerticalScrollbar';
+ }
+
+ scrollbar.style.cssText += ';overflow:hidden';
+
+ if ( !interactive ) {
+ scrollbar.style.pointerEvents = 'none';
+ }
+
+ scrollbar.appendChild(indicator);
+
+ return scrollbar;
+}
+
+function Indicator (scroller, options) {
+ this.wrapper = typeof options.el == 'string' ? document.querySelector(options.el) : options.el;
+ this.wrapperStyle = this.wrapper.style;
+ this.indicator = this.wrapper.children[0];
+ this.indicatorStyle = this.indicator.style;
+ this.scroller = scroller;
+
+ this.options = {
+ listenX: true,
+ listenY: true,
+ interactive: false,
+ resize: true,
+ defaultScrollbars: false,
+ shrink: false,
+ fade: false,
+ speedRatioX: 0,
+ speedRatioY: 0
+ };
+
+ for ( var i in options ) {
+ this.options[i] = options[i];
+ }
+
+ this.sizeRatioX = 1;
+ this.sizeRatioY = 1;
+ this.maxPosX = 0;
+ this.maxPosY = 0;
+
+ if ( this.options.interactive ) {
+ if ( !this.options.disableTouch ) {
+ utils.addEvent(this.indicator, 'touchstart', this);
+ utils.addEvent(window, 'touchend', this);
+ }
+ if ( !this.options.disablePointer ) {
+ utils.addEvent(this.indicator, 'MSPointerDown', this);
+ utils.addEvent(window, 'MSPointerUp', this);
+ }
+ if ( !this.options.disableMouse ) {
+ utils.addEvent(this.indicator, 'mousedown', this);
+ utils.addEvent(window, 'mouseup', this);
+ }
+ }
+
+ if ( this.options.fade ) {
+ this.wrapperStyle[utils.style.transform] = this.scroller.translateZ;
+ this.wrapperStyle[utils.style.transitionDuration] = utils.isBadAndroid ? '0.001s' : '0ms';
+ this.wrapperStyle.opacity = '0';
+ }
+}
+
+Indicator.prototype = {
+ handleEvent: function (e) {
+ switch ( e.type ) {
+ case 'touchstart':
+ case 'MSPointerDown':
+ case 'mousedown':
+ this._start(e);
+ break;
+ case 'touchmove':
+ case 'MSPointerMove':
+ case 'mousemove':
+ this._move(e);
+ break;
+ case 'touchend':
+ case 'MSPointerUp':
+ case 'mouseup':
+ case 'touchcancel':
+ case 'MSPointerCancel':
+ case 'mousecancel':
+ this._end(e);
+ break;
+ }
+ },
+
+ destroy: function () {
+ if ( this.options.interactive ) {
+ utils.removeEvent(this.indicator, 'touchstart', this);
+ utils.removeEvent(this.indicator, 'MSPointerDown', this);
+ utils.removeEvent(this.indicator, 'mousedown', this);
+
+ utils.removeEvent(window, 'touchmove', this);
+ utils.removeEvent(window, 'MSPointerMove', this);
+ utils.removeEvent(window, 'mousemove', this);
+
+ utils.removeEvent(window, 'touchend', this);
+ utils.removeEvent(window, 'MSPointerUp', this);
+ utils.removeEvent(window, 'mouseup', this);
+ }
+
+ if ( this.options.defaultScrollbars ) {
+ this.wrapper.parentNode.removeChild(this.wrapper);
+ }
+ },
+
+ _start: function (e) {
+ var point = e.touches ? e.touches[0] : e;
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ this.transitionTime();
+
+ this.initiated = true;
+ this.moved = false;
+ this.lastPointX = point.pageX;
+ this.lastPointY = point.pageY;
+
+ this.startTime = utils.getTime();
+
+ if ( !this.options.disableTouch ) {
+ utils.addEvent(window, 'touchmove', this);
+ }
+ if ( !this.options.disablePointer ) {
+ utils.addEvent(window, 'MSPointerMove', this);
+ }
+ if ( !this.options.disableMouse ) {
+ utils.addEvent(window, 'mousemove', this);
+ }
+
+ this.scroller._execEvent('beforeScrollStart');
+ },
+
+ _move: function (e) {
+ var point = e.touches ? e.touches[0] : e,
+ deltaX, deltaY,
+ newX, newY,
+ timestamp = utils.getTime();
+
+ if ( !this.moved ) {
+ this.scroller._execEvent('scrollStart');
+ }
+
+ this.moved = true;
+
+ deltaX = point.pageX - this.lastPointX;
+ this.lastPointX = point.pageX;
+
+ deltaY = point.pageY - this.lastPointY;
+ this.lastPointY = point.pageY;
+
+ newX = this.x + deltaX;
+ newY = this.y + deltaY;
+
+ this._pos(newX, newY);
+
+// INSERT POINT: indicator._move
+
+ e.preventDefault();
+ e.stopPropagation();
+ },
+
+ _end: function (e) {
+ if ( !this.initiated ) {
+ return;
+ }
+
+ this.initiated = false;
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ utils.removeEvent(window, 'touchmove', this);
+ utils.removeEvent(window, 'MSPointerMove', this);
+ utils.removeEvent(window, 'mousemove', this);
+
+ if ( this.scroller.options.snap ) {
+ var snap = this.scroller._nearestSnap(this.scroller.x, this.scroller.y);
+
+ var time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(this.scroller.x - snap.x), 1000),
+ Math.min(Math.abs(this.scroller.y - snap.y), 1000)
+ ), 300);
+
+ if ( this.scroller.x != snap.x || this.scroller.y != snap.y ) {
+ this.scroller.directionX = 0;
+ this.scroller.directionY = 0;
+ this.scroller.currentPage = snap;
+ this.scroller.scrollTo(snap.x, snap.y, time, this.scroller.options.bounceEasing);
+ }
+ }
+
+ if ( this.moved ) {
+ this.scroller._execEvent('scrollEnd');
+ }
+ },
+
+ transitionTime: function (time) {
+ time = time || 0;
+ this.indicatorStyle[utils.style.transitionDuration] = time + 'ms';
+
+ if ( !time && utils.isBadAndroid ) {
+ this.indicatorStyle[utils.style.transitionDuration] = '0.001s';
+ }
+ },
+
+ transitionTimingFunction: function (easing) {
+ this.indicatorStyle[utils.style.transitionTimingFunction] = easing;
+ },
+
+ refresh: function () {
+ this.transitionTime();
+
+ if ( this.options.listenX && !this.options.listenY ) {
+ this.indicatorStyle.display = this.scroller.hasHorizontalScroll ? 'block' : 'none';
+ } else if ( this.options.listenY && !this.options.listenX ) {
+ this.indicatorStyle.display = this.scroller.hasVerticalScroll ? 'block' : 'none';
+ } else {
+ this.indicatorStyle.display = this.scroller.hasHorizontalScroll || this.scroller.hasVerticalScroll ? 'block' : 'none';
+ }
+
+ if ( this.scroller.hasHorizontalScroll && this.scroller.hasVerticalScroll ) {
+ utils.addClass(this.wrapper, 'iScrollBothScrollbars');
+ utils.removeClass(this.wrapper, 'iScrollLoneScrollbar');
+
+ if ( this.options.defaultScrollbars && this.options.customStyle ) {
+ if ( this.options.listenX ) {
+ this.wrapper.style.right = '8px';
+ } else {
+ this.wrapper.style.bottom = '8px';
+ }
+ }
+ } else {
+ utils.removeClass(this.wrapper, 'iScrollBothScrollbars');
+ utils.addClass(this.wrapper, 'iScrollLoneScrollbar');
+
+ if ( this.options.defaultScrollbars && this.options.customStyle ) {
+ if ( this.options.listenX ) {
+ this.wrapper.style.right = '2px';
+ } else {
+ this.wrapper.style.bottom = '2px';
+ }
+ }
+ }
+
+ var r = this.wrapper.offsetHeight; // force refresh
+
+ if ( this.options.listenX ) {
+ this.wrapperWidth = this.wrapper.clientWidth;
+ if ( this.options.resize ) {
+ this.indicatorWidth = Math.max(Math.round(this.wrapperWidth * this.wrapperWidth / (this.scroller.scrollerWidth || this.wrapperWidth || 1)), 8);
+ this.indicatorStyle.width = this.indicatorWidth + 'px';
+ } else {
+ this.indicatorWidth = this.indicator.clientWidth;
+ }
+
+ this.maxPosX = this.wrapperWidth - this.indicatorWidth;
+
+ if ( this.options.shrink == 'clip' ) {
+ this.minBoundaryX = -this.indicatorWidth + 8;
+ this.maxBoundaryX = this.wrapperWidth - 8;
+ } else {
+ this.minBoundaryX = 0;
+ this.maxBoundaryX = this.maxPosX;
+ }
+
+ this.sizeRatioX = this.options.speedRatioX || (this.scroller.maxScrollX && (this.maxPosX / this.scroller.maxScrollX));
+ }
+
+ if ( this.options.listenY ) {
+ this.wrapperHeight = this.wrapper.clientHeight;
+ if ( this.options.resize ) {
+ this.indicatorHeight = Math.max(Math.round(this.wrapperHeight * this.wrapperHeight / (this.scroller.scrollerHeight || this.wrapperHeight || 1)), 8);
+ this.indicatorStyle.height = this.indicatorHeight + 'px';
+ } else {
+ this.indicatorHeight = this.indicator.clientHeight;
+ }
+
+ this.maxPosY = this.wrapperHeight - this.indicatorHeight;
+
+ if ( this.options.shrink == 'clip' ) {
+ this.minBoundaryY = -this.indicatorHeight + 8;
+ this.maxBoundaryY = this.wrapperHeight - 8;
+ } else {
+ 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 x = this.options.listenX && Math.round(this.sizeRatioX * this.scroller.x) || 0,
+ y = this.options.listenY && Math.round(this.sizeRatioY * this.scroller.y) || 0;
+
+ if ( !this.options.ignoreBoundaries ) {
+ if ( x < this.minBoundaryX ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.width = Math.max(this.indicatorWidth + x, 8);
+ this.indicatorStyle.width = this.width + 'px';
+ }
+ x = this.minBoundaryX;
+ } else if ( x > this.maxBoundaryX ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.width = Math.max(this.indicatorWidth - (x - this.maxPosX), 8);
+ this.indicatorStyle.width = this.width + 'px';
+ x = this.maxPosX + this.indicatorWidth - this.width;
+ } else {
+ x = this.maxBoundaryX;
+ }
+ } else if ( this.options.shrink == 'scale' && this.width != this.indicatorWidth ) {
+ this.width = this.indicatorWidth;
+ this.indicatorStyle.width = this.width + 'px';
+ }
+
+ if ( y < this.minBoundaryY ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.height = Math.max(this.indicatorHeight + y * 3, 8);
+ this.indicatorStyle.height = this.height + 'px';
+ }
+ y = this.minBoundaryY;
+ } else if ( y > this.maxBoundaryY ) {
+ if ( this.options.shrink == 'scale' ) {
+ this.height = Math.max(this.indicatorHeight - (y - this.maxPosY) * 3, 8);
+ this.indicatorStyle.height = this.height + 'px';
+ y = this.maxPosY + this.indicatorHeight - this.height;
+ } else {
+ y = this.maxBoundaryY;
+ }
+ } else if ( this.options.shrink == 'scale' && this.height != this.indicatorHeight ) {
+ this.height = this.indicatorHeight;
+ this.indicatorStyle.height = this.height + 'px';
+ }
+ }
+
+ this.x = x;
+ this.y = y;
+
+ if ( this.scroller.options.useTransform ) {
+ this.indicatorStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.scroller.translateZ;
+ } else {
+ this.indicatorStyle.left = x + 'px';
+ this.indicatorStyle.top = y + 'px';
+ }
+ },
+
+ _pos: function (x, y) {
+ if ( x < 0 ) {
+ x = 0;
+ } else if ( x > this.maxPosX ) {
+ x = this.maxPosX;
+ }
+
+ if ( y < 0 ) {
+ y = 0;
+ } else if ( y > this.maxPosY ) {
+ y = this.maxPosY;
+ }
+
+ x = this.options.listenX ? Math.round(x / this.sizeRatioX) : this.scroller.x;
+ y = this.options.listenY ? Math.round(y / this.sizeRatioY) : this.scroller.y;
+
+ this.scroller.scrollTo(x, y);
+ },
+
+ fade: function (val, hold) {
+ if ( hold && !this.visible ) {
+ return;
+ }
+
+ clearTimeout(this.fadeTimeout);
+ this.fadeTimeout = null;
+
+ var time = val ? 250 : 500,
+ delay = val ? 0 : 300;
+
+ val = val ? '1' : '0';
+
+ this.wrapperStyle[utils.style.transitionDuration] = time + 'ms';
+
+ this.fadeTimeout = setTimeout((function (val) {
+ this.wrapperStyle.opacity = val;
+ this.visible = +val;
+ }).bind(this, val), delay);
+ }
+};
diff --git a/src/infinite/build.json b/src/infinite/build.json
new file mode 100644
index 0000000..642256e
--- /dev/null
+++ b/src/infinite/build.json
@@ -0,0 +1,10 @@
+{
+ "insert": {
+ "OPTIONS": "\t\tinfiniteUseTransform: true,\n\t\tdeceleration: 0.004,",
+ "NORMALIZATION": "\tif ( this.options.infiniteElements ) {\n\t\tthis.options.probeType = 3;\n\t}\n\tthis.options.infiniteUseTransform = this.options.infiniteUseTransform && this.options.useTransform;",
+ "_init": "\t\tif ( this.options.infiniteElements ) {\n\t\t\tthis._initInfinite();\n\t\t}"
+ },
+ "replace": {
+ "refresh": "infinite/refresh.js"
+ }
+}
\ No newline at end of file
diff --git a/src/infinite/infinite.js b/src/infinite/infinite.js
new file mode 100644
index 0000000..426a627
--- /dev/null
+++ b/src/infinite/infinite.js
@@ -0,0 +1,98 @@
+
+ _initInfinite: function () {
+ var el = this.options.infiniteElements;
+
+ this.infiniteElements = typeof el == 'string' ? document.querySelectorAll(el) : el;
+ 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 || 1000;
+ this.infiniteCacheBuffer = Math.round(this.options.cacheSize / 4);
+
+ //this.infiniteCache = {};
+ this.options.dataset.call(this, 0, this.options.cacheSize);
+
+ this.on('refresh', function () {
+ var elementsPerPage = Math.ceil(this.wrapperHeight / this.infiniteElementHeight);
+ this.infiniteUpperBufferSize = Math.floor((this.infiniteLength - elementsPerPage) / 2);
+ this.reorderInfinite();
+ });
+
+ this.on('scroll', this.reorderInfinite);
+ },
+
+ // TO-DO: clean up the mess
+ reorderInfinite: function () {
+ var center = -this.y + this.wrapperHeight / 2;
+
+ var minorPhase = Math.max(Math.floor(-this.y / this.infiniteElementHeight) - this.infiniteUpperBufferSize, 0),
+ majorPhase = Math.floor(minorPhase / this.infiniteLength),
+ phase = minorPhase - majorPhase * this.infiniteLength;
+
+ var top = 0;
+ var i = 0;
+ var update = [];
+
+ //var cachePhase = Math.floor((minorPhase + this.infiniteLength / 2) / this.infiniteCacheBuffer);
+ var cachePhase = Math.floor(minorPhase / this.infiniteCacheBuffer);
+
+ while ( i < this.infiniteLength ) {
+ top = i * this.infiniteElementHeight + majorPhase * this.infiniteHeight;
+
+ if ( phase > i ) {
+ top += this.infiniteElementHeight * this.infiniteLength;
+ }
+
+ if ( this.infiniteElements[i]._top !== top ) {
+ this.infiniteElements[i]._phase = top / this.infiniteElementHeight;
+
+ if ( this.infiniteElements[i]._phase < this.options.infiniteLimit ) {
+ this.infiniteElements[i]._top = top;
+ if ( this.options.infiniteUseTransform ) {
+ this.infiniteElements[i].style[utils.style.transform] = 'translate(0, ' + top + 'px)' + this.translateZ;
+ } else {
+ this.infiniteElements[i].style.top = top + 'px';
+ }
+ update.push(this.infiniteElements[i]);
+ }
+ }
+
+ i++;
+ }
+
+ if ( this.cachePhase != cachePhase && (cachePhase === 0 || minorPhase - this.infiniteCacheBuffer > 0) ) {
+ this.options.dataset.call(this, Math.max(cachePhase * this.infiniteCacheBuffer - this.infiniteCacheBuffer, 0), this.options.cacheSize);
+ }
+
+ this.cachePhase = cachePhase;
+
+ this.updateContent(update);
+ },
+
+ updateContent: function (els) {
+ if ( this.infiniteCache === undefined ) {
+ return;
+ }
+
+ for ( var i = 0, l = els.length; i < l; i++ ) {
+ this.options.dataFiller.call(this, els[i], this.infiniteCache[els[i]._phase]);
+ }
+ },
+
+ updateCache: function (start, data) {
+ var firstRun = this.infiniteCache === undefined;
+
+ this.infiniteCache = {};
+
+ for ( var i = 0, l = data.length; i < l; i++ ) {
+ this.infiniteCache[start++] = data[i];
+ }
+
+ if ( firstRun ) {
+ this.updateContent(this.infiniteElements);
+ }
+
+ },
+
diff --git a/src/infinite/refresh.js b/src/infinite/refresh.js
new file mode 100644
index 0000000..16130a8
--- /dev/null
+++ b/src/infinite/refresh.js
@@ -0,0 +1,12 @@
+
+ this.scrollerWidth = this.scroller.offsetWidth;
+ this.scrollerHeight = this.scroller.offsetHeight;
+
+ this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
+
+ var limit;
+ if ( this.options.infiniteElements ) {
+ this.options.infiniteLimit = this.options.infiniteLimit || Math.floor(2147483645 / this.infiniteElementHeight);
+ limit = -this.options.infiniteLimit * this.infiniteElementHeight + this.wrapperHeight;
+ }
+ this.maxScrollY = limit !== undefined ? limit : this.wrapperHeight - this.scrollerHeight;
diff --git a/src/keys/build.json b/src/keys/build.json
new file mode 100644
index 0000000..3ec49ce
--- /dev/null
+++ b/src/keys/build.json
@@ -0,0 +1,5 @@
+{
+ "insert": {
+ "_init": "\t\tif ( this.options.keyBindings ) {\n\t\t\tthis._initKeys();\n\t\t}"
+ }
+}
\ No newline at end of file
diff --git a/src/keys/keys.js b/src/keys/keys.js
new file mode 100644
index 0000000..e7a0683
--- /dev/null
+++ b/src/keys/keys.js
@@ -0,0 +1,123 @@
+
+ _initKeys: function (e) {
+ // default key bindings
+ var keys = {
+ pageUp: 33,
+ pageDown: 34,
+ end: 35,
+ home: 36,
+ left: 37,
+ up: 38,
+ right: 39,
+ down: 40
+ };
+ var i;
+
+ // if you give me characters I give you keycode
+ if ( typeof this.options.keyBindings == 'object' ) {
+ for ( i in this.options.keyBindings ) {
+ if ( typeof this.options.keyBindings[i] == 'string' ) {
+ this.options.keyBindings[i] = this.options.keyBindings[i].toUpperCase().charCodeAt(0);
+ }
+ }
+ } else {
+ this.options.keyBindings = {};
+ }
+
+ for ( i in keys ) {
+ this.options.keyBindings[i] = this.options.keyBindings[i] || keys[i];
+ }
+
+ utils.addEvent(window, 'keydown', this);
+
+ this.on('destroy', function () {
+ utils.removeEvent(window, 'keydown', this);
+ });
+ },
+
+ _key: function (e) {
+ if ( !this.enabled ) {
+ return;
+ }
+
+ var snap = this.options.snap, // we are using this alot, better to cache it
+ newX = snap ? this.currentPage.pageX : this.x,
+ newY = snap ? this.currentPage.pageY : this.y,
+ now = utils.getTime(),
+ prevTime = this.keyTime || 0,
+ acceleration = 0.250,
+ pos;
+
+ if ( this.options.useTransition && this.isInTransition ) {
+ pos = this.getComputedPosition();
+
+ this._translate(Math.round(pos.x), Math.round(pos.y));
+ this.isInTransition = false;
+ }
+
+ this.keyAcceleration = now - prevTime < 200 ? Math.min(this.keyAcceleration + acceleration, 50) : 0;
+
+ switch ( e.keyCode ) {
+ case this.options.keyBindings.pageUp:
+ if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
+ newX += snap ? 1 : this.wrapperWidth;
+ } else {
+ newY += snap ? 1 : this.wrapperHeight;
+ }
+ break;
+ case this.options.keyBindings.pageDown:
+ if ( this.hasHorizontalScroll && !this.hasVerticalScroll ) {
+ newX -= snap ? 1 : this.wrapperWidth;
+ } else {
+ newY -= snap ? 1 : this.wrapperHeight;
+ }
+ break;
+ case this.options.keyBindings.end:
+ newX = snap ? this.pages.length-1 : this.maxScrollX;
+ newY = snap ? this.pages[0].length-1 : this.maxScrollY;
+ break;
+ case this.options.keyBindings.home:
+ newX = 0;
+ newY = 0;
+ break;
+ case this.options.keyBindings.left:
+ newX += snap ? -1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.up:
+ newY += snap ? 1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.right:
+ newX -= snap ? -1 : 5 + this.keyAcceleration>>0;
+ break;
+ case this.options.keyBindings.down:
+ newY -= snap ? 1 : 5 + this.keyAcceleration>>0;
+ break;
+ default:
+ return;
+ }
+
+ if ( snap ) {
+ this.goToPage(newX, newY);
+ return;
+ }
+
+ if ( newX > 0 ) {
+ newX = 0;
+ this.keyAcceleration = 0;
+ } else if ( newX < this.maxScrollX ) {
+ newX = this.maxScrollX;
+ this.keyAcceleration = 0;
+ }
+
+ if ( newY > 0 ) {
+ newY = 0;
+ this.keyAcceleration = 0;
+ } else if ( newY < this.maxScrollY ) {
+ newY = this.maxScrollY;
+ this.keyAcceleration = 0;
+ }
+
+ this.scrollTo(newX, newY, 0);
+
+ this.keyTime = now;
+ },
diff --git a/src/open.js b/src/open.js
new file mode 100644
index 0000000..d0df6c4
--- /dev/null
+++ b/src/open.js
@@ -0,0 +1 @@
+(function (window, document, Math) {
diff --git a/src/probe/_animate.js b/src/probe/_animate.js
new file mode 100644
index 0000000..d6c6100
--- /dev/null
+++ b/src/probe/_animate.js
@@ -0,0 +1,42 @@
+
+ _animate: function (destX, destY, duration, easingFn) {
+ var that = this,
+ startX = this.x,
+ startY = this.y,
+ startTime = utils.getTime(),
+ destTime = startTime + duration;
+
+ function step () {
+ var now = utils.getTime(),
+ newX, newY,
+ easing;
+
+ if ( now >= destTime ) {
+ that.isAnimating = false;
+ that._translate(destX, destY);
+
+ if ( !that.resetPosition(that.options.bounceTime) ) {
+ that._execEvent('scrollEnd');
+ }
+
+ return;
+ }
+
+ now = ( now - startTime ) / duration;
+ easing = easingFn(now);
+ newX = ( destX - startX ) * easing + startX;
+ newY = ( destY - startY ) * easing + startY;
+ that._translate(newX, newY);
+
+ if ( that.isAnimating ) {
+ rAF(step);
+ }
+
+ if ( that.options.probeType == 3 ) {
+ that._execEvent('scroll');
+ }
+ }
+
+ this.isAnimating = true;
+ step();
+ },
diff --git a/src/probe/_move.js b/src/probe/_move.js
new file mode 100644
index 0000000..34cb24f
--- /dev/null
+++ b/src/probe/_move.js
@@ -0,0 +1,14 @@
+
+ if ( timestamp - this.startTime > 300 ) {
+ this.startTime = timestamp;
+ this.startX = this.x;
+ this.startY = this.y;
+
+ if ( this.options.probeType == 1 ) {
+ this._execEvent('scroll');
+ }
+ }
+
+ if ( this.options.probeType > 1 ) {
+ this._execEvent('scroll');
+ }
diff --git a/src/probe/build.json b/src/probe/build.json
new file mode 100644
index 0000000..4cc93c0
--- /dev/null
+++ b/src/probe/build.json
@@ -0,0 +1,10 @@
+{
+ "insert": {
+ "NORMALIZATION": "\tif ( this.options.probeType == 3 ) {\n\t\tthis.options.useTransition = false;\t}",
+ "_wheel": "\t\tif ( this.options.probeType > 1 ) {\n\t\t\tthis._execEvent('scroll');\n\t\t}",
+ "indicator._move": "probe/indicator._move.js"
+ },
+ "replace": {
+ "_move": "probe/_move.js"
+ }
+}
\ No newline at end of file
diff --git a/src/probe/indicator._move.js b/src/probe/indicator._move.js
new file mode 100644
index 0000000..ea34ae3
--- /dev/null
+++ b/src/probe/indicator._move.js
@@ -0,0 +1,7 @@
+
+ if ( this.scroller.options.probeType == 1 && timestamp - this.startTime > 300 ) {
+ this.startTime = timestamp;
+ this.scroller._execEvent('scroll');
+ } else if ( this.scroller.options.probeType > 1 ) {
+ this.scroller._execEvent('scroll');
+ }
diff --git a/src/probe/probe.js b/src/probe/probe.js
new file mode 100644
index 0000000..72f18e4
--- /dev/null
+++ b/src/probe/probe.js
@@ -0,0 +1,6 @@
+
+iScroll.prototype._initProbe = function () {
+ if ( this.options.probeType == 3 ) {
+ this.options.useTransition = false;
+ }
+};
diff --git a/src/snap/_end.js b/src/snap/_end.js
new file mode 100644
index 0000000..84d598a
--- /dev/null
+++ b/src/snap/_end.js
@@ -0,0 +1,16 @@
+
+ if ( this.options.snap ) {
+ var snap = this._nearestSnap(newX, newY);
+ this.currentPage = snap;
+ time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(newX - snap.x), 1000),
+ Math.min(Math.abs(newY - snap.y), 1000)
+ ), 300);
+ newX = snap.x;
+ newY = snap.y;
+
+ this.directionX = 0;
+ this.directionY = 0;
+ easing = this.options.bounceEasing;
+ }
\ No newline at end of file
diff --git a/src/snap/build.json b/src/snap/build.json
new file mode 100644
index 0000000..eccb8db
--- /dev/null
+++ b/src/snap/build.json
@@ -0,0 +1,8 @@
+{
+ "insert": {
+ "OPTIONS": "\t\tsnapThreshold: 0.334,",
+ "_end": "snap/_end.js",
+ "refresh": "snap/refresh.js",
+ "_init": "\t\tif ( this.options.snap ) {\n\t\t\tthis._initSnap();\n\t\t}"
+ }
+}
\ No newline at end of file
diff --git a/src/snap/refresh.js b/src/snap/refresh.js
new file mode 100644
index 0000000..ec7ea83
--- /dev/null
+++ b/src/snap/refresh.js
@@ -0,0 +1,10 @@
+
+ if ( this.options.snap ) {
+ var snap = this._nearestSnap(this.x, this.y);
+ if ( this.x == snap.x && this.y == snap.y ) {
+ return;
+ }
+
+ this.currentPage = snap;
+ this.scrollTo(snap.x, snap.y);
+ }
diff --git a/src/snap/snap.js b/src/snap/snap.js
new file mode 100644
index 0000000..f2c8c38
--- /dev/null
+++ b/src/snap/snap.js
@@ -0,0 +1,247 @@
+
+ _initSnap: function () {
+ this.currentPage = {};
+
+ if ( typeof this.options.snap == 'string' ) {
+ this.options.snap = this.scroller.querySelectorAll(this.options.snap);
+ }
+
+ this.on('refresh', function () {
+ var i = 0, l,
+ m = 0, n,
+ cx, cy,
+ x = 0, y,
+ stepX = this.options.snapStepX || this.wrapperWidth,
+ stepY = this.options.snapStepY || this.wrapperHeight,
+ el;
+
+ this.pages = [];
+
+ if ( !this.wrapperWidth || !this.wrapperHeight || !this.scrollerWidth || !this.scrollerHeight ) {
+ return;
+ }
+
+ if ( this.options.snap === true ) {
+ cx = Math.round( stepX / 2 );
+ cy = Math.round( stepY / 2 );
+
+ while ( x > -this.scrollerWidth ) {
+ this.pages[i] = [];
+ l = 0;
+ y = 0;
+
+ while ( y > -this.scrollerHeight ) {
+ this.pages[i][l] = {
+ x: Math.max(x, this.maxScrollX),
+ y: Math.max(y, this.maxScrollY),
+ width: stepX,
+ height: stepY,
+ cx: x - cx,
+ cy: y - cy
+ };
+
+ y -= stepY;
+ l++;
+ }
+
+ x -= stepX;
+ i++;
+ }
+ } else {
+ el = this.options.snap;
+ l = el.length;
+ n = -1;
+
+ for ( ; i < l; i++ ) {
+ if ( i === 0 || el[i].offsetLeft <= el[i-1].offsetLeft ) {
+ m = 0;
+ n++;
+ }
+
+ if ( !this.pages[m] ) {
+ this.pages[m] = [];
+ }
+
+ x = Math.max(-el[i].offsetLeft, this.maxScrollX);
+ y = Math.max(-el[i].offsetTop, this.maxScrollY);
+ cx = x - Math.round(el[i].offsetWidth / 2);
+ cy = y - Math.round(el[i].offsetHeight / 2);
+
+ this.pages[m][n] = {
+ x: x,
+ y: y,
+ width: el[i].offsetWidth,
+ height: el[i].offsetHeight,
+ cx: cx,
+ cy: cy
+ };
+
+ if ( x > this.maxScrollX ) {
+ m++;
+ }
+ }
+ }
+
+ this.goToPage(this.currentPage.pageX || 0, this.currentPage.pageY || 0, 0);
+
+ // Update snap threshold if needed
+ if ( this.options.snapThreshold % 1 === 0 ) {
+ this.snapThresholdX = this.options.snapThreshold;
+ this.snapThresholdY = this.options.snapThreshold;
+ } else {
+ this.snapThresholdX = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width * this.options.snapThreshold);
+ this.snapThresholdY = Math.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height * this.options.snapThreshold);
+ }
+ });
+
+ this.on('flick', function () {
+ var time = this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(this.x - this.startX), 1000),
+ Math.min(Math.abs(this.y - this.startY), 1000)
+ ), 300);
+
+ this.goToPage(
+ this.currentPage.pageX + this.directionX,
+ this.currentPage.pageY + this.directionY,
+ time
+ );
+ });
+ },
+
+ _nearestSnap: function (x, y) {
+ if ( !this.pages.length ) {
+ return { x: 0, y: 0, pageX: 0, pageY: 0 };
+ }
+
+ var i = 0,
+ l = this.pages.length,
+ m = 0;
+
+ // Check if we exceeded the snap threshold
+ if ( Math.abs(x - this.absStartX) < this.snapThresholdX &&
+ Math.abs(y - this.absStartY) < this.snapThresholdY ) {
+ return this.currentPage;
+ }
+
+ if ( x > 0 ) {
+ x = 0;
+ } else if ( x < this.maxScrollX ) {
+ x = this.maxScrollX;
+ }
+
+ if ( y > 0 ) {
+ y = 0;
+ } else if ( y < this.maxScrollY ) {
+ y = this.maxScrollY;
+ }
+
+ for ( ; i < l; i++ ) {
+ if ( x >= this.pages[i][0].cx ) {
+ x = this.pages[i][0].x;
+ break;
+ }
+ }
+
+ l = this.pages[i].length;
+
+ for ( ; m < l; m++ ) {
+ if ( y >= this.pages[0][m].cy ) {
+ y = this.pages[0][m].y;
+ break;
+ }
+ }
+
+ if ( i == this.currentPage.pageX ) {
+ i += this.directionX;
+
+ if ( i < 0 ) {
+ i = 0;
+ } else if ( i >= this.pages.length ) {
+ i = this.pages.length - 1;
+ }
+
+ x = this.pages[i][0].x;
+ }
+
+ if ( m == this.currentPage.pageY ) {
+ m += this.directionY;
+
+ if ( m < 0 ) {
+ m = 0;
+ } else if ( m >= this.pages[0].length ) {
+ m = this.pages[0].length - 1;
+ }
+
+ y = this.pages[0][m].y;
+ }
+
+ return {
+ x: x,
+ y: y,
+ pageX: i,
+ pageY: m
+ };
+ },
+
+ goToPage: function (x, y, time, easing) {
+ easing = easing || this.options.bounceEasing;
+
+ if ( x >= this.pages.length ) {
+ x = this.pages.length - 1;
+ } else if ( x < 0 ) {
+ x = 0;
+ }
+
+ if ( y >= this.pages[x].length ) {
+ y = this.pages[x].length - 1;
+ } else if ( y < 0 ) {
+ y = 0;
+ }
+
+ var posX = this.pages[x][y].x,
+ posY = this.pages[x][y].y;
+
+ time = time === undefined ? this.options.snapSpeed || Math.max(
+ Math.max(
+ Math.min(Math.abs(posX - this.x), 1000),
+ Math.min(Math.abs(posY - this.y), 1000)
+ ), 300) : time;
+
+ this.currentPage = {
+ x: posX,
+ y: posY,
+ pageX: x,
+ pageY: y
+ };
+
+ this.scrollTo(posX, posY, time, easing);
+ },
+
+ next: function (time, easing) {
+ var x = this.currentPage.pageX,
+ y = this.currentPage.pageY;
+
+ x++;
+
+ if ( x >= this.pages.length && this.hasVerticalScroll ) {
+ x = 0;
+ y++;
+ }
+
+ this.goToPage(x, y, time, easing);
+ },
+
+ prev: function (time, easing) {
+ var x = this.currentPage.pageX,
+ y = this.currentPage.pageY;
+
+ x--;
+
+ if ( x < 0 && this.hasVerticalScroll ) {
+ x = 0;
+ y--;
+ }
+
+ this.goToPage(x, y, time, easing);
+ },
diff --git a/src/utils.js b/src/utils.js
new file mode 100644
index 0000000..b51b1e2
--- /dev/null
+++ b/src/utils.js
@@ -0,0 +1,234 @@
+var rAF = window.requestAnimationFrame ||
+ window.webkitRequestAnimationFrame ||
+ window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame ||
+ window.msRequestAnimationFrame ||
+ function (callback) { window.setTimeout(callback, 1000 / 60); };
+
+var utils = (function () {
+ var me = {};
+
+ var _elementStyle = document.createElement('div').style;
+ var _vendor = (function () {
+ var vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'],
+ transform,
+ i = 0,
+ l = vendors.length;
+
+ for ( ; i < l; i++ ) {
+ transform = vendors[i] + 'ransform';
+ if ( transform in _elementStyle ) return vendors[i].substr(0, vendors[i].length-1);
+ }
+
+ return false;
+ })();
+
+ function _prefixStyle (style) {
+ if ( _vendor === false ) return false;
+ if ( _vendor === '' ) return style;
+ return _vendor + style.charAt(0).toUpperCase() + style.substr(1);
+ }
+
+ me.getTime = Date.now || function getTime () { return new Date().getTime(); };
+
+ me.extend = function (target, obj) {
+ for ( var i in obj ) {
+ target[i] = obj[i];
+ }
+ };
+
+ me.addEvent = function (el, type, fn, capture) {
+ el.addEventListener(type, fn, !!capture);
+ };
+
+ me.removeEvent = function (el, type, fn, capture) {
+ el.removeEventListener(type, fn, !!capture);
+ };
+
+ me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
+ var distance = current - start,
+ speed = Math.abs(distance) / time,
+ destination,
+ duration;
+
+ deceleration = deceleration === undefined ? 0.0006 : deceleration;
+
+ destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );
+ duration = speed / deceleration;
+
+ if ( destination < lowerMargin ) {
+ destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin;
+ distance = Math.abs(destination - current);
+ duration = distance / speed;
+ } else if ( destination > 0 ) {
+ destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0;
+ distance = Math.abs(current) + destination;
+ duration = distance / speed;
+ }
+
+ return {
+ destination: Math.round(destination),
+ duration: duration
+ };
+ };
+
+ var _transform = _prefixStyle('transform');
+
+ me.extend(me, {
+ hasTransform: _transform !== false,
+ hasPerspective: _prefixStyle('perspective') in _elementStyle,
+ hasTouch: 'ontouchstart' in window,
+ hasPointer: navigator.msPointerEnabled,
+ hasTransition: _prefixStyle('transition') in _elementStyle
+ });
+
+ // This should find all Android browsers lower than build 535.19 (both stock browser and webview)
+ me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
+
+ me.extend(me.style = {}, {
+ transform: _transform,
+ transitionTimingFunction: _prefixStyle('transitionTimingFunction'),
+ transitionDuration: _prefixStyle('transitionDuration'),
+ transitionDelay: _prefixStyle('transitionDelay'),
+ transformOrigin: _prefixStyle('transformOrigin')
+ });
+
+ me.hasClass = function (e, c) {
+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)");
+ return re.test(e.className);
+ };
+
+ me.addClass = function (e, c) {
+ if ( me.hasClass(e, c) ) {
+ return;
+ }
+
+ var newclass = e.className.split(' ');
+ newclass.push(c);
+ e.className = newclass.join(' ');
+ };
+
+ me.removeClass = function (e, c) {
+ if ( !me.hasClass(e, c) ) {
+ return;
+ }
+
+ var re = new RegExp("(^|\\s)" + c + "(\\s|$)", 'g');
+ e.className = e.className.replace(re, ' ');
+ };
+
+ me.offset = function (el) {
+ var left = -el.offsetLeft,
+ top = -el.offsetTop;
+
+ // jshint -W084
+ while (el = el.offsetParent) {
+ left -= el.offsetLeft;
+ top -= el.offsetTop;
+ }
+ // jshint +W084
+
+ return {
+ left: left,
+ top: top
+ };
+ };
+
+ me.preventDefaultException = function (el, exceptions) {
+ for ( var i in exceptions ) {
+ if ( exceptions[i].test(el[i]) ) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ me.extend(me.eventType = {}, {
+ touchstart: 1,
+ touchmove: 1,
+ touchend: 1,
+
+ mousedown: 2,
+ mousemove: 2,
+ mouseup: 2,
+
+ MSPointerDown: 3,
+ MSPointerMove: 3,
+ MSPointerUp: 3
+ });
+
+ me.extend(me.ease = {}, {
+ quadratic: {
+ style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
+ fn: function (k) {
+ return k * ( 2 - k );
+ }
+ },
+ circular: {
+ 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)
+ fn: function (k) {
+ return Math.sqrt( 1 - ( --k * k ) );
+ }
+ },
+ back: {
+ style: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
+ fn: function (k) {
+ var b = 4;
+ return ( k = k - 1 ) * k * ( ( b + 1 ) * k + b ) + 1;
+ }
+ },
+ bounce: {
+ style: '',
+ fn: function (k) {
+ if ( ( k /= 1 ) < ( 1 / 2.75 ) ) {
+ return 7.5625 * k * k;
+ } else if ( k < ( 2 / 2.75 ) ) {
+ return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75;
+ } else if ( k < ( 2.5 / 2.75 ) ) {
+ return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375;
+ } else {
+ return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375;
+ }
+ }
+ },
+ elastic: {
+ style: '',
+ fn: function (k) {
+ var f = 0.22,
+ e = 0.4;
+
+ if ( k === 0 ) { return 0; }
+ if ( k == 1 ) { return 1; }
+
+ return ( e * Math.pow( 2, - 10 * k ) * Math.sin( ( k - f / 4 ) * ( 2 * Math.PI ) / f ) + 1 );
+ }
+ }
+ });
+
+ me.tap = function (e, eventName) {
+ var ev = document.createEvent('Event');
+ ev.initEvent(eventName, true, true);
+ ev.pageX = e.pageX;
+ ev.pageY = e.pageY;
+ e.target.dispatchEvent(ev);
+ };
+
+ me.click = function (e) {
+ var target = e.target,
+ ev;
+
+ if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) {
+ ev = document.createEvent('MouseEvents');
+ ev.initMouseEvent('click', true, true, e.view, 1,
+ target.screenX, target.screenY, target.clientX, target.clientY,
+ e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
+ 0, null);
+
+ ev._constructed = true;
+ target.dispatchEvent(ev);
+ }
+ };
+
+ return me;
+})();
diff --git a/src/wheel/build.json b/src/wheel/build.json
new file mode 100644
index 0000000..de47dcf
--- /dev/null
+++ b/src/wheel/build.json
@@ -0,0 +1,7 @@
+{
+ "insert": {
+ "OPTIONS": "\t\tmouseWheelSpeed: 20,",
+ "NORMALIZATION": "\tthis.options.invertWheelDirection = this.options.invertWheelDirection ? -1 : 1;",
+ "_init": "\t\tif ( this.options.mouseWheel ) {\n\t\t\tthis._initWheel();\n\t\t}"
+ }
+}
\ No newline at end of file
diff --git a/src/wheel/wheel.js b/src/wheel/wheel.js
new file mode 100644
index 0000000..6f6ade3
--- /dev/null
+++ b/src/wheel/wheel.js
@@ -0,0 +1,98 @@
+
+ _initWheel: function () {
+ utils.addEvent(this.wrapper, 'wheel', this);
+ utils.addEvent(this.wrapper, 'mousewheel', this);
+ utils.addEvent(this.wrapper, 'DOMMouseScroll', this);
+
+ this.on('destroy', function () {
+ utils.removeEvent(this.wrapper, 'wheel', this);
+ utils.removeEvent(this.wrapper, 'mousewheel', this);
+ utils.removeEvent(this.wrapper, 'DOMMouseScroll', this);
+ });
+ },
+
+ _wheel: function (e) {
+ if ( !this.enabled ) {
+ return;
+ }
+
+ e.preventDefault();
+ e.stopPropagation();
+
+ var wheelDeltaX, wheelDeltaY,
+ newX, newY,
+ that = this;
+
+ if ( this.wheelTimeout === undefined ) {
+ that._execEvent('scrollStart');
+ }
+
+ // Execute the scrollEnd event after 400ms the wheel stopped scrolling
+ clearTimeout(this.wheelTimeout);
+ this.wheelTimeout = setTimeout(function () {
+ that._execEvent('scrollEnd');
+ that.wheelTimeout = undefined;
+ }, 400);
+
+ if ( 'deltaX' in e ) {
+ wheelDeltaX = -e.deltaX;
+ wheelDeltaY = -e.deltaY;
+ } else if ( 'wheelDeltaX' in e ) {
+ wheelDeltaX = e.wheelDeltaX / 120 * this.options.mouseWheelSpeed;
+ wheelDeltaY = e.wheelDeltaY / 120 * this.options.mouseWheelSpeed;
+ } else if ( 'wheelDelta' in e ) {
+ wheelDeltaX = wheelDeltaY = e.wheelDelta / 120 * this.options.mouseWheelSpeed;
+ } else if ( 'detail' in e ) {
+ wheelDeltaX = wheelDeltaY = -e.detail / 3 * this.options.mouseWheelSpeed;
+ } else {
+ return;
+ }
+
+ wheelDeltaX *= this.options.invertWheelDirection;
+ wheelDeltaY *= this.options.invertWheelDirection;
+
+ if ( !this.hasVerticalScroll ) {
+ wheelDeltaX = wheelDeltaY;
+ wheelDeltaY = 0;
+ }
+
+ if ( this.options.snap ) {
+ newX = this.currentPage.pageX;
+ newY = this.currentPage.pageY;
+
+ if ( wheelDeltaX > 0 ) {
+ newX--;
+ } else if ( wheelDeltaX < 0 ) {
+ newX++;
+ }
+
+ if ( wheelDeltaY > 0 ) {
+ newY--;
+ } else if ( wheelDeltaY < 0 ) {
+ newY++;
+ }
+
+ this.goToPage(newX, newY);
+
+ return;
+ }
+
+ newX = this.x + Math.round(this.hasHorizontalScroll ? wheelDeltaX : 0);
+ newY = this.y + Math.round(this.hasVerticalScroll ? wheelDeltaY : 0);
+
+ if ( newX > 0 ) {
+ newX = 0;
+ } else if ( newX < this.maxScrollX ) {
+ newX = this.maxScrollX;
+ }
+
+ if ( newY > 0 ) {
+ newY = 0;
+ } else if ( newY < this.maxScrollY ) {
+ newY = this.maxScrollY;
+ }
+
+ this.scrollTo(newX, newY, 0);
+
+// INSERT POINT: _wheel
+ },
diff --git a/src/zoom/build.json b/src/zoom/build.json
new file mode 100644
index 0000000..43ec9c7
--- /dev/null
+++ b/src/zoom/build.json
@@ -0,0 +1,11 @@
+{
+ "insert": {
+ "OPTIONS": "\t\tzoomMin: 1,\n\t\tzoomMax: 4, startZoom: 1,",
+ "DEFAULTS": "\tthis.scale = Math.min(Math.max(this.options.startZoom, this.options.zoomMin), this.options.zoomMax);",
+ "_init": "\t\tif ( this.options.zoom ) {\n\t\t\tthis._initZoom();\n\t\t}"
+ },
+ "replace": {
+ "refresh": "zoom/refresh.js",
+ "_translate": "\t\t\tthis.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px) scale(' + this.scale + ') ' + this.translateZ;"
+ }
+}
\ No newline at end of file
diff --git a/src/zoom/handleEvent.js b/src/zoom/handleEvent.js
new file mode 100644
index 0000000..cf26efa
--- /dev/null
+++ b/src/zoom/handleEvent.js
@@ -0,0 +1,59 @@
+
+ handleEvent: function (e) {
+ switch ( e.type ) {
+ case 'touchstart':
+ case 'MSPointerDown':
+ case 'mousedown':
+ this._start(e);
+
+ if ( this.options.zoom && e.touches && e.touches.length > 1 ) {
+ this._zoomStart(e);
+ }
+ break;
+ case 'touchmove':
+ case 'MSPointerMove':
+ case 'mousemove':
+ if ( this.options.zoom && e.touches && e.touches[1] ) {
+ this._zoom(e);
+ return;
+ }
+ this._move(e);
+ break;
+ case 'touchend':
+ case 'MSPointerUp':
+ case 'mouseup':
+ case 'touchcancel':
+ case 'MSPointerCancel':
+ case 'mousecancel':
+ if ( this.scaled ) {
+ this._zoomEnd(e);
+ return;
+ }
+ this._end(e);
+ break;
+ case 'orientationchange':
+ case 'resize':
+ this._resize();
+ break;
+ case 'transitionend':
+ case 'webkitTransitionEnd':
+ case 'oTransitionEnd':
+ case 'MSTransitionEnd':
+ this._transitionEnd(e);
+ break;
+ case 'wheel':
+ case 'DOMMouseScroll':
+ case 'mousewheel':
+ if ( this.options.wheelAction == 'zoom' ) {
+ this._wheelZoom(e);
+ return;
+ }
+ this._wheel(e);
+ break;
+ case 'keydown':
+ this._key(e);
+ break;
+ }
+ }
+
+};
\ No newline at end of file
diff --git a/src/zoom/refresh.js b/src/zoom/refresh.js
new file mode 100644
index 0000000..bd1830c
--- /dev/null
+++ b/src/zoom/refresh.js
@@ -0,0 +1,6 @@
+
+ this.scrollerWidth = Math.round(this.scroller.offsetWidth * this.scale);
+ this.scrollerHeight = Math.round(this.scroller.offsetHeight * this.scale);
+
+ this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
+ this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
diff --git a/src/zoom/zoom.js b/src/zoom/zoom.js
new file mode 100644
index 0000000..fc2c2eb
--- /dev/null
+++ b/src/zoom/zoom.js
@@ -0,0 +1,170 @@
+
+ _initZoom: function () {
+ this.scrollerStyle[utils.style.transformOrigin] = '0 0';
+ },
+
+ _zoomStart: function (e) {
+ var c1 = Math.abs( e.touches[0].pageX - e.touches[1].pageX ),
+ c2 = Math.abs( e.touches[0].pageY - e.touches[1].pageY );
+
+ this.touchesDistanceStart = Math.sqrt(c1 * c1 + c2 * c2);
+ this.startScale = this.scale;
+
+ this.originX = Math.abs(e.touches[0].pageX + e.touches[1].pageX) / 2 + this.wrapperOffset.left - this.x;
+ this.originY = Math.abs(e.touches[0].pageY + e.touches[1].pageY) / 2 + this.wrapperOffset.top - this.y;
+
+ this._execEvent('zoomStart');
+ },
+
+ _zoom: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault ) {
+ e.preventDefault();
+ }
+
+ var c1 = Math.abs( e.touches[0].pageX - e.touches[1].pageX ),
+ c2 = Math.abs( e.touches[0].pageY - e.touches[1].pageY ),
+ distance = Math.sqrt( c1 * c1 + c2 * c2 ),
+ scale = 1 / this.touchesDistanceStart * distance * this.startScale,
+ lastScale,
+ x, y;
+
+ this.scaled = true;
+
+ if ( scale < this.options.zoomMin ) {
+ scale = 0.5 * this.options.zoomMin * Math.pow(2.0, scale / this.options.zoomMin);
+ } else if ( scale > this.options.zoomMax ) {
+ scale = 2.0 * this.options.zoomMax * Math.pow(0.5, this.options.zoomMax / scale);
+ }
+
+ lastScale = scale / this.startScale;
+ x = this.originX - this.originX * lastScale + this.startX;
+ y = this.originY - this.originY * lastScale + this.startY;
+
+ this.scale = scale;
+
+ this.scrollTo(x, y, 0);
+ },
+
+ _zoomEnd: function (e) {
+ if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
+ return;
+ }
+
+ if ( this.options.preventDefault ) {
+ e.preventDefault();
+ }
+
+ var newX, newY,
+ lastScale;
+
+ this.isInTransition = 0;
+ this.initiated = 0;
+
+ if ( this.scale > this.options.zoomMax ) {
+ this.scale = this.options.zoomMax;
+ } else if ( this.scale < this.options.zoomMin ) {
+ this.scale = this.options.zoomMin;
+ }
+
+ // Update boundaries
+ this.refresh();
+
+ lastScale = this.scale / this.startScale;
+
+ newX = this.originX - this.originX * lastScale + this.startX;
+ newY = this.originY - this.originY * lastScale + this.startY;
+
+ if ( newX > 0 ) {
+ newX = 0;
+ } else if ( newX < this.maxScrollX ) {
+ newX = this.maxScrollX;
+ }
+
+ if ( newY > 0 ) {
+ newY = 0;
+ } else if ( newY < this.maxScrollY ) {
+ newY = this.maxScrollY;
+ }
+
+ if ( this.x != newX || this.y != newY ) {
+ this.scrollTo(newX, newY, this.options.bounceTime);
+ }
+
+ this.scaled = false;
+
+ this._execEvent('zoomEnd');
+ },
+
+ zoom: function (scale, x, y, time) {
+ if ( scale < this.options.zoomMin ) {
+ scale = this.options.zoomMin;
+ } else if ( scale > this.options.zoomMax ) {
+ scale = this.options.zoomMax;
+ }
+
+ if ( scale == this.scale ) {
+ return;
+ }
+
+ var relScale = scale / this.scale;
+
+ x = x === undefined ? this.wrapperWidth / 2 : x;
+ y = y === undefined ? this.wrapperHeight / 2 : y;
+ time = time === undefined ? 300 : time;
+
+ x = x + this.wrapperOffset.left - this.x;
+ y = y + this.wrapperOffset.top - this.y;
+
+ x = x - x * relScale + this.x;
+ y = y - y * relScale + this.y;
+
+ this.scale = scale;
+
+ this.refresh(); // update boundaries
+
+ if ( x > 0 ) {
+ x = 0;
+ } else if ( x < this.maxScrollX ) {
+ x = this.maxScrollX;
+ }
+
+ if ( y > 0 ) {
+ y = 0;
+ } else if ( y < this.maxScrollY ) {
+ y = this.maxScrollY;
+ }
+
+ this.scrollTo(x, y, time);
+ },
+
+ _wheelZoom: function (e) {
+ var wheelDeltaY,
+ deltaScale,
+ that = this;
+
+ // Execute the zoomEnd event after 400ms the wheel stopped scrolling
+ clearTimeout(this.wheelTimeout);
+ this.wheelTimeout = setTimeout(function () {
+ that._execEvent('zoomEnd');
+ }, 400);
+
+ if ( 'deltaX' in e ) {
+ wheelDeltaY = -e.deltaY / Math.abs(e.deltaY);
+ } else if ('wheelDeltaX' in e) {
+ wheelDeltaY = e.wheelDeltaY / Math.abs(e.wheelDeltaY);
+ } else if('wheelDelta' in e) {
+ wheelDeltaY = e.wheelDelta / Math.abs(e.wheelDelta);
+ } else if ('detail' in e) {
+ wheelDeltaY = -e.detail / Math.abs(e.wheelDelta);
+ } else {
+ return;
+ }
+
+ deltaScale = this.scale + wheelDeltaY / 5;
+
+ this.zoom(deltaScale, e.pageX, e.pageY, 0);
+ },
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-iscroll.git
More information about the Pkg-javascript-commits
mailing list