Question

I’m trying to make a div follow the window scrollTop.

In FF it looks good but in IE (6,7) the animation jumps and causes the window scroll to jump.

I've tried easing but it didn't work.

My code:

        <div style="float:left;width:500px;height:4000px; background-color:Blue;">
        <br/>           
    </div>
    <div id="Div1" style="position:relative; float:left; height:4000px; width:300px;">
        <div id="sidePanel" style="position:absolute; top:0px; left:0px;width:200px; height:200px;  border:solid 1px black;">
            SIDE PANEL<br/><br/>
        <div id="info"></div>
            <br />
            <button id="showCurrTop" onclick="alert($(window).scrollTop());">$(window).scrollTop()</button>
        </div>
    </div>

        $(document).ready(function(){

             $(window).scroll(function () { 
                    var scrollTop = $(window).scrollTop();

                    $("#sidePanel").stop(false,false);
                    $("#sidePanel").animate({"top": scrollTop + 200}, 1000);

                    $("#info").html(scrollTop);

                });
          });
Was it helpful?

Solution

Found a solution: Floating Div

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top