Skip to content

Instantly share code, notes, and snippets.

View ezirmusitua's full-sized avatar
🎯
Focusing

ezirmusitua ezirmusitua

🎯
Focusing
View GitHub Profile
@ezirmusitua
ezirmusitua / javascript-resize-debounce.js
Last active September 1, 2023 13:14
[Debounce window resize event] Debounce window resize event #javascript #frontend #perfermance
/* --------------------------------------------
* Detect device orientation
* and trigger changes based on it
--------------------------------------------*/
function updateOrientation() {
// Detect whether device supports orientationchange event, otherwise fall back to the resize event
// Genius solution from http://stackoverflow.com/a/2307936
let supportsOrientationChange = "onorientationchange";
let orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";
let newAngle = null;