VulpesOS/assets/webapps/ftu.gaiamobile.org/shared/js/event_safety.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

5 lines
No EOL
578 B
JavaScript

;'use strict';function eventSafety(obj,event,callback,timeout){if(typeof callback==='number'){timeout=callback;callback=null;}
if(!timeout){throw new Error('You must pass a valid timeout value to `eventSafety`.');}
return new Promise((resolve)=>{var finishTimeout;function done(e){if(e&&e.target!==obj&&(e.type==='transitionend'||e.type==='animationend')){return;}
clearTimeout(finishTimeout);obj.removeEventListener(event,done);if(callback){resolve(callback.apply(this,arguments));}else{resolve(e);}}
finishTimeout=setTimeout(done,timeout);obj.addEventListener(event,done);});}