Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit 691a9ca

Browse files
committed
making sure window.orientation exists
1 parent a5477b6 commit 691a9ca

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

public/styleguide/js/styleguide.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -446,16 +446,19 @@
446446
});
447447

448448
// Listen for resize changes
449-
var origOrientation = window.orientation;
450-
window.addEventListener("orientationchange", function() {
451-
if (window.orientation != origOrientation) {
452-
$("#sg-gen-container").width($(window).width());
453-
$("#sg-viewport").width($(window).width());
454-
updateSizeReading($(window).width());
455-
origOrientation = window.orientation;
456-
}
457-
}, false);
458-
449+
if (window.orientation !== undefined) {
450+
var origOrientation = window.orientation;
451+
window.addEventListener("orientationchange", function() {
452+
if (window.orientation != origOrientation) {
453+
$("#sg-gen-container").width($(window).width());
454+
$("#sg-viewport").width($(window).width());
455+
updateSizeReading($(window).width());
456+
origOrientation = window.orientation;
457+
}
458+
}, false);
459+
460+
}
461+
459462
// watch the iframe source so that it can be sent back to everyone else.
460463
// based on the great MDN docs at https://developer.mozilla.org/en-US/docs/Web/API/window.postMessage
461464
function receiveIframeMessage(event) {

0 commit comments

Comments
 (0)