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

Orientationchange event is flaky #16

Open
simonratner opened this issue Mar 21, 2012 · 2 comments
Open

Orientationchange event is flaky #16

simonratner opened this issue Mar 21, 2012 · 2 comments

Comments

@simonratner
Copy link
Contributor

The behaviour of orientationchange event isn't consistent; specifically, on many Android devices this event fires before orientation is actually updated, resulting in the wrong (opposite) size being detected. On some Android devices, it apparently doesn't fire at all.

Workaround I am using is to unregister SwipeView from listening to orientationchange, and manually call __resize on window resize. My recommendation would be to remove orientationchange detection from SwipeView completely, and just rely on window resize, which seems to give more reliable results.

@cubiq
Copy link
Owner

cubiq commented Mar 23, 2012

I'd hook resize only on android, or maybe call __resize inside a timeout. I'll check this, thanks for the report

@simonratner
Copy link
Contributor Author

By popular demand, here is a sketch of the code for my workaround (forgive any syntax errors, I did a cross-compile from coffeescript in my head):

var carousel = new SwipeView($('#carousel').get(0));
// prevent swipeview from resizing itself on orientation change, instead use `resize` event
window.removeEventListener('orientationchange', carousel, false);
window.addEventListener('resize', function(e) {
  carousel.__resize();
});

Alternatively, just patch line 38 in your copy of swipeview.js:
https://github.com/cubiq/SwipeView/blob/master/src/swipeview.js#L38

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

2 participants