{"version":3,"file":"kendo.mobile.scroller.min.js","sources":["kendo.mobile.scroller.js"],"sourcesContent":["(function(f, define) {\n define('kendo.mobile.scroller',[ \"kendo.fx\", \"kendo.draganddrop\" ], f);\n})(function() {\n\nvar __meta__ = {\n id: \"mobile.scroller\",\n name: \"Scroller\",\n category: \"mobile\",\n description: \"The Kendo Mobile Scroller widget enables touch friendly kinetic scrolling for the contents of a given DOM element.\",\n depends: [ \"fx\", \"draganddrop\" ]\n};\n\n(function($, undefined) {\n var kendo = window.kendo,\n mobile = kendo.mobile,\n fx = kendo.effects,\n ui = mobile.ui,\n extend = $.extend,\n Widget = ui.Widget,\n Class = kendo.Class,\n Movable = kendo.ui.Movable,\n Pane = kendo.ui.Pane,\n PaneDimensions = kendo.ui.PaneDimensions,\n Transition = fx.Transition,\n Animation = fx.Animation,\n abs = Math.abs,\n SNAPBACK_DURATION = 500,\n SCROLLBAR_OPACITY = 0.7,\n FRICTION = 0.96,\n VELOCITY_MULTIPLIER = 10,\n MAX_VELOCITY = 55,\n OUT_OF_BOUNDS_FRICTION = 0.5,\n ANIMATED_SCROLLER_PRECISION = 5,\n RELEASECLASS = \"km-scroller-release\",\n REFRESHCLASS = \"km-scroller-refresh\",\n PULL = \"pull\",\n CHANGE = \"change\",\n RESIZE = \"resize\",\n SCROLL = \"scroll\",\n MOUSE_WHEEL_ID = 2;\n\n var ZoomSnapBack = Animation.extend({\n init: function(options) {\n var that = this;\n Animation.fn.init.call(that);\n extend(that, options);\n\n that.userEvents.bind(\"gestureend\", that.start.bind(that));\n that.tapCapture.bind(\"press\", that.cancel.bind(that));\n },\n\n enabled: function() {\n return this.movable.scale < this.dimensions.minScale;\n },\n\n done: function() {\n return this.dimensions.minScale - this.movable.scale < 0.01;\n },\n\n tick: function() {\n var movable = this.movable;\n movable.scaleWith(1.1);\n this.dimensions.rescale(movable.scale);\n },\n\n onEnd: function() {\n var movable = this.movable;\n movable.scaleTo(this.dimensions.minScale);\n this.dimensions.rescale(movable.scale);\n }\n });\n\n var DragInertia = Animation.extend({\n init: function(options) {\n var that = this;\n\n Animation.fn.init.call(that);\n\n extend(that, options, {\n transition: new Transition({\n axis: options.axis,\n movable: options.movable,\n onEnd: function() { that._end(); }\n })\n });\n\n that.tapCapture.bind(\"press\", function() { that.cancel(); });\n that.userEvents.bind(\"end\", that.start.bind(that));\n that.userEvents.bind(\"gestureend\", that.start.bind(that));\n that.userEvents.bind(\"tap\", that.onEnd.bind(that));\n },\n\n onCancel: function() {\n this.transition.cancel();\n },\n\n freeze: function(location) {\n var that = this;\n that.cancel();\n that._moveTo(location);\n },\n\n onEnd: function() {\n var that = this;\n if (that.paneAxis.outOfBounds()) {\n that._snapBack();\n } else {\n that._end();\n }\n },\n\n done: function() {\n return abs(this.velocity) < 1;\n },\n\n start: function(e) {\n var that = this,\n velocity;\n\n if (!that.dimension.enabled) { return; }\n\n if (that.paneAxis.outOfBounds()) {\n if (that.transition._started) {\n that.transition.cancel();\n that.velocity = Math.min(e.touch[that.axis].velocity * that.velocityMultiplier, MAX_VELOCITY);\n\n Animation.fn.start.call(that);\n } else {\n that._snapBack();\n }\n } else {\n velocity = e.touch.id === MOUSE_WHEEL_ID ? 0 : e.touch[that.axis].velocity;\n that.velocity = Math.max(Math.min(velocity * that.velocityMultiplier, MAX_VELOCITY), -MAX_VELOCITY);\n\n that.tapCapture.captureNext();\n Animation.fn.start.call(that);\n }\n },\n\n tick: function() {\n var that = this,\n dimension = that.dimension,\n friction = that.paneAxis.outOfBounds() ? OUT_OF_BOUNDS_FRICTION : that.friction,\n delta = (that.velocity *= friction),\n location = that.movable[that.axis] + delta;\n\n if (!that.elastic && dimension.outOfBounds(location)) {\n location = Math.max(Math.min(location, dimension.max), dimension.min);\n that.velocity = 0;\n }\n\n that.movable.moveAxis(that.axis, location);\n },\n\n _end: function() {\n this.tapCapture.cancelCapture();\n this.end();\n },\n\n _snapBack: function() {\n var that = this,\n dimension = that.dimension,\n snapBack = that.movable[that.axis] > dimension.max ? dimension.max : dimension.min;\n that._moveTo(snapBack);\n },\n\n _moveTo: function(location) {\n this.transition.moveTo({ location: location, duration: SNAPBACK_DURATION, ease: Transition.easeOutExpo });\n }\n });\n\n var AnimatedScroller = Animation.extend({\n init: function(options) {\n var that = this;\n\n kendo.effects.Animation.fn.init.call(this);\n\n extend(that, options, {\n origin: {},\n destination: {},\n offset: {}\n });\n },\n\n tick: function() {\n this._updateCoordinates();\n this.moveTo(this.origin);\n },\n\n done: function() {\n return abs(this.offset.y) < ANIMATED_SCROLLER_PRECISION && abs(this.offset.x) < ANIMATED_SCROLLER_PRECISION;\n },\n\n onEnd: function() {\n this.moveTo(this.destination);\n if (this.callback) {\n this.callback.call();\n }\n },\n\n setCoordinates: function(from, to) {\n this.offset = {};\n this.origin = from;\n this.destination = to;\n },\n\n setCallback: function(callback) {\n if (callback && kendo.isFunction(callback)) {\n this.callback = callback;\n } else {\n callback = undefined;\n }\n },\n\n _updateCoordinates: function() {\n this.offset = {\n x: (this.destination.x - this.origin.x) / 4,\n y: (this.destination.y - this.origin.y) / 4\n };\n\n this.origin = {\n y: this.origin.y + this.offset.y,\n x: this.origin.x + this.offset.x\n };\n }\n });\n\n var ScrollBar = Class.extend({\n init: function(options) {\n var that = this,\n horizontal = options.axis === \"x\",\n element = $('
');\n\n if (horizontal) {\n element.attr(\"aria-orientation\", \"horizontal\");\n }\n\n extend(that, options, {\n element: element,\n elementSize: 0,\n movable: new Movable(element),\n scrollMovable: options.movable,\n alwaysVisible: options.alwaysVisible,\n size: horizontal ? \"width\" : \"height\"\n });\n\n that.scrollMovable.bind(CHANGE, that.refresh.bind(that));\n that.container.append(element);\n if (options.alwaysVisible) {\n that.show();\n }\n },\n\n refresh: function() {\n var that = this,\n axis = that.axis,\n dimension = that.dimension,\n paneSize = dimension.size,\n scrollMovable = that.scrollMovable,\n sizeRatio = paneSize / dimension.total,\n position = Math.round(-scrollMovable[axis] * sizeRatio),\n size = Math.round(paneSize * sizeRatio);\n\n if (sizeRatio >= 1) {\n this.element.css(\"display\", \"none\");\n } else {\n this.element.css(\"display\", \"\");\n }\n\n if (position + size > paneSize) {\n size = paneSize - position;\n } else if (position < 0) {\n size += position;\n position = 0;\n }\n\n if (that.elementSize != size) {\n that.element.css(that.size, size + \"px\");\n that.elementSize = size;\n }\n\n that._ariaValue(position, dimension.size - that.elementSize);\n\n that.movable.moveAxis(axis, position);\n },\n\n show: function() {\n this.element.css({ opacity: SCROLLBAR_OPACITY, visibility: \"visible\" });\n },\n\n hide: function() {\n if (!this.alwaysVisible) {\n this.element.css({ opacity: 0 });\n }\n },\n\n _ariaValue: function(current, total) {\n var element = this.element;\n\n if (current > total) {\n current = total;\n }\n\n element.attr(\"aria-valuemax\", total);\n element.attr(\"aria-valuenow\", current);\n }\n });\n\n var Scroller = Widget.extend({\n init: function(element, options) {\n var that = this;\n Widget.fn.init.call(that, element, options);\n\n element = that.element;\n\n that._native = that.options.useNative && kendo.support.hasNativeScrolling;\n if (that._native) {\n element.addClass(\"km-native-scroller\")\n .prepend('