Last active
August 29, 2015 14:06
-
-
Save megazalrock/af34ae501d80680f9665 to your computer and use it in GitHub Desktop.
orientationchangeのイベント実装方法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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