Home > jquery.lazyexecute

jquery.lazyexecute

Jquery.lazyexecute is a project mainly written in JAVASCRIPT and COFFEESCRIPT, it's free.

jQuery plugin

Lazy Execute : This is jQuery plugin. When some elements available on display area, the callback get executed.

=================================================================================== Copyright (C) 2011 Ryuichi Maeno [email protected] Dual licensed under the MIT and GPL licenses: http://www.opensource.org/licenses/mit-license.php http://www.gnu.org/licenses/gpl.html

Usage

// logging href attribute of A element when it available on display area. $(function(){ var lze = $('a').lazyExecute(function(){ console.log(this.attr("href")); }); // logging lazyExecute version. console.log(lze.version()); // logging target elements. console.log(lze.getLazyExecuteTargetElems());

// lze === lze2
// below statement is add elements to execute list in lazyExecute instance.
var lze2 = $('div').lazyExecute();

// lze !== lze3
// This is lazyExecute instance but different from lze and lze2.
var lze3 = $('div').lazyExecute(function(){
    console.log(this);
    // this mean execute this callback for element just once.
    return this.lazyExecute.STOP;
}, "dataSrorekey");

// if elements is inside the display area, execute function.
lze = $('a').lazyExecute($.lazyExecute.InDisplayArea, function(){
    console.log(this.attr("href"));
});
// if elements is outside the display area, execute function.
lze = $('a').lazyExecute($.lazyExecute.OutDisplayArea, function(){
    console.log(this.attr("href"));
});
// if elements enter into the display area, execute function.
// But if elements inside display area already, execute function.
lze = $('a').lazyExecute($.lazyExecute.LeaveDisplayArea, function(){
    console.log(this.attr("href"));
});
// if elements leave from the display area, execute function.
// But if elements outside display area already, execute function.
lze = $('a').lazyExecute($.lazyExecute.EnterDisplayArea, function(){
    console.log(this.attr("href"));
});

});

lazyExecute method trigger a scroll event on window.