wnr / element-resize-detector

Optimized cross-browser resize listener for elements.
MIT License
1.32k stars 118 forks source link

uninstall throws - Cannot read property 'busy' of undefined #50

Closed justintfrost closed 8 years ago

justintfrost commented 8 years ago

When calling the uninstall method on a erd the above error is thrown.

var resizeDetectorElements = $("#uid .container").toArray();
var resizeDetector = elementResizeDetectorMaker({
     strategy: "scroll" //<- For ultra performance.
});
resizeDetector.listenTo(resizeDetectorElements, function(element) {
    // code for resize
});

*** this line throws the error ***
resizeDetector.uninstall(resizeDetectorElements);
wnr commented 8 years ago

Hi and thanks for the issue. The uninstall API takes a single element as input, so it throws an error when you pass it an array. I think it would be a nice addition to the method to also accept an array, perhaps you could submit a PR? Otherwise I can look into that.

Thanks

eliseumds commented 8 years ago

That happens when hot reload happens as well (React). The element exists, but the function is being called two or three times and the state gets cleared in between.

wnr commented 8 years ago

@eliseumds I see. Thanks for the PR. As I believe this is another issue (calling uninstall on already uninstalled elements) I'll not close this issue, but happily merge the PR :)

eliseumds commented 8 years ago

@wnr you're right, that's different, sorry =S I updated the commit msg on #52

wnr commented 8 years ago

@eliseumds No problems at all :) I have merged your PR locally, and will publish it soon. Looking to fix this issue at the same time.

wnr commented 8 years ago

Support for multiple elements is now supported in v1.1.3.