-
-
Save walterdavis/114588cdb07c3b534910 to your computer and use it in GitHub Desktop.
Script.aculo.us Scroll Area with iOS Compatibility
This file contains 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
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