+ 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.

5th Apr 2019, 8:28 PM
Emoji FanBoy
Emoji FanBoy - avatar
2 Antworten
+ 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) }
6th Apr 2019, 12:47 AM
Calviղ
Calviղ - avatar
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?
6th Apr 2019, 10:55 AM
Emoji FanBoy
Emoji FanBoy - avatar