Get Window Scroll type in Jquery
<p>I m in a situation where i need to keep a div at a fixed place and move to left or right depending upon window scroll, so for this i m using following jquery which is working fine</p>

<pre><code>$(document).ready(function() {

    var leftInit = $("#myDiv").offset().left;

    fixHeader = $('.fn-fixable')
    if (fixHeader.length) {
        start = fixHeader.offset().top;
        start += 20;
    }
    $.event.add(window, "scroll", function() {

        p = $(window).scrollTop();
        if (p &gt; start) {
            fixHeader.addClass('fix-on-top');
        }
        else {
            fixHeader.removeClass('fix-on-top');
        }

        if (fixHeader.hasClass('fix-on-top')) {
            var x = 0 - $(this).scrollLeft();
            $(fixHeader).css("left", x + leftInit);
        }
        else {
            $(fixHeader).css("left", "0");
        }
    });
});
</code></pre>

<p>The problem is when i resize the browser window , it changes the DIV position.
I want to find out a way so when window is resized it changes all DIV posititons to (0,0).</p>

<p>Please suggest any better way to do this.</p>

<p>thanks</p>
