comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:493bcb69166c
1 /**
2 * ScrollFix v0.1
3 * http://www.joelambert.co.uk
4 *
5 * Copyright 2011, Joe Lambert.
6 * Free to use under the MIT license.
7 * http://www.opensource.org/licenses/mit-license.php
8 */
9
10 var ScrollFix = function(elem) {
11 // Variables to track inputs
12 var startY, startTopScroll;
13
14 elem = elem || document.querySelector(elem);
15
16 // If there is no element, then do nothing
17 if(!elem)
18 return;
19
20 // Handle the start of interactions
21 elem.addEventListener('touchstart', function(event){
22 startY = event.touches[0].pageY;
23 startTopScroll = elem.scrollTop;
24
25 if(startTopScroll <= 0)
26 elem.scrollTop = 1;
27
28 if(startTopScroll + elem.offsetHeight >= elem.scrollHeight)
29 elem.scrollTop = elem.scrollHeight - elem.offsetHeight - 1;
30 }, false);
31 };