+ 1
How to change scroll speed?
I want to change scrolling speed(actually fast) when we scroll through the page. For the whole window, not any specific element. Actually my page is too long so I want to reduce stress on fingers.😉 No auto mode, only with my movement. If you want example, https://code.sololearn.com/W9ZavDVT1svB/?ref=app Note: No frameworks, no jQuery.
2 Respuestas
+ 5
Try this
function drawWhenScroll(){
var speed = 100; // adjust speed accordingly
var offset = speed*pageYOffset;
if(offset < LOGOLENGTH) {
SVGLOGO.style.strokeDashoffset = LOGOLENGTH - offset;
console.log(pageYOffset)
}
0
Thanks Calviղ.
I've new two questions
1) This was special animation, but in normal long text condition, I thought this would work but it didn't. I guess pageYOffset can't be assigned a value.🤔 addEventListener("scroll",mys);
function mys(){
var speed = 100;
var offset= pageYOffset * speed;
pageYOffset = offset;
}
So, can I do this?
2) In original CodePen code [link], when calcpercentage ==1 text automatically filled.
Here, when I want to do this, I did if offset == LOGOLENGTH. But it didn't worked😌
Edit: Does window.addEventListener and addEventListener make difference?