Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Created May 18, 2012 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterdavis/114588cdb07c3b534910 to your computer and use it in GitHub Desktop.
Save walterdavis/114588cdb07c3b534910 to your computer and use it in GitHub Desktop.
Script.aculo.us Scroll Area with iOS Compatibility
var inner = $('innerDiv'); //change innerDiv to whatever your inner box is called
var thumb = $('thumb'); //change thumb to whatever your slider control is called
var track = $('track'); //change track to whatever your slider track is called
//testing for WebKit on a mobile device
var ua = navigator.userAgent, mobile = false;
if( ua.match(/WebKit/i) && (
ua.match(/Android/i) ||
ua.match(/webOS/i) ||
ua.match(/Blackberry/i))
){
mobile = true;
}
if(Prototype.Browser.MobileSafari || mobile){
inner.setStyle('position:relative;');
inner.up('div').setStyle('overflow:scroll; -webkit-overflow-scrolling:touch;')
track.hide();
}else{
var s = new Control.Slider(thumb,track, {axis:'vertical'});
var f = function(value){
var h = (inner.getHeight() - inner.up('div').getHeight());
inner.style.top = (Math.round(value * h) * -1) + 'px';
}
s.options.onChange = function(value){
f(value);
};
s.options.onSlide = function(value){
f(value);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment