Mercurial > hg > dml-open-vis
diff src/DML/VendorAssetsBundle/Resources/assets/scrollfix/0.1/scrollfix.js @ 0:493bcb69166c
added public content
author | Daniel Wolff |
---|---|
date | Tue, 09 Feb 2016 20:54:02 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/DML/VendorAssetsBundle/Resources/assets/scrollfix/0.1/scrollfix.js Tue Feb 09 20:54:02 2016 +0100 @@ -0,0 +1,31 @@ +/** + * ScrollFix v0.1 + * http://www.joelambert.co.uk + * + * Copyright 2011, Joe Lambert. + * Free to use under the MIT license. + * http://www.opensource.org/licenses/mit-license.php + */ + +var ScrollFix = function(elem) { + // Variables to track inputs + var startY, startTopScroll; + + elem = elem || document.querySelector(elem); + + // If there is no element, then do nothing + if(!elem) + return; + + // Handle the start of interactions + elem.addEventListener('touchstart', function(event){ + startY = event.touches[0].pageY; + startTopScroll = elem.scrollTop; + + if(startTopScroll <= 0) + elem.scrollTop = 1; + + if(startTopScroll + elem.offsetHeight >= elem.scrollHeight) + elem.scrollTop = elem.scrollHeight - elem.offsetHeight - 1; + }, false); +}; \ No newline at end of file