Ver Fonte

call requestAnimationFrame when moving the selection

Gildas há 7 anos atrás
pai
commit
7cc64c065d
1 ficheiros alterados com 8 adições e 6 exclusões
  1. 8 6
      extension/ui/content/content-ui.js

+ 8 - 6
extension/ui/content/content-ui.js

@@ -118,12 +118,14 @@ this.singlefile.ui = this.singlefile.ui || (() => {
 	}
 
 	function moveAreaSelector(target) {
-		const selectorElement = createAreaSelector();
-		const boundingRect = target.getBoundingClientRect();
-		selectorElement.style.setProperty("top", (scrollY + boundingRect.top - 10) + "px");
-		selectorElement.style.setProperty("left", (scrollX + boundingRect.left - 10) + "px");
-		selectorElement.style.setProperty("width", (boundingRect.width + 20) + "px");
-		selectorElement.style.setProperty("height", (boundingRect.height + 20) + "px");
+		requestAnimationFrame(() => {
+			const selectorElement = createAreaSelector();
+			const boundingRect = target.getBoundingClientRect();
+			selectorElement.style.setProperty("top", (scrollY + boundingRect.top - 10) + "px");
+			selectorElement.style.setProperty("left", (scrollX + boundingRect.left - 10) + "px");
+			selectorElement.style.setProperty("width", (boundingRect.width + 20) + "px");
+			selectorElement.style.setProperty("height", (boundingRect.height + 20) + "px");
+		});
 	}
 
 	function createAreaSelector() {