sdecima / javascript-detect-element-resize

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

why doesn't this work? #32

Open N6REJ opened 9 years ago

N6REJ commented 9 years ago

when I use 'html' or 'body" and resize the browser sliding left to right or right to left, nothing happens.

<!-- window resize detection event -->
<script type="text/javascript">
    var topnavbar = <?php echo $topnavbar; ?>;
    var myFunc = function(jQuery) {
    jQuery('body').css('border', '44px solid blue'); 
  };

  jQuery('html').resize(myFunc);
  //jQuery('body').removeResize(myFunc);
</script>

what am I doing wrong?

bvaughn commented 9 years ago

The documentation says:

It uses scroll events on most browsers, and the onresize event on IE10 and below.

My guess is that- since a horizontal resize won't trigger a scroll event- it also doesn't trigger the resize.