Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 4.44 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.     /**
  2.      * Utility method to obtain scrollWidth, scrollHeight,
  3.      * accounting for the impact of translate on scrollWidth, scrollHeight
  4.      * @method _getScrollDims
  5.      * @returns {Array} The scrollWidth and scrollHeight as an array: [scrollWidth, scrollHeight]
  6.      * @private
  7.      */
  8.     _getScrollDims: function() {
  9.         var dims,
  10.             matrix,
  11.             origX,
  12.             origY,
  13.  
  14.             cb = this.get("contentBox"),
  15.             bb = this.get("boundingBox");
  16.  
  17.         if (NATIVE_TRANSITIONS) {
  18.  
  19.             // TOD: Is this OK? Just in case it's called 'during' a transition.
  20.             cb.setStyle(TRANS.DURATION, ZERO);
  21.             cb.setStyle(TRANS.PROPERTY, EMPTY);
  22.  
  23.             // Ideally using CSSMatrix - don't think we have it normalized yet though.
  24.             // origX = (new WebKitCSSMatrix(cb.getComputedStyle("transform"))).e;
  25.             // origY = (new WebKitCSSMatrix(cb.getComputedStyle("transform"))).f;
  26.  
  27.             origX = this.get(SCROLL_X);
  28.             origY = this.get(SCROLL_Y);
  29.  
  30.             cb.setStyle('transform', this._transform(0, 0));
  31.         }
  32.  
  33.         // Use bb instead of cb. cb doesn't gives us the right results in FF (due to overflow:hidden)
  34.         dims = [bb.get('scrollWidth'), bb.get('scrollHeight')];
  35.  
  36.         if (NATIVE_TRANSITIONS) {
  37.             cb.setStyle('transform', this._transform(origX, origY));
  38.         }
  39.  
  40.         return dims;
  41.     }
  42.  
  43.     /**
  44.      * This method gets invoked whenever the height or width attributes change,
  45.      * allowing us to determine which scrolling axes need to be enabled.
  46.      *
  47.      * @method _uiDimensionsChange
  48.      * @protected
  49.      */
  50.     _uiDimensionsChange: function() {
  51.  
  52.         var sv = this,
  53.             bb = sv._bb,
  54.  
  55.             CLASS_NAMES = ScrollView.CLASS_NAMES,
  56.  
  57.             width = bb.get('offsetWidth'),
  58.             height = bb.get('offsetHeight'),
  59.  
  60.             scrollDims = this._getScrollDims(),
  61.  
  62.             scrollWidth = scrollDims[0],
  63.             scrollHeight = scrollDims[1];
  64.  
  65.         if (height && scrollHeight > height) {
  66.             sv._scrollsVertical = true;
  67.             sv._maxScrollY = scrollHeight - height;
  68.             sv._minScrollY = 0;
  69.             sv._scrollHeight = scrollHeight;
  70.             bb.addClass(CLASS_NAMES.vertical);
  71.         }
  72.         /* else {
  73.             sv._scrollsVertical = false;
  74.             sv._minScrollY = 0,
  75.             sv._maxScrollY = height;
  76.         }*/
  77.  
  78.         if (width && scrollWidth > width) {
  79.             sv._scrollsHorizontal = true;
  80.             sv._maxScrollX = scrollWidth - width;
  81.             sv._minScrollX = 0;
  82.             sv._scrollWidth = scrollWidth;
  83.             bb.addClass(CLASS_NAMES.horizontal);
  84.         }
  85.         /* else {
  86.             sv._scrollsHorizontal = false;
  87.             sv._minScrollX = 0,
  88.             sv._maxScrollX = width;
  89.         }
  90.         */
  91.  
  92.         /**
  93.          * Internal state, defines whether or not the scrollview can scroll vertically
  94.          *
  95.          * @property _scrollsVertical
  96.          * @type boolean
  97.          * @protected
  98.          */
  99.        
  100.         /**
  101.          * Internal state, defines the maximum amount that the scrollview can be scrolled along the Y axis
  102.          *
  103.          * @property _maxScrollY
  104.          * @type number
  105.          * @protected
  106.          */
  107.  
  108.         /**
  109.          * Internal state, defines the minimum amount that the scrollview can be scrolled along the Y axis
  110.          *
  111.          * @property _minScrollY
  112.          * @type number
  113.          * @protected
  114.          */
  115.  
  116.         /**
  117.          * Internal state, cached scrollHeight, for performance
  118.          *
  119.          * @property _scrollHeight
  120.          * @type number
  121.          * @protected
  122.          */
  123.  
  124.         /**
  125.          * Internal state, defines whether or not the scrollview can scroll horizontally
  126.          *
  127.          * @property _scrollsHorizontal
  128.          * @type boolean
  129.          * @protected
  130.          */
  131.        
  132.         /**
  133.          * Internal state, defines the maximum amount that the scrollview can be scrolled along the X axis
  134.          *
  135.          * @property _maxScrollX
  136.          * @type number
  137.          * @protected
  138.          */
  139.  
  140.         /**
  141.          * Internal state, defines the minimum amount that the scrollview can be scrolled along the X axis
  142.          *
  143.          * @property _minScrollX
  144.          * @type number
  145.          * @protected
  146.          */
  147.  
  148.         /**
  149.          * Internal state, cached scrollWidth, for performance
  150.          *
  151.          * @property _scrollWidth
  152.          * @type number
  153.          * @protected
  154.          */
  155.     },