summaryrefslogtreecommitdiffstats
path: root/js/yui3/scrollview-base/scrollview-base-min.js
blob: d867305427131a719d212b1d63ee335be1fb0840 (plain)
1
2
3
4
5
6
7
8
9
/*
YUI 3.17.2 (build 9c3c78e)
Copyright 2014 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/

YUI.add("scrollview-base",function(e,t){function F(){F.superclass.constructor.apply(this,arguments)}var n=e.ClassNameManager.getClassName,r=e.config.doc,i=e.UA.ie,s=e.Transition.useNative,o=e.Transition._VENDOR_PREFIX,u="scrollview",a={vertical:n(u,"vert"),horizontal:n(u,"horiz")},f="scrollEnd",l="flick",c="drag",h="mousewheel",p="ui",d="top",v="left",m="px",g="axis",y="scrollY",b="scrollX",w="bounce",E="disabled",S="deceleration",x="x",T="y",N="boundingBox",C="contentBox",k="gesturemove",L="start",A="end",O="",M="0s",_="snapDuration",D="snapEasing",P="easing",H="frameDuration",B="bounceRange",j=function(e,t,n){return Math.min(Math.max(e,t),n)};e.ScrollView=e.extend(F,e.Widget,{_forceHWTransforms:e.UA.webkit?!0:!1,_prevent:{start:!1,move:!0,end:!1},lastScrolledAmt:0,_minScrollX:null,_maxScrollX:null,_minScrollY:null,_maxScrollY:null,initializer:function(){var e=this;e._bb=e.get(N),e._cb=e.get(C),e._cAxis=e.get(g),e._cBounce=e.get(w),e._cBounceRange=e.get(B),e._cDeceleration=e.get(S),e._cFrameDuration=e.get(H)},bindUI:function(){var e=this;e._bindFlick(e.get(l)),e._bindDrag(e.get(c)),e._bindMousewheel(!0),e._bindAttrs(),i&&e._fixIESelect(e._bb,e._cb),F.SNAP_DURATION&&e.set(_,F.SNAP_DURATION),F.SNAP_EASING&&e.set(D,F.SNAP_EASING),F.EASING&&e.set(P,F.EASING),F.FRAME_STEP&&e.set(H,F.FRAME_STEP),F.BOUNCE_RANGE&&e.set(B,F.BOUNCE_RANGE)},_bindAttrs:function(){var e=this,t=e._afterScrollChange,n=e._afterDimChange;e.after({scrollEnd:e._afterScrollEnd,disabledChange:e._afterDisabledChange,flickChange:e._afterFlickChange,dragChange:e._afterDragChange,axisChange:e._afterAxisChange,scrollYChange:t,scrollXChange:t,heightChange:n,widthChange:n})},_bindDrag:function(t){var n=this,r=n._bb;r.detach(c+"|*"),t&&r.on(c+"|"+k+L,e.bind(n._onGestureMoveStart,n))},_bindFlick:function(t){var n=this,r=n._bb;r.detach(l+"|*"),t&&(r.on(l+"|"+l,e.bind(n._flick,n),t),n._bindDrag(n.get(c)))},_bindMousewheel:function(t){var n=this,i=n._bb;i.detach(h+"|*"),t&&e.one(r).on(h,e.bind(n._mousewheel,n))},syncUI:function(){var e=this,t=e._getScrollDims(),n=t.offsetWidth,r=t.offsetHeight,i=t.scrollWidth,s=t.scrollHeight;e._cAxis===undefined&&(e._cAxis={x:i>n,y:s>r},e._set(g,e._cAxis)),e.rtl=e._cb.getComputedStyle("direction")==="rtl",e._cDisabled=e.get(E),e._uiDimensionsChange(),e._isOutOfBounds()&&e._snapBack()},_getScrollDims:function(){var e=this,t=e._cb,n=e._bb,r=F._TRANSITION,i=e.get(b),o=e.get(y),u,a;return s&&(t.setStyle(r.DURATION,M),t.setStyle(r.PROPERTY,O)),u=e._forceHWTransforms,e._forceHWTransforms=!1,e._moveTo(t,0,0),a={offsetWidth:n.get("offsetWidth"),offsetHeight:n.get("offsetHeight"),scrollWidth:n.get("scrollWidth"),scrollHeight:n.get("scrollHeight")},e._moveTo(t,-i,-o),e._forceHWTransforms=u,a},_uiDimensionsChange:function(){var e=this,t=e._bb,n=e._getScrollDims(),r=n.offsetWidth,i=n.offsetHeight,s=n.scrollWidth,o=n.scrollHeight,u=e.rtl,f=e._cAxis,l=u?Math.min(0,-(s-r)):0,c=u?0:Math.max(0,s-r),h=0,p=Math.max(0,o-i);f&&f.x&&t.addClass(a.horizontal),f&&f.y&&t.addClass(a.vertical),e._setBounds({minScrollX:l,maxScrollX:c,minScrollY:h,maxScrollY:p})},_setBounds:function(e){var t=this;t._minScrollX=e.minScrollX,t._maxScrollX=e.maxScrollX,t._minScrollY=e.minScrollY,t._maxScrollY=e.maxScrollY},_getBounds:function(){var e=this;return{minScrollX:e._minScrollX,maxScrollX:e._maxScrollX,minScrollY:e._minScrollY,maxScrollY:e._maxScrollY}},scrollTo:function(t,n,r,i,o){if(this._cDisabled)return;var u=this,a=u._cb,f=F._TRANSITION,l=e.bind(u._onTransEnd,u),c=0,h=0,g={},w;r=r||0,i=i||u.get(P),o=o||a,t!==null&&(u.set(b,t,{src:p}),c=-t),n!==null&&(u.set(y,n,{src:p}),h=-n),w=u._transform(c,h),s&&o.setStyle(f.DURATION,M).setStyle(f.PROPERTY,O),r===0?s?o.setStyle("transform",w):(t!==null&&o.setStyle(v,c+m),n!==null&&o.setStyle(d,h+m)):(g.easing=i,g.duration=r/1e3,s?g.transform=w:(g.left=c+m,g.top=h+m),o.transition(g,l))},_transform:function(e,t){var n="translate("+e+"px, "+t+"px)";return this._forceHWTransforms&&(n+=" translateZ(0)"),n},_moveTo:function(e,t,n){s?e.setStyle("transform",this._transform(t,n)):(e.setStyle(v,t+m),e.setStyle(d,n+m))},_onTransEnd:function(){var e=this;e._isOutOfBounds()?e._snapBack():e.fire(f)},_onGestureMoveStart:function(t){if(this._cDisabled)return!1;var n=this,r=n._bb,i=n.get(b),s=n.get(y),o=t.clientX,u=t.clientY;n._prevent.start&&t.preventDefault(),n._flickAnim&&(n._cancelFlick(),n._onTransEnd()),n.lastScrolledAmt=0,n._gesture={axis:null,startX:i,startY:s,startClientX:o,startClientY:u,endClientX:null,endClientY:null,deltaX:null,deltaY:null,flick:null,onGestureMove:r.on(c+"|"+k,e.bind(n._onGestureMove,n)),onGestureMoveEnd:r.on(c+"|"+k+A,e.bind(n._onGestureMoveEnd,n))}},_onGestureMove:function(e){var t=this,n=t._gesture,r=t._cAxis,i=r.x,s=r.y,o=n.startX,u=n.startY,a=n.startClientX,f=n.startClientY,l=e.clientX,c=e.clientY;t._prevent.move&&e.preventDefault(),n.deltaX=a-l,n.deltaY=f-c,n.axis===null&&(n.axis=Math.abs(n.deltaX)>Math.abs(n.deltaY)?x:T),n.axis===x&&i?t.set(b,o+n.deltaX):n.axis===T&&s&&t.set(y,u+n.deltaY)},_onGestureMoveEnd:function(e){var t=this,n=t._gesture,r=n.flick,i=e.clientX,s=e.clientY,o;t._prevent.end&&e.preventDefault(),n.endClientX=i,n.endClientY=s,n.onGestureMove.detach(),n.onGestureMoveEnd.detach(),r||n.deltaX!==null&&n.deltaY!==null&&(o=t._isOutOfBounds(),o?t._snapBack():(!t.pages||t.pages&&!t.pages.get(g)[n.axis])&&t._onTransEnd())},_flick:function(e){if(this._cDisabled)return!1;var t=this,n=t._cAxis,r=e.flick,i=r.axis,s=r.velocity,o=i===x?b:y,u=t.get(o);t._gesture&&(t._gesture.flick=r),n[i]&&t._flickFrame(s,i,u)},_flickFrame:function(t,n,r){var i=this,s=n===x?b:y,o=i._getBounds(),u=i._cBounce,a=i._cBounceRange,f=i._cDeceleration,l=i._cFrameDuration,c=t*f,h=r-l*c,p=n===x?o.minScrollX:o.minScrollY,d=n===x?o.maxScrollX:o.maxScrollY,v=h<p,m=h<d,g=h>p,w=h>d,E=h<p-a,S=v&&h>p-a,T=w&&h<d+a,N=h>d+a,C;if(S||T)c*=u;C=Math.abs(c).toFixed(4)<.015,C||E||N?(i._flickAnim&&i._cancelFlick(),g&&m?i._onTransEnd():i._snapBack()):(i._flickAnim=e.later(l,i,"_flickFrame",[c,n,h]),i.set(s,h))},_cancelFlick:function(
){var e=this;e._flickAnim&&(e._flickAnim.cancel(),delete e._flickAnim)},_mousewheel:function(e){var t=this,n=t.get(y),r=t._getBounds(),i=t._bb,s=10,o=e.wheelDelta>0,u=n-(o?1:-1)*s;u=j(u,r.minScrollY,r.maxScrollY),i.contains(e.target)&&t._cAxis[T]&&(t.lastScrolledAmt=0,t.set(y,u),t.scrollbars&&(t.scrollbars._update(),t.scrollbars.flash()),t._onTransEnd(),e.preventDefault())},_isOutOfBounds:function(e,t){var n=this,r=n._cAxis,i=r.x,s=r.y,o=e||n.get(b),u=t||n.get(y),a=n._getBounds(),f=a.minScrollX,l=a.minScrollY,c=a.maxScrollX,h=a.maxScrollY;return i&&(o<f||o>c)||s&&(u<l||u>h)},_snapBack:function(){var e=this,t=e.get(b),n=e.get(y),r=e._getBounds(),i=r.minScrollX,s=r.minScrollY,o=r.maxScrollX,u=r.maxScrollY,a=j(n,s,u),f=j(t,i,o),l=e.get(_),c=e.get(D);f!==t?e.set(b,f,{duration:l,easing:c}):a!==n?e.set(y,a,{duration:l,easing:c}):e._onTransEnd()},_afterScrollChange:function(e){if(e.src===F.UI_SRC)return!1;var t=this,n=e.duration,r=e.easing,i=e.newVal,s=[];t.lastScrolledAmt=t.lastScrolledAmt+(e.newVal-e.prevVal),e.attrName===b?(s.push(i),s.push(t.get(y))):(s.push(t.get(b)),s.push(i)),s.push(n),s.push(r),t.scrollTo.apply(t,s)},_afterFlickChange:function(e){this._bindFlick(e.newVal)},_afterDisabledChange:function(e){this._cDisabled=e.newVal},_afterAxisChange:function(e){this._cAxis=e.newVal},_afterDragChange:function(e){this._bindDrag(e.newVal)},_afterDimChange:function(){this._uiDimensionsChange()},_afterScrollEnd:function(){var e=this;e._flickAnim&&e._cancelFlick()},_axisSetter:function(t){if(e.Lang.isString(t))return{x:t.match(/x/i)?!0:!1,y:t.match(/y/i)?!0:!1}},_setScroll:function(t){return this._cDisabled&&(t=e.Attribute.INVALID_VALUE),t},_setScrollX:function(e){return this._setScroll(e,x)},_setScrollY:function(e){return this._setScroll(e,T)}},{NAME:"scrollview",ATTRS:{axis:{setter:"_axisSetter",writeOnce:"initOnly"},scrollX:{value:0,setter:"_setScrollX"},scrollY:{value:0,setter:"_setScrollY"},deceleration:{value:.93},bounce:{value:.1},flick:{value:{minDistance:10,minVelocity:.3}},drag:{value:!0},snapDuration:{value:400},snapEasing:{value:"ease-out"},easing:{value:"cubic-bezier(0, 0.1, 0, 1.0)"},frameDuration:{value:15},bounceRange:{value:150}},CLASS_NAMES:a,UI_SRC:p,_TRANSITION:{DURATION:o?o+"TransitionDuration":"transitionDuration",PROPERTY:o?o+"TransitionProperty":"transitionProperty"},BOUNCE_RANGE:!1,FRAME_STEP:!1,EASING:!1,SNAP_EASING:!1,SNAP_DURATION:!1})},"3.17.2",{requires:["widget","event-gestures","event-mousewheel","transition"],skinnable:!0});