Skip to content

Instantly share code, notes, and snippets.

@megazalrock
Last active August 29, 2015 14:06
Show Gist options
  • Save megazalrock/af34ae501d80680f9665 to your computer and use it in GitHub Desktop.
Save megazalrock/af34ae501d80680f9665 to your computer and use it in GitHub Desktop.
orientationchangeのイベント実装方法
var oldIsPortrait;
$(window)
.on('resize.orientaionChange', function () {
var $window = $(window);
var isPortrait = $window.width() < $window.height();
if(oldIsPortrait !== isPortrait){
$window
.trigger('orientaionChange', (isPortrait) ? 'portrait' : 'landscape');
oldIsPortrait = isPortrait;
}
})
.on('orientaionChange', function (e, orientaion) {
console.log(orientaion);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment