Created
March 7, 2011 18:52
-
-
Save sdesai/858976 to your computer and use it in GitHub Desktop.
Force Axis, without _uiDimChange calcs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YUI({filter:"raw"}).use('dump', 'scrollview-base', function(Y) { | |
// Workaround, need to roll support for "axis" into out-of-the-box product | |
Y.ScrollView.prototype._uiDimensionsChange = function() { | |
var sv = this, | |
bb = sv._bb, | |
CLASS_NAMES = Y.ScrollView.CLASS_NAMES, | |
height = sv.get('height'), | |
width = sv.get('width'), | |
// Use bb instead of cb. cb doesn't gives us the right results | |
// in FF (due to overflow:hidden) | |
scrollHeight = bb.get('scrollHeight'), | |
scrollWidth = bb.get('scrollWidth'); | |
if (this.get("axis") === "vertical" || (height && scrollHeight > height)) { | |
sv._scrollsVertical = true; | |
sv._maxScrollY = scrollHeight - height; | |
sv._minScrollY = 0; | |
sv._scrollHeight = scrollHeight; | |
bb.addClass(CLASS_NAMES.vertical); | |
} | |
if (this.get("axis") === "horizontal" || (width && scrollWidth > width)) { | |
sv._scrollsHorizontal = true; | |
sv._maxScrollX = scrollWidth - width; | |
sv._minScrollX = 0; | |
sv._scrollWidth = scrollWidth; | |
bb.addClass(CLASS_NAMES.horizontal); | |
} | |
}; | |
Y.ScrollView.ATTRS.axis = {value:null} | |
// End Workaround | |
var scrollView = new Y.ScrollView({ | |
contentBox: '#scrollable', | |
width: 320, | |
axis: "horizontal" | |
}); | |
scrollView.render(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment