- This topic is empty.
January 23, 2018 at 10:14 am #265915
Do you mean that they can slowdown the website if not limited?January 23, 2018 at 10:26 am #265916
Potentially it could, even though it’s unlikely because of this script alone. But accumulative with other code it’s certainly possible. Optimisation’s always better.January 23, 2018 at 12:46 pm #265926
Keep me guessing..)
What kind of optimization?January 23, 2018 at 12:55 pm #265927
Throttling, in this case. :-pJanuary 23, 2018 at 1:33 pm #265929
Actually i was thinkin about erasing opacity fading animation out of your script
since we have some extra from our css animations to apply + throttling)
But i still don’t understand what it does.
those fuctions can’t be firing constantly, aren’t they?
plus we can’t limit them because user going to scroll randomly so there should be no delay.January 23, 2018 at 1:44 pm #265930
The scroll event itself can fire up to 60 times a second when normally scrolling and likely even more when dragging the scrollbar. There will be no noticeable delay when throttling, it only brings down events to about 20 times a second. Any more is usually unnecessary.April 6, 2019 at 12:50 am #286000
Hey, Edo .. hows it going?
Do you remember that pen you did?
Since you’re at the role of a magician here on this topic))
Can you add some lines so nav links would become active when user scroll to a certain section?
RIght now they become active only after you click a link.April 6, 2019 at 4:54 am #286005
Hey Funk, how are you. Been a while.
I actually made a demo similar to that recently, I’ll see if I can adapt it for this over the weekend…April 6, 2019 at 5:26 am #286006
Gave my eyes some rest.
Was doing other stuff which finally brought me here again)April 7, 2019 at 11:44 am #286022
This is it I think:
By the way…
e.preventDefault()prevents the click from instantly snapping to the section (the default behaviour with anchor links) so that it can be animated instead. Where
eis the event itself – and its related data.April 7, 2019 at 10:33 pm #286025
Looking back through the topic, I kinda did the same thing already…April 8, 2019 at 1:06 am #286029
yeah its just .. it has animation
and its conflicting with other animations in css when i try to reuse it
thats why i asked you to write script just for scrollApril 8, 2019 at 6:30 am #286033
Using JS’s native
getBoundingClientRectis a nicer approach anyway.April 9, 2019 at 9:33 am #286116
i’ve noticed that nav links become active as next window starts to appear in the bottom like here
is it possible to make a nav link become active in the middle or top of the screen if you know what i mean?April 9, 2019 at 8:44 pm #286179
It’s all in this line:
if (apex < gate && nadir > range)
Currently it will make an item active when its top (apex) is at the bottom of the screen or above. Change to
0.5*gateif you want it when entering the middle. The other condition is set to make it active after the item’s bottom is going beyond the height of the top menu which was stored in the
rangevariable near the end of the script. Can also be changed to any other value you like.