mobify / pikabu

Off-Canvas flyout menu
http://mobify.github.io/pikabu/
MIT License
453 stars 51 forks source link

Resize event mistakenly fired, sidebar in view check incorrect (fix) #46

Closed sunyatasattva closed 9 years ago

sunyatasattva commented 10 years ago

I came across this bug because scrolling on my site suddenly didn't work anymore. I assume this is a new iOS Safari bug, but it seems that the resize event was fired on scroll.

So, in the event handler for the resize and orientationchange events, I added a fix to check if a resize of the viewport really happened (I only check for width, as I assume that's what we only care about).

This alone, however, would not explain why my scrolling wouldn't work (although this fixes the issue in a sense). The problem is that, further down (line 325 onwards), the code checks to see if any of the sidebars are visible, and proceeds to lock the viewport height.

Unfortunately, this is not how the Zepto :visible selector works. Rather, it just checks if the element has a width or height and it's not display: none. So, it basically always returns true for the sidebars.

What I did instead, is to check the offsets of the sidebars to determine if they are in view.

donnielrt commented 9 years ago

Hey, we’re looking to prune older unattended PRs. If this PR is still relevant and you would like to see it merged in, please reopen the PR and we’ll add it to our backlog! Thanks!