Honzis Novák Honzis Novák - 2 years ago 96
Javascript Question

Change value of div while scrolling

how could I change a position of a div, based on scroll level of my website? I have a landing screen (whole page fullscreen background) only with big centered logo. What I'm asking is, how to do that it'll scale down and catch into a navbar, where it'll be sticked, untill it would be scrolled up again.

I did a video showcase, how I mean it. https://www.youtube.com/watch?v=3fecyRsOkz8&feature=youtu.be

I'm so glad for any help, have a nice day, senior coders! :)

Answer Source

Check the http://jsfiddle.net/rjv2016/occL21s3/1/

var aDivPosition = $('.adivclass').height();
if ($(this).scrollTop() >= aDivPosition) {
      my: bottom,
      of: $window,
          collision: "fit"

The fiddle only has the needed code. You will have to work out the .position method if not, post back your update (with your code).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download