Prevent ResizeObserver loop errors
This commit is contained in:
parent
270b15d2c3
commit
f22f2019d1
30
src/main.js
30
src/main.js
|
|
@ -3593,23 +3593,14 @@ function toolbar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function timeline() {
|
function timeline() {
|
||||||
// let container = document.createElement("div")
|
|
||||||
// let layerspanel = document.createElement("div")
|
|
||||||
// let framescontainer = document.createElement("div")
|
|
||||||
// container.classList.add("horizontal-grid")
|
|
||||||
// container.classList.add("layers-container")
|
|
||||||
// layerspanel.className = "layers"
|
|
||||||
// framescontainer.className = "frames-container"
|
|
||||||
// container.appendChild(layerspanel)
|
|
||||||
// container.appendChild(framescontainer)
|
|
||||||
// layoutElements.push(container)
|
|
||||||
// container.setAttribute("lb-percent", 20)
|
|
||||||
|
|
||||||
// return container
|
|
||||||
|
|
||||||
let timeline_cvs = document.createElement("canvas")
|
let timeline_cvs = document.createElement("canvas")
|
||||||
timeline_cvs.className = "timeline"
|
timeline_cvs.className = "timeline"
|
||||||
|
|
||||||
|
|
||||||
|
// Variable to store the last time updateTimelineCanvasSize was called
|
||||||
|
let lastResizeTime = 0;
|
||||||
|
const throttleIntervalMs = 20;
|
||||||
|
|
||||||
function updateTimelineCanvasSize() {
|
function updateTimelineCanvasSize() {
|
||||||
const canvasStyles = window.getComputedStyle(timeline_cvs);
|
const canvasStyles = window.getComputedStyle(timeline_cvs);
|
||||||
|
|
||||||
|
|
@ -3619,7 +3610,16 @@ function timeline() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up ResizeObserver to watch for changes in the canvas size
|
// Set up ResizeObserver to watch for changes in the canvas size
|
||||||
const resizeObserver = new ResizeObserver(updateTimelineCanvasSize);
|
const resizeObserver = new ResizeObserver(() => {
|
||||||
|
const currentTime = Date.now();
|
||||||
|
|
||||||
|
// Only call updateTimelineCanvasSize if enough time has passed since the last call
|
||||||
|
// This prevents error messages about a ResizeObserver loop
|
||||||
|
if (currentTime - lastResizeTime > throttleIntervalMs) {
|
||||||
|
lastResizeTime = currentTime;
|
||||||
|
updateTimelineCanvasSize();
|
||||||
|
}
|
||||||
|
});
|
||||||
resizeObserver.observe(timeline_cvs);
|
resizeObserver.observe(timeline_cvs);
|
||||||
|
|
||||||
let scrollSpeed = 1;
|
let scrollSpeed = 1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue