wduffy / jScroll

jScroll is a jQuery plugin that keeps an element in view when a user scrolls.
http://www.wduffy.co.uk/jScroll
73 stars 19 forks source link

scoll onload #7

Open karlmikko opened 13 years ago

karlmikko commented 13 years ago
    return this.each(function() {
        var $element = $(this);
        var $window = $(window);
        var locator = new location($element);

        $window.scroll(function() {
            $element
                .stop()
                .animate(locator.getMargin($window), opts.speed);
        }).scroll();
    });

by adding the .scroll(); after the callback is defined will enable the callback to be executed instantly. This will allow the plugin to work when someone has used the back button in a browser and it loads already scrolled down a page.

Currently this will only bring the element into view when the user scrolls. The extra .scroll() will enable it to come in on load.