_aspxEnableCssAnimation = true; aspxAnimationTransitionBase = _aspxCreateClass(null, { constructor: function (element, options) { aspxAnimationTransitionBase.Cancel(element); this.element = element; this.element.aspxTransition = this; this.duration = options.duration || aspxAnimationTransitionBase.Durations.DEFAULT; this.transition = options.transition || aspxAnimationTransitionBase.Transitions.SINE; this.property = options.property; this.unit = options.unit || ""; this.onComplete = options.onComplete; this.to = null; this.from = null; }, Start: function (from, to) { if (to != undefined) { this.to = to; this.from = from; this.SetValue(this.from); } else this.to = from; }, Cancel: function () { try { delete this.element.aspxTransition; } catch (e) { this.element.aspxTransition = undefined; } }, GetValue: function () { return this.getValueInternal(this.element, this.property); }, SetValue: function (value) { this.setValueInternal(this.element, this.property, this.unit, value); }, setValueInternal: function (element, property, unit, value) { if (property == "opacity") ASPxAnimationHelper.setOpacity(element, value); else element.style[property] = value + unit; }, getValueInternal: function (element, property) { if (property == "opacity") return _aspxGetElementOpacity(element); var value = parseFloat(element.style[property]); return isNaN(value) ? 0 : value; }, performOnComplete: function () { if (this.onComplete) this.onComplete(this.element); }, getTransition: function () { return this.transition; } }); aspxAnimationTransitionBase.Cancel = function (element) { if (element.aspxTransition) element.aspxTransition.Cancel(); }; aspxAnimationTransitionBase.Durations = { SHORT: 200, DEFAULT: 400, LONG: 600 }; aspxAnimationTransitionBase.Transitions = { LINER: { Css: "cubic-bezier(0.250, 0.250, 0.750, 0.750)", Js: function (progress) { return progress; } }, SINE: { Css: "cubic-bezier(0.470, 0.000, 0.745, 0.715)", Js: function (progress) { return Math.sin(progress * 1.57); } }, POW: { Css: "cubic-bezier(0.755, 0.050, 0.855, 0.060)", Js: function (progress) { return Math.pow(progress, 4); } }, POW_EASE_OUT: { Css: "cubic-bezier(0.165, 0.840, 0.440, 1.000)", Js: function (progress) { return 1 - aspxAnimationTransitionBase.Transitions.POW.Js(1 - progress); } } }; aspxJsAnimationTransition = _aspxCreateClass(aspxAnimationTransitionBase, { constructor: function (element, options) { this.constructor.prototype.constructor.call(this, element, options); this.fps = 60; this.startTime = null; }, Start: function (from, to) { aspxAnimationTransitionBase.prototype.Start.call(this, from, to); this.initTimer(); }, Cancel: function () { aspxAnimationTransitionBase.prototype.Cancel.call(this); if (this.timerId) clearInterval(this.timerId); }, initTimer: function () { this.startTime = new Date(); this.timerId = window.setInterval(function () { this.onTick(); }.aspxBind(this), 1000 / this.fps); }, onTick: function () { var progress = (new Date() - this.startTime) / this.duration; if (progress >= 1) this.complete(); else this.update(progress); }, update: function (progress) { this.SetValue(this.gatCalculatedValue(this.from, this.to, progress)); }, complete: function () { this.Cancel(); this.update(1); this.performOnComplete(); }, gatCalculatedValue: function (from, to, progress) { if (progress == 1) return to; return from + (to - from) * this.getTransition()(progress); }, getTransition: function () { return this.transition.Js; } }); aspxMultipleJsAnimationTransition = _aspxCreateClass(aspxJsAnimationTransition, { constructor: function (element, options) { this.constructor.prototype.constructor.call(this, element, options); this.properties = { }; }, Start: function (properties) { this.initProperties(properties); this.initTimer(); }, initProperties: function (properties) { this.properties = properties; for (var propName in this.properties) if (properties[propName].from == undefined) properties[propName].from = this.getValueInternal(this.element, propName); }, update: function (progress) { for (var propName in this.properties) { var property = this.properties[propName]; if (property.from != property.to) this.setValueInternal(this.element, propName, property.unit, this.gatCalculatedValue(property.from, property.to, progress)); } } }); aspxCssAnimationTransition = _aspxCreateClass(aspxAnimationTransitionBase, { constructor: function (element, options) { this.constructor.prototype.constructor.call(this, element, options); this.transitionPropertyName = aspxCssAnimationTransition.CSS_TRANSITION.transitionPropertyName; this.eventName = aspxCssAnimationTransition.CSS_TRANSITION.eventName; }, Start: function (from, to) { aspxAnimationTransitionBase.prototype.Start.call(this, from, to); _aspxSetTimeout(function() { var isHidden = this.element.offsetHeight == 0 && this.element.offsetWidth == 0; if(!isHidden) this.prepareElementBeforeAnimation(); this.SetValue(this.to); if(isHidden) this.onTransitionEnd(); }.aspxBind(this), 0); }, Cancel: function () { aspxAnimationTransitionBase.prototype.Cancel.call(this); _aspxDetachEventFromElement(this.element, this.eventName, aspxCssAnimationTransition.transitionEnd); this.stopAnimation(); this.setValueInternal(this.element, this.transitionPropertyName, "", ""); }, prepareElementBeforeAnimation: function () { _aspxAttachEventToElement(this.element, this.eventName, aspxCssAnimationTransition.transitionEnd); var tmpH = this.element.offsetHeight; this.element.style[this.transitionPropertyName] = this.getTransitionCssString(); }, stopAnimation: function () { this.SetValue(_aspxGetCurrentStyle(this.element)[this.property]); }, onTransitionEnd: function () { this.Cancel(); this.performOnComplete(); }, getTransition: function () { return this.transition.Css; }, getTransitionCssString: function () { return this.getTransitionCssStringInternal(this.getCssName(this.property)); }, getTransitionCssStringInternal: function (cssProperty) { return cssProperty + " " + this.duration + "ms " + this.getTransition(); }, getCssName: function (property) { switch (property) { case "marginLeft": return "margin-left"; case "marginTop": return "margin-top" } return property; } }); aspxMultipleCssAnimationTransition = _aspxCreateClass(aspxCssAnimationTransition, { constructor: function (element, options) { this.constructor.prototype.constructor.call(this, element, options); this.properties = null; }, Start: function (properties) { this.properties = properties; this.prepareElementBeforeAnimation(); this.forEachProperties(function (property, propName) { this.setValueInternal(this.element, propName, property.unit, property.to); }.aspxBind(this)); }, stopAnimation: function () { var style = _aspxGetCurrentStyle(this.element); this.forEachProperties(function (property, propName) { this.setValueInternal(this.element, propName, "", style[propName]); }.aspxBind(this)); }, getTransitionCssString: function () { var str = ""; this.forEachProperties(function (property, propName) { str += this.getTransitionCssStringInternal(this.getCssName(propName)) + ","; }.aspxBind(this)); str = str.substring(0, str.length - 1); return str; }, forEachProperties: function (func) { for (var propName in this.properties) { var property = this.properties[propName]; if (property.from == undefined) property.from = this.getValueInternal(this.element, propName); if (property.from != property.to) func(property, propName); } } }); aspxCssAnimationTransition.transitionEnd = function (evt) { var element = evt.target; if (element && element.aspxTransition) element.aspxTransition.onTransitionEnd(); } aspxCssAnimationTransition.CSS_TRANSITION = (function () { if (__aspxIE) return null; var cssNames = [ { transitionPropertyName: "webkitTransition", eventName: "webkitTransitionEnd" }, { transitionPropertyName: "MozTransition", eventName: "transitionend" }, { transitionPropertyName: "OTransition", eventName: "oTransitionEnd" }, { transitionPropertyName: "transition", eventName: "transitionend" } ]; var fakeElement = document.createElement("DIV"); for (var i = 0; i < cssNames.length; i++) if (cssNames[i].transitionPropertyName in fakeElement.style) return cssNames[i]; return null; })(); aspxCssAnimationTransition.CanUse = function () { return _aspxEnableCssAnimation && !!aspxCssAnimationTransition.CSS_TRANSITION; }; aspxPositionAnimationTransition = _aspxCreateClass(aspxAnimationTransitionBase, { constructor: function (element, options) { this.constructor.prototype.constructor.call(this, element, options); this.direction = options.direction; this.animationTransition = this.createAnimationTransition(); this.patchElement(); }, Start: function (to) { var from = this.GetValue(); if (aspxPositionAnimationTransition.CSS_TRANSFORM) { from = this.convertPosToCssTransformPos(from); to = this.convertPosToCssTransformPos(to); } this.animationTransition.Start(from, to); }, SetValue: function (value) { aspxPositionAnimationTransition.SetValue(this.element, value, this.direction == ASPxAnimationHelper.SLIDE_VERTICAL_DIRECTION); }, GetValue: function () { return aspxPositionAnimationTransition.GetValue(this.element, this.direction == ASPxAnimationHelper.SLIDE_VERTICAL_DIRECTION); }, createAnimationTransition: function () { var transition = aspxPositionAnimationTransition.CSS_TRANSFORM ? this.createTransformAnimationTransition() : this.createPositionAnimationTransition(); transition.transition = aspxAnimationTransitionBase.Transitions.POW_EASE_OUT; return transition; }, createTransformAnimationTransition: function () { return new aspxCssAnimationTransition(this.element, { property: aspxPositionAnimationTransition.CSS_TRANSFORM, duration: this.duration, onComplete: this.onComplete }); }, createPositionAnimationTransition: function () { return ASPxAnimationHelper.createAnimationTransition(this.element, { property: this.direction == ASPxAnimationHelper.SLIDE_VERTICAL_DIRECTION ? "top" : "left", unit: "px", duration: this.duration, onComplete: this.onComplete }); }, convertPosToCssTransformPos: function (position) { return aspxPositionAnimationTransition.GetCssTranslateText(position, this.direction == ASPxAnimationHelper.SLIDE_VERTICAL_DIRECTION); }, patchElement: function () { if (aspxPositionAnimationTransition.CSS_TRANSFORM && __aspxWebKitFamily && !_aspxElementHasCssClass(this.element, "dxTA")) this.element.className += " dxTA"; } }); aspxPositionAnimationTransition.GetCssTranslateText = function (position, top) { return "matrix(1, 0, 0, 1," + (!top ? position : 0) + ", " + (!top ? 0 : position) + ")"; }; aspxPositionAnimationTransition.GetValue = function (element, top) { if (aspxPositionAnimationTransition.CSS_TRANSFORM) { var cssValue = element.style[aspxPositionAnimationTransition.CSS_TRANSFORM]; return cssValue ? Number(cssValue.replace('matrix(1, 0, 0, 1,', '').replace(')', '').split(',')[!top ? 0 : 1]) : 0; } else return !top ? element.offsetLeft : element.offsetTop; }; aspxPositionAnimationTransition.SetValue = function (element, position, top) { if (aspxPositionAnimationTransition.CSS_TRANSFORM) element.style[aspxPositionAnimationTransition.CSS_TRANSFORM] = aspxPositionAnimationTransition.GetCssTranslateText(position, top); else element.style[!top ? "left" : "top"] = position + "px"; }; aspxPositionAnimationTransition.CSS_TRANSFORM = (function () { if (!aspxCssAnimationTransition.CanUse()) return null; var transformPropertiesNames = ["transform", "MozTransform", "-webkit-transform", "msTransform", "OTransform"]; var fakeElement = document.createElement("DIV"); for (var i = 0; i < transformPropertiesNames.length; i++) if (transformPropertiesNames[i] in fakeElement.style) return transformPropertiesNames[i]; return null; })(); var ASPxAnimationHelper = { SLIDE_HORIZONTAL_DIRECTION: 0, SLIDE_VERTICAL_DIRECTION: 1, SLIDE_TOP_DIRECTION: 0, SLIDE_RIGHT_DIRECTION: 1, SLIDE_BOTTOM_DIRECTION: 2, SLIDE_LEFT_DIRECTION: 3, SLIDE_CONTAINER_CLASS: "dxAC", MAXIMUM_DEPTH: 3, createAnimationTransition: function (element, options) { switch (options.animationEngine) { case "js": return new aspxJsAnimationTransition(element, options); break; case "css": return new aspxCssAnimationTransition(element, options); break; } return aspxCssAnimationTransition.CanUse() ? new aspxCssAnimationTransition(element, options) : new aspxJsAnimationTransition(element, options); }, createMultipleAnimationTransition: function (element, options) { return aspxCssAnimationTransition.CanUse() ? new aspxMultipleCssAnimationTransition(element, options) : new aspxMultipleJsAnimationTransition(element, options); }, cancelAnimation: function (element) { aspxAnimationTransitionBase.Cancel(element); }, fadeIn: function (element, onComplete) { ASPxAnimationHelper.fadeTo(element, { from: 0, to: 1, onComplete: onComplete, duration: aspxAnimationTransitionBase.Durations.DEFAULT }); }, fadeOut: function (element, onComplete) { ASPxAnimationHelper.fadeTo(element, { from: 1, to: 0, onComplete: onComplete, duration: aspxAnimationTransitionBase.Durations.DEFAULT }); }, fadeTo: function (element, options) { options.property = "opacity"; if (!options.duration) options.duration = aspxAnimationTransitionBase.Durations.SHORT; var transition = ASPxAnimationHelper.createAnimationTransition(element, options); if (!_aspxIsExists(options.from)) options.from = transition.GetValue(); transition.Start(options.from, options.to); }, slideIn: function (element, direction, onComplete) { ASPxAnimationHelper.setOpacity(element, 1); var animationContainer = ASPxAnimationHelper.getSlideAnimationContainer(element, true, true); var pos = ASPxAnimationHelper.getSlideInStartPos(animationContainer, direction); var transition = ASPxAnimationHelper.createSlideTransition(animationContainer, direction, function (el) { ASPxAnimationHelper.resetSlideAnimationContainerSize(animationContainer); if (onComplete) onComplete(el); }); transition.Start(pos, 0); }, slideOut: function (element, direction, onComplete) { var animationContainer = ASPxAnimationHelper.getSlideAnimationContainer(element, true, true); var pos = ASPxAnimationHelper.getSlideOutFinishPos(animationContainer, direction); var transition = ASPxAnimationHelper.createSlideTransition(animationContainer, direction, function (el) { ASPxAnimationHelper.setOpacity(el.firstChild, 0); if (onComplete) onComplete(el); }); transition.Start(pos); }, slideTo: function (element, options) { if (!_aspxIsExists(options.direction)) options.direction = ASPxAnimationHelper.SLIDE_HORIZONTAL_DIRECTION; var transition = new aspxPositionAnimationTransition(element, options); transition.Start(options.to); }, setOpacity: function (element, value) { if (__aspxIE && __aspxBrowserVersion < 8) element.style.zoom = 1; _aspxSetElementOpacity(element, value); }, findSlideAnimationContainer: function (element) { var container = element for (var i = 0; i < ASPxAnimationHelper.MAXIMUM_DEPTH; i++) { if (container.tagName == "BODY") return null; if (_aspxElementHasCssClass(container, ASPxAnimationHelper.SLIDE_CONTAINER_CLASS)) return container; container = container.parentNode; } return null; }, createSlideAnimationContainer: function (element) { var rootContainer = document.createElement("DIV"); _aspxSetStyles(rootContainer, { className: ASPxAnimationHelper.SLIDE_CONTAINER_CLASS, overflow: "hidden" }); var elementContainer = document.createElement("DIV"); rootContainer.appendChild(elementContainer); var parentNode = element.parentNode; parentNode.insertBefore(rootContainer, element); elementContainer.appendChild(element); return rootContainer; }, getSlideAnimationContainer: function (element, create, fixSize) { if(!element) return; var width = element.offsetWidth; var height = element.offsetHeight; var container; if (element.className == ASPxAnimationHelper.SLIDE_CONTAINER_CLASS) container = element; if(!container) container = ASPxAnimationHelper.findSlideAnimationContainer(element); if(!container && create) container = ASPxAnimationHelper.createSlideAnimationContainer(element); if (container && fixSize) { _aspxSetStyles(container, { width: width, height: height }); _aspxSetStyles(container.firstChild, { width: width, height: height }); } return container; }, resetSlideAnimationContainerSize: function (container) { _aspxSetStyles(container, { width: "", height: "" }); _aspxSetStyles(container.firstChild, { width: "", height: "" }); }, getModifyProperty: function (direction) { if (direction == ASPxAnimationHelper.SLIDE_TOP_DIRECTION || direction == ASPxAnimationHelper.SLIDE_BOTTOM_DIRECTION) return "marginTop"; return "marginLeft"; }, createSlideTransition: function (animationContainer, direction, complete) { return ASPxAnimationHelper.createAnimationTransition(animationContainer.firstChild, { unit: "px", property: ASPxAnimationHelper.getModifyProperty(direction), onComplete: complete }); }, getSlideInStartPos: function (animationContainer, direction) { switch(direction) { case ASPxAnimationHelper.SLIDE_TOP_DIRECTION: return animationContainer.offsetHeight; case ASPxAnimationHelper.SLIDE_LEFT_DIRECTION: return animationContainer.offsetWidth; case ASPxAnimationHelper.SLIDE_RIGHT_DIRECTION: return -animationContainer.offsetWidth; case ASPxAnimationHelper.SLIDE_BOTTOM_DIRECTION: return -animationContainer.offsetHeight; } }, getSlideOutFinishPos: function (animationContainer, direction) { switch (direction) { case ASPxAnimationHelper.SLIDE_TOP_DIRECTION: return -animationContainer.offsetHeight; case ASPxAnimationHelper.SLIDE_LEFT_DIRECTION: return -animationContainer.offsetWidth; case ASPxAnimationHelper.SLIDE_RIGHT_DIRECTION: return animationContainer.offsetWidth; case ASPxAnimationHelper.SLIDE_BOTTOM_DIRECTION: return animationContainer.offsetHeight; } } }; var ASPxGesturesHelper = { handlers: {}, activeHandler: null, isAttachedEvents: false, isExecutedGesture: false, AddSwipeGestureHandler: function(id, getAnimationElement, canHandle, allowStart, start, allowComplete, complete, cancel) { this.handlers[id] = new ASPxSwipeGestureHandler(getAnimationElement, canHandle, allowStart, start, allowComplete, complete, cancel); }, UpdateSwipeAnimationContainer: function (id) { if (this.handlers[id]) this.handlers[id].UpdateAnimationContainer(); }, AddSwipeSlideGestureHandler: function (id, getAnimationElement, direction, canHandle, backward, forward, rollback) { this.handlers[id] = new ASPxSwipeSlideGestureHandler(getAnimationElement, direction, canHandle, backward, forward, rollback); }, OnDocumentMouseDown: function(evt) { if (!_aspxGetIsLeftButtonPressed(evt)) return; ASPxGesturesHelper.activeHandler = ASPxGesturesHelper.FindHandler(evt); if(ASPxGesturesHelper.activeHandler) ASPxGesturesHelper.activeHandler.OnMouseDown(evt); }, OnDocumentMouseMove: function(evt) { if (ASPxGesturesHelper.activeHandler) { ASPxGesturesHelper.isExecutedGesture = true; ASPxGesturesHelper.activeHandler.OnMouseMove(evt); } }, OnDocumentMouseUp: function(evt) { if (ASPxGesturesHelper.activeHandler) { ASPxGesturesHelper.activeHandler.OnMouseUp(evt); ASPxGesturesHelper.activeHandler = null; _aspxSetTimeout(function () { ASPxGesturesHelper.isExecutedGesture = false; }, 0); } }, AttachEvents: function() { if(!ASPxGesturesHelper.isAttachedEvents) { ASPxGesturesHelper.Attach(_aspxAttachEventToElement); ASPxGesturesHelper.isAttachedEvents = true; } }, DetachEvents: function() { if(ASPxGesturesHelper.isAttachedEvents) { ASPxGesturesHelper.Attach(_aspxDetachEventFromElement); ASPxGesturesHelper.isAttachedEvents = false; } }, Attach: function(changeEventsMethod) { changeEventsMethod(window.document, ASPxClientTouchUI.touchMouseDownEventName, ASPxGesturesHelper.OnDocumentMouseDown); changeEventsMethod(window.document, ASPxClientTouchUI.touchMouseMoveEventName, ASPxGesturesHelper.OnDocumentMouseMove); changeEventsMethod(window.document, ASPxClientTouchUI.touchMouseUpEventName, ASPxGesturesHelper.OnDocumentMouseUp); }, FindHandler: function (evt) { var handlers = []; for (var id in ASPxGesturesHelper.handlers) { var handler = ASPxGesturesHelper.handlers[id]; if(handler.CanHandleEvent(evt)) handlers.push(handler); } if (!handlers.length) return null; handlers.sort(function (a, b) { return _aspxGetIsParent(a.getAnimationElement(), b.getAnimationElement()) ? 1 : -1; }); return handlers[0]; }, IsExecutedGesture: function () { return ASPxGesturesHelper.isExecutedGesture; } }; ASPxGesturesHelper.AttachEvents(); ASPxGestureHandler = _aspxCreateClass(null, { constructor: function (getAnimationElement, canHandle, allowStart) { this.getAnimationElement = getAnimationElement; this.canHandle = canHandle; this.allowStart = allowStart; this.startMousePosX = 0; this.startMousePosY = 0; this.startTime = null; this.savedElements = []; }, OnMouseDown: function (evt) { if (!__aspxTouchUI && !this.IsTextElement(evt)) _aspxPreventEvent(evt); this.startMousePosX = _aspxGetEventX(evt); this.startMousePosY = _aspxGetEventY(evt); this.startTime = new Date(); }, OnMouseMove: function (evt) { if (!__aspxTouchUI) _aspxClearSelection(); if (Math.abs(this.GetCurrentDistanceX(evt)) < ASPxGestureHandler.SLIDER_MIN_START_DISTANCE && Math.abs(this.GetCurrentDistanceY(evt)) < ASPxGestureHandler.SLIDER_MIN_START_DISTANCE) ASPxGesturesHelper.isExecutedGesture = false; }, OnMouseUp: function (evt) { }, CanHandleEvent: function (evt) { return !this.canHandle || this.canHandle(evt); }, IsStartAllowed: function (value) { return !this.allowStart || this.allowStart(value); }, RollbackGesture: function () { }, GetRubberPosition: function (position) { return position / ASPxGestureHandler.FACTOR_RUBBER; }, GetCurrentDistanceX: function (evt) { return _aspxGetEventX(evt) - this.startMousePosX; }, GetCurrentDistanceY: function (evt) { return _aspxGetEventY(evt) - this.startMousePosY; }, GetDistanceLimit: function () { return (new Date() - this.startTime) < ASPxGestureHandler.MAX_TIME_SPAN ? ASPxGestureHandler.MIN_DISTANCE_LIMIT : ASPxGestureHandler.MAX_DISTANCE_LIMIT; }, IsTextElement: function (evt) { var element = _aspxGetEventSource(evt); return element.tagName == "TEXTAREA" || element.tagName == "INPUT" && _aspxGetAttribute(element, "type") == "text"; }, GetContainerElement: function () { }, AttachPreventEvents: function (evt) { var element = _aspxGetEventSource(evt); var container = this.GetContainerElement(); while (element && element != container) { _aspxAttachEventToElement(element, "mouseup", this.PreventEvent); _aspxAttachEventToElement(element, "click", this.PreventEvent); this.savedElements.push(element); element = element.parentNode; } }, DetachPreventEvents: function () { _aspxSetTimeout(function () { while (this.savedElements.length > 0) { var element = this.savedElements.pop(); _aspxDetachEventFromElement(element, "mouseup", this.PreventEvent); _aspxDetachEventFromElement(element, "click", this.PreventEvent); } }.aspxBind(this), 0); }, PreventEvent: function (evt) { return _aspxPreventEvent(evt); } }); ASPxGestureHandler.MAX_DISTANCE_LIMIT = 70; ASPxGestureHandler.MIN_DISTANCE_LIMIT = 10; ASPxGestureHandler.MIN_START_DISTANCE = 0; ASPxGestureHandler.SLIDER_MIN_START_DISTANCE = 5; ASPxGestureHandler.MAX_TIME_SPAN = 300; ASPxGestureHandler.FACTOR_RUBBER = 4; ASPxGestureHandler.RETURN_ANIMATION_DURATION = 150; ASPxSwipeSlideGestureHandler = _aspxCreateClass(ASPxGestureHandler, { constructor: function (getAnimationElement, direction, canHandle, backward, forward, rollback) { this.constructor.prototype.constructor.call(this, getAnimationElement, canHandle); this.slideElement = this.getAnimationElement(); this.container = this.slideElement.parentNode; this.direction = direction; this.backward = backward; this.forward = forward; this.rollback = rollback; this.slideElementSize = 0; this.containerElementSize = 0; this.startSliderElementPosition = 0; this.centeredSlideElementPosition = 0; this.isAttachedPreventEvents = false; }, OnMouseDown: function (evt) { ASPxGestureHandler.prototype.OnMouseDown.call(this, evt); this.slideElementSize = this.GetElementSize(); this.startSliderElementPosition = this.GetElementPosition(); this.containerElementSize = this.GetContainerElementSize(); if (this.slideElementSize <= this.containerElementSize) this.centeredSlideElementPosition = (this.containerElementSize - this.slideElementSize) / 2; }, OnMouseMove: function (evt) { ASPxGestureHandler.prototype.OnMouseMove.call(this, evt); if (!__aspxTouchUI && !_aspxGetIsParent(this.container, _aspxGetEventSource(evt))) { ASPxGesturesHelper.OnDocumentMouseUp(evt); return; } var distance = this.GetCurrentDistance(evt); if (Math.abs(distance) < ASPxGestureHandler.SLIDER_MIN_START_DISTANCE || ASPxClientTouchUI.isGesture) return; aspxAnimationTransitionBase.Cancel(this.slideElement); var position = this.startSliderElementPosition + distance, maxPosition = -(this.slideElementSize - this.containerElementSize), minPosition = 0; if (this.centeredSlideElementPosition > 0) position = this.GetRubberPosition(distance) + this.centeredSlideElementPosition; else if (position > minPosition) position = this.GetRubberPosition(distance); else if (position < maxPosition) position = this.GetRubberPosition(distance) + maxPosition; this.SetElementPosition(position); this.AttachPreventEvents(evt); return _aspxPreventEvent(evt); }, OnMouseUp: function (evt) { this.DetachPreventEvents(); var distance = this.GetCurrentDistance(evt); if (distance == 0) return; else if (this.centeredSlideElementPosition > 0 || this.CheckSlidePanelIsOutOfBounds()) this.PerformRollback(); else { if (Math.abs(distance) < this.GetDistanceLimit()) this.PerformRollback(); else if (distance < 0) this.PerformForward(); else this.PerformBackward(); } }, PerformBackward: function () { this.backward(); }, PerformForward: function () { this.forward(); }, PerformRollback: function () { this.rollback(); }, CheckSlidePanelIsOutOfBounds: function () { var minOffset = -(this.slideElementSize - this.containerElementSize), maxOffset = 0; var position = null, slideElementPos = this.GetElementPosition(); if (slideElementPos > maxOffset || slideElementPos < minOffset) return true; return false; }, GetContainerElement: function () { return this.container; }, GetElementSize: function () { return this.IsHorizontalDirection() ? this.slideElement.offsetWidth : this.slideElement.offsetHeight; }, GetContainerElementSize: function () { return this.IsHorizontalDirection() ? _aspxGetClearClientWidth(this.container) : _aspxGetClearClientHeight(this.container); }, GetCurrentDistance: function (evt) { return this.IsHorizontalDirection() ? this.GetCurrentDistanceX(evt) : this.GetCurrentDistanceY(evt); }, GetElementPosition: function () { return aspxPositionAnimationTransition.GetValue(this.slideElement, !this.IsHorizontalDirection()); }, SetElementPosition: function (position) { aspxPositionAnimationTransition.SetValue(this.slideElement, position, !this.IsHorizontalDirection()); }, IsHorizontalDirection: function () { return this.direction == ASPxAnimationHelper.SLIDE_HORIZONTAL_DIRECTION; }, AttachPreventEvents: function (evt) { if (!this.isAttachedPreventEvents) { ASPxGestureHandler.prototype.AttachPreventEvents.call(this, evt); this.isAttachedPreventEvents = true; } }, DetachPreventEvents: function () { if (this.isAttachedPreventEvents) { ASPxGestureHandler.prototype.DetachPreventEvents.call(this); this.isAttachedPreventEvents = false; } } }); ASPxSwipeGestureHandler = _aspxCreateClass(ASPxGestureHandler, { constructor: function (getAnimationElement, canHandle, allowStart, start, allowComplete, complete, cancel) { this.constructor.prototype.constructor.call(this, getAnimationElement, canHandle, allowStart); this.start = start; this.allowComplete = allowComplete; this.complete = complete; this.cancel = cancel; this.animationTween = null; this.currentDistanceX = 0; this.currentDistanceY = 0; this.tryStartGesture = false; this.tryStartScrolling = false; this.UpdateAnimationContainer(); }, UpdateAnimationContainer: function () { this.animationContainer = ASPxAnimationHelper.getSlideAnimationContainer(this.getAnimationElement(), true, false); }, CanHandleEvent: function(evt) { if(ASPxGestureHandler.prototype.CanHandleEvent.call(this, evt)) return true; return this.animationTween && this.animationContainer && _aspxGetIsParent(this.animationContainer, _aspxGetEventSource(evt)); }, OnMouseDown: function (evt) { ASPxGestureHandler.prototype.OnMouseDown.call(this, evt); if(this.animationTween) this.animationTween.Cancel(); this.currentDistanceX = 0; this.currentDistanceY = 0; this.tryStartGesture = false; this.tryStartScrolling = false; }, OnMouseMove: function (evt) { ASPxGestureHandler.prototype.OnMouseMove.call(this, evt); this.currentDistanceX = this.GetCurrentDistanceX(evt); this.currentDistanceY = this.GetCurrentDistanceY(evt); if (!this.animationTween && !this.tryStartScrolling && (Math.abs(this.currentDistanceX) > ASPxGestureHandler.MIN_START_DISTANCE || Math.abs(this.currentDistanceY) > ASPxGestureHandler.MIN_START_DISTANCE)) { if(Math.abs(this.currentDistanceY) < Math.abs(this.currentDistanceX)) { this.tryStartGesture = true; if(this.IsStartAllowed(this.currentDistanceX)) { this.animationContainer = ASPxAnimationHelper.getSlideAnimationContainer(this.getAnimationElement(), true, true); this.animationTween = ASPxAnimationHelper.createSlideTransition(this.animationContainer, ASPxAnimationHelper.SLIDE_LEFT_DIRECTION, function() { ASPxAnimationHelper.resetSlideAnimationContainerSize(this.animationContainer); this.animationContainer = null; this.animationTween = null; }.aspxBind(this)); this.PerformStart(this.currentDistanceX); this.AttachPreventEvents(evt); } } else this.tryStartScrolling = true; } if(this.animationTween) { if(this.allowComplete && !this.allowComplete(this.currentDistanceX)) this.currentDistanceX = this.GetRubberPosition(this.currentDistanceX); this.animationTween.SetValue(this.currentDistanceX); } if(!this.tryStartScrolling && !ASPxClientTouchUI.isGesture && evt.touches && evt.touches.length < 2) _aspxPreventEvent(evt); }, OnMouseUp: function(evt) { if(!this.animationTween) { if(this.tryStartGesture) this.PerformCancel(this.currentDistanceX); } else{ if(Math.abs(this.currentDistanceX) < this.GetDistanceLimit()) this.RollbackGesture(); else { if(this.IsCompleteAllowed(this.currentDistanceX)) { this.PerformComplete(this.currentDistanceX); this.animationContainer = null; this.animationTween = null; } else this.RollbackGesture(); } } this.DetachPreventEvents(); this.tryStartGesture = false; this.tryStartScrolling = false; }, PerformStart: function(value) { if(this.start) this.start(value); }, IsCompleteAllowed: function(value) { return !this.allowComplete || this.allowComplete(value); }, PerformComplete: function(value) { if(this.complete) this.complete(value); }, PerformCancel: function(value) { if(this.cancel) this.cancel(value); }, RollbackGesture: function() { this.animationTween.Start(this.currentDistanceX, 0); }, GetContainerElement: function () { return this.animationContainer; } });