1 2 3 4 window.addEventListener('load', function(e){5 var bar = document.getElementById('collection-bar');6 var tap = document.getElementById('collection-tap');7 8 bar.addEventListener('mousedown', function(event){9 bar.scrolling = true;10 }, true);11 12 bar.addEventListener('mousemove', function(event){13 var v = event.pageX-bar.offsetLeft-tap.clientWidth/2;14 15 if (v < 0) v = 0;16 if (v > bar.clientWidth-tap.clientWidth) v = bar.clientWidth-tap.clientWidth;17 18 if (bar.scrolling)19 document.getElementById('collection-tap').style.marginLeft = v+'px';20 }, true);21 22 bar.addEventListener('mouseout', function(event){23 bar.scrolling = false;24 }, true);25 26 }, true);27 28 29 function log(m) {30 document.getElementById('log').innerHTML = m;31 }
Este ShareCode tiene versiones:
- ... (02/10/2012)
- Scroll horizontal lkafdj aslkfjf ñlkj... (05/10/2012)
Enlace
El enlace para compartir es: