From 802d135a702f2f20c13105fe0f2e80c4c1c24034 Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Tue, 11 Oct 2022 16:29:57 +0300 Subject: [PATCH] Refacroting embed addon --- embed/embed.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/embed/embed.js b/embed/embed.js index 7d2d4086..24160b7d 100644 --- a/embed/embed.js +++ b/embed/embed.js @@ -31,6 +31,7 @@ */ "use strict"; -(function(){function b(a){this.frame=a;this.x=window.scrollX;this.y=window.scrollY;this.isLock=!1;document.addEventListener("scroll",this.onScroll.bind(this),!1);window.addEventListener("blur",this.onBlur.bind(this),!1);window.addEventListener("pointermove",this.onMove.bind(this),!1);window.addEventListener("wheel",this.onMove.bind(this),!1);this.frame.addEventListener("pointerover",this.onOver.bind(this),!1);this.frame.addEventListener("pointerleave",this.onLeave.bind(this),!1)}window.AscEmbed=window.AscEmbed|| -{};b.prototype.onScroll=function(){document.activeElement===this.frame||this.isLock?window.scrollTo(this.x,this.y):(this.x=window.scrollX,this.y=window.scrollY)};b.prototype.onBlur=function(){if(document.activeElement===this.frame){this.isLock=!0;var a=this;setTimeout(function(){a.isLock=!1},100)}};b.prototype.onOver=function(){};b.prototype.onLeave=function(){this.frame.blur()};b.prototype.onMove=function(){document.activeElement===this.frame&&this.frame.blur()};window.AscEmbed.initWorker=function(a){window.AscEmbed.workers= -window.AscEmbed.workers||[];a=new b(a);window.AscEmbed.workers.push(a);return a}})(); +(function(){function b(a){this.frame=a;this.x=window.scrollX;this.y=window.scrollY;this.lockCounter=0;document.addEventListener("scroll",this.onScroll.bind(this),!1);window.addEventListener("blur",this.onBlur.bind(this),!1);window.addEventListener("pointermove",this.onMove.bind(this),!1);window.addEventListener("wheel",this.onMove.bind(this),!1);this.frame.addEventListener("pointerover",this.onOver.bind(this),!1);this.frame.addEventListener("pointerleave",this.onLeave.bind(this),!1)}window.AscEmbed= +window.AscEmbed||{};b.prototype.onScroll=function(){document.activeElement===this.frame||0!==this.lockCounter?window.scrollTo(this.x,this.y):(this.x=window.scrollX,this.y=window.scrollY)};b.prototype.onBlur=function(){document.activeElement===this.frame&&this.lockWithTimeout(500)};b.prototype.onOver=function(){};b.prototype.onLeave=function(){this.lockWithTimeout(100);this.frame.blur()};b.prototype.onMove=function(){document.activeElement===this.frame&&(this.lockWithTimeout(100),this.frame.blur())}; +b.prototype.lockWithTimeout=function(a){this.lockCounter++;var c=this;setTimeout(function(){c.lockCounter--},a)};window.AscEmbed.initWorker=function(a){window.AscEmbed.workers=window.AscEmbed.workers||[];a=new b(a);window.AscEmbed.workers.push(a);return a}})(); +