mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-12 00:37:19 +00:00
Everything supports ResizeObserver now
This commit is contained in:
@@ -78,12 +78,8 @@ export default class TwoUp extends HTMLElement {
|
|||||||
`}</div>`;
|
`}</div>`;
|
||||||
|
|
||||||
// Watch for element size changes.
|
// Watch for element size changes.
|
||||||
if ('ResizeObserver' in window) {
|
|
||||||
this._resizeObserver = new ResizeObserver(() => this._resetPosition());
|
this._resizeObserver = new ResizeObserver(() => this._resetPosition());
|
||||||
this._resizeObserver.observe(this);
|
this._resizeObserver.observe(this);
|
||||||
} else {
|
|
||||||
window.addEventListener('resize', this._onResize);
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener('keydown', this._onKeyDown);
|
window.addEventListener('keydown', this._onKeyDown);
|
||||||
|
|
||||||
@@ -95,7 +91,6 @@ export default class TwoUp extends HTMLElement {
|
|||||||
|
|
||||||
disconnectedCallback() {
|
disconnectedCallback() {
|
||||||
window.removeEventListener('keydown', this._onKeyDown);
|
window.removeEventListener('keydown', this._onKeyDown);
|
||||||
window.removeEventListener('resize', this._onResize);
|
|
||||||
if (this._resizeObserver) this._resizeObserver.disconnect();
|
if (this._resizeObserver) this._resizeObserver.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,8 +128,6 @@ export default class TwoUp extends HTMLElement {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private _onResize = () => this._resetPosition();
|
|
||||||
|
|
||||||
private _resetPosition() {
|
private _resetPosition() {
|
||||||
// Set the initial position of the handle.
|
// Set the initial position of the handle.
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user