sdecima / javascript-detect-element-resize

A Cross-Browser, Event-based, Element Resize Detection
MIT License
881 stars 151 forks source link

Does not work properly under OSX Chrome / in general #19

Open wonderment opened 9 years ago

wonderment commented 9 years ago

I've installed via Bower, which drops in the /javascript-detect-element-resize/detect-element-resize.js file.

If I have the following in the js:

( function( $ ) {
    var do_something = function(){
      console.log('test');
    }

   $(window).resize(do_something);
} )( jQuery );

It seems to fire as if I had a regular resize event on the window.

Adding:

$(window).removeResize(do_something);

...throws a "Uncaught TypeError: undefined is not a function". And if I point it to an element it simply does not fire. The script is loading fine, so I'm confused.

What am I missing?

andreicojea commented 9 years ago

Hey @wonderment, I doubt this is meant to work with the window object, which has it's own resize event and which is actually the only one that triggers a natural resize event. This plugin is a workaround for all other elements, which don't trigger this event when they get resized.

I suppose you want to remove that listener, just perform a regular jquery unbind:

$(window).unbind("resize", do_something);
// or
$(window).off("resize", do_something);
alexlawrence commented 9 years ago

Agree with @andreicojea . Could this issue just be closed?