|
|
2008-04-11
, 16:41
|
|
|
Posts: 4,930 |
Thanked: 2,272 times |
Joined on Oct 2007
|
#2
|
function startSpeedTracking(e) {
stopScroll();
oldY = e.pageY;
tintv = setInterval(speedTracker, 50);
}
function speedTracker() {
//Somehow get current coords? Stuffing the new y in newY...
velocity = (newY - oldY)/50;
oldY = newY;
}
function startScroll(e) {
clearInterval(tintv);
if(velocity > 0){
direction = -1;
}else{
direction = 1;
}
velocity = Math.abs(velocity);
//Rest of stuff unchanged...
//Maybe threshold off velocity, instead of time?
}
|
|
2008-04-11
, 16:51
|
|
|
Posts: 4,930 |
Thanked: 2,272 times |
Joined on Oct 2007
|
#3
|
|
|
2008-04-11
, 17:01
|
|
|
Posts: 4,707 |
Thanked: 4,643 times |
Joined on Oct 2007
@ Bulgaria
|
#4
|
<body onmousemove="console.log(event.screenX)">
We have during drag
| The Following User Says Thank You to Bundyo For This Useful Post: | ||
|
|
2008-04-11
, 17:23
|
|
|
Posts: 4,930 |
Thanked: 2,272 times |
Joined on Oct 2007
|
#5
|
|
|
2008-04-11
, 17:26
|
|
Posts: 17 |
Thanked: 10 times |
Joined on Mar 2008
@ Guatemala City, Guatemala
|
#6
|
|
|
2008-04-11
, 17:27
|
|
|
Posts: 4,707 |
Thanked: 4,643 times |
Joined on Oct 2007
@ Bulgaria
|
#7
|
|
|
2008-04-11
, 17:59
|
|
|
Posts: 4,930 |
Thanked: 2,272 times |
Joined on Oct 2007
|
#8
|
|
|
2008-04-11
, 18:33
|
|
|
Posts: 4,707 |
Thanked: 4,643 times |
Joined on Oct 2007
@ Bulgaria
|
#9
|
Here is a rough Greasemonkey script I've written for 'kinetic' scrolling for MicroB. It needs some tweaking, but it works! Let me know what you think.
-Broc
var TIME_THRESHOLD = 500; var MAX_VELOCITY = 5000; var scrollBy; var sintv; var startY = 0; var endY = 0; var startTime; var endTime; var timeScrolled; var distanceScrolled; var velocity; var direction; var intervalCount = 0; function setStartY(e){ stopScroll(); startY = e.pageY; startTime = new Date(); } function startScroll(e){ stopScroll(); endY = e.pageY; endTime = new Date(); if(e.pageX < 700){ // 700 should be innerwidth of window ... change me Scroll(startY, endY, startTime, endTime); } } function Scroll(stY,enY,stTime,enTime){ timeScrolled = (enTime.getSeconds()+ enTime.getMilliseconds()/1000) - (stTime.getSeconds()+stTime.getMilliseconds()/1000); if(timeScrolled < TIME_THRESHOLD){ distanceScrolled = Math.abs(enY - stY); velocity = (distanceScrolled / timeScrolled); if(velocity > MAX_VELOCITY){ velocity = MAX_VELOCITY; } //get direction if(enY > stY){ direction = -1; }else{ direction = 1; } sintv = setInterval(scrollIt, 10); } } function scrollIt(){ intervalCount +=1; var cseconds = 1+intervalCount/100; scrollBy = (velocity*0.098)/(cseconds*cseconds); if(scrollBy > 2){ window.scrollBy(0,parseInt(scrollBy * direction)); }else{ stopScroll(); } } function stopScroll(){ direction = 0; velocity = 0; intervalCount = 0; distanceToScroll = 0; clearInterval(sintv); } document.addEventListener('mousedown', setStartY, false); document.addEventListener('mouseup', startScroll, false);Last edited by binauralbeat; 2008-04-11 at 16:18.