Merge pull request #4009 from Tyriar/vscode157444
Ensure canvas device dims are > 0x0 when firing callback
This commit is contained in:
@@ -24,10 +24,12 @@ export function observeDevicePixelDimensions(element: HTMLElement, callback: (de
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(
|
// Fire the callback, ignore events where the dimensions are 0x0 as the canvas is likely hidden
|
||||||
entry.devicePixelContentBoxSize[0].inlineSize,
|
const width = entry.devicePixelContentBoxSize[0].inlineSize;
|
||||||
entry.devicePixelContentBoxSize[0].blockSize
|
const height = entry.devicePixelContentBoxSize[0].blockSize;
|
||||||
);
|
if (width > 0 && height > 0) {
|
||||||
|
callback(width, height);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
observer.observe(element, { box: ['device-pixel-content-box'] } as any);
|
observer.observe(element, { box: ['device-pixel-content-box'] } as any);
|
||||||
return toDisposable(() => observer?.disconnect());
|
return toDisposable(() => observer?.disconnect());
|
||||||
|
|||||||
Reference in New Issue
Block a user