Adding value to integer changes other variable
Hope I posted this to the right forum, as this is my first post here.
I'm experiencing something weird with a piece of code I've written to enlarge a link as soon as the user scrolls past a div box. I'm using this code:
This all worked until I added a feature on my website where the content can dynamically change depending on an option the user makes. It works like this:
https://jsfiddle.net/1Lret7vk/4/.
After adding this option, the illogical things started to happen. The code to resize the links doesn't work anymore and the line that is causing the problem is line 6. Whenever I add this line it results in the values of scrolltop and offtop being identical - but offtop should normally be a constant value.
I was able to recreate the issue in a fiddle:
You can see that all links resize at once with the first scroll in the second fiddle. This is due to the fact that
scrolltop
is somehow identical to
offtop
then (see console).
I've been stuck with this for a few days now and I jsut can't find a solution to this.
So there are pretty weird things going somehow and if there are more things that you need to see to get an idea of the issue then I will of course add this to my question. Thanks in advance!