I have a not so unique problem I am running into. Currently utilizing the Google Maps API InfoBox. If a specific flag is set on this infobox the scroll is disabled. I need to have this flag set and there seems no way to dynamically change it.
The only way around this may be to use a pure JavaScript scrolling function. The standard CSS would be:
-webkit-overflow-scrolling: touch;
However this does not function per the flag above. I have also tried a number of JavaScript libraries but they just seem to be pretty versions of the standard CSS scroll.
Does anyone know of a library which uses only JavaScript to scroll inside of a div?
answer
function touchScroll(id){
// if(isTouchDevice()){ //if touch events exist...
var el=document.getElementById(id);
var scrollStartPos=0;
document.getElementById(id).addEventListener("touchstart", function(event) {
scrollStartPos=this.scrollTop+event.touches[0].pageY;
event.preventDefault();
},false);
document.getElementById(id).addEventListener("touchmove", function(event) {
this.scrollTop=scrollStartPos-event.touches[0].pageY;
event.preventDefault();
},false);
// }
}