0
Hello, I was thinking of putting in a project of mine, an "effect" of controlling a certain element using the position of the scroll bar, when the user descends through the page. I tried to run some tests, but it turned out to be nothing. I think it should be easy to do and did not want to use a plugin for this.
In short: it would be a code that computes the percentage of scroll position (when moved up or down) from 20 to 100 and transforms it into a value from 0.0 to 1.0 to apply as opacity on an element or from 0 to 200 to put as "marginTop", for example. Thanks since then =)
What did you try to do? There’s some code ? You’re using jQuery or neither ?
– Diego Souza
See if this example helps you http://jsfiddle.net/tcloninger/e5qad/
– Emir Marques
Emir, in his example, he gives the beginning of the animation in a certain position, but does not control it if I fool up or down in scroll =p
– Iago Bruno
Right, the more you’ll need to adjust the logic. scrollTop will give you the scroll position with respect to the screen size. From there you only need to get the screen size with window.height. Make a rule of three and discover the %. Remembering that every time the guy rolls the bar the event will be triggered
– Emir Marques
Jquery all right, is the basis of all =D but did not want to use gigantic plugins to make a certain function that I’m sure can do with few lines of code
– Iago Bruno
I asked if you are using jQuery. jQuery is not plugin, it is a library made in Javascript.
– Diego Souza