Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unbinding later bound event in earlier bound trigger fails #5

Open
plaidhatter opened this issue May 17, 2012 · 0 comments
Open

unbinding later bound event in earlier bound trigger fails #5

plaidhatter opened this issue May 17, 2012 · 0 comments

Comments

@plaidhatter
Copy link

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 ] );

  };
GerHobbelt pushed a commit to GerHobbelt/jquery-resize that referenced this issue Oct 31, 2013
GerHobbelt pushed a commit to GerHobbelt/jquery-resize that referenced this issue Oct 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant