jquery-resize icon indicating copy to clipboard operation
jquery-resize copied to clipboard

unbinding later bound event in earlier bound trigger fails

Open plaidhatter opened this issue 12 years ago • 0 comments

Great plugin. I've used it a bunch. I found a bug though that will completely disable the plugin. The gist is that within a resize trigger, when you unbind a resize event for a later bound resize event, loopy still try's to check the unbound one and it no longer has the needed data. I've fixed the code (just check that data exists before accessing it) on my machine and have included it here:

  function loopy() {

    // Start the polling loop, asynchronously.
    timeout_id = window[ str_setTimeout ](function(){

      // Iterate over all elements to which the 'resize' event is bound.
      elems.each(function(){
        var elem = $(this),
          width = elem.width(),
          height = elem.height(),
          data = $.data( this, str_data );

        // If element size has changed since the last time, update the element
        // data store and trigger the 'resize' event.
        if (data && ( width !== data.w || height !== data.h ) ) {
          elem.trigger( str_resize, [ data.w = width, data.h = height ] );
        }

      });

      // Loop.
      loopy();

    }, jq_resize[ str_delay ] );

  };

plaidhatter avatar May 17 '12 23:05 plaidhatter