Node's Package Magician

    timeout-window-resize

    2.0.1 • Public • Published

    jQuery.timeout-window-resize.js

    Installation

    npm i timeout-window-resize

    Require

    require("timeout-window-resize")

    Example

    $(window).timeoutResize(() => doSomethingAfter1Second(), 1000);

    Code

    (function($){
        $.fn.timeoutResize = function(callback, time){
            callback = callback || function(){};
            var $this = this;
            var settimeout_ID = 0;
            $this.resize(function(event) {
                clearTimeout(settimeout_ID);
                settimeout_ID = setTimeout(function(){
                    callback(event);
                }, time);
            });
     
            return {
                destroy: function(){
                    $this.off('resize', callback);
                }
            };
        };
    })(jQuery);

    Keywords

    Install

    npm i timeout-window-resize

    DownloadsWeekly Downloads

    7

    Version

    2.0.1

    License

    MIT

    Unpacked Size

    2.28 kB

    Total Files

    3

    Last publish

    Collaborators

    • mupic