Everything supports ResizeObserver now

This commit is contained in:
Jake Archibald
2021-06-16 10:13:46 +01:00
parent 828f9a5eeb
commit 1d292468b0

View File

@@ -78,12 +78,8 @@ export default class TwoUp extends HTMLElement {
`}</div>`;
// Watch for element size changes.
if ('ResizeObserver' in window) {
this._resizeObserver = new ResizeObserver(() => this._resetPosition());
this._resizeObserver.observe(this);
} else {
window.addEventListener('resize', this._onResize);
}
this._resizeObserver = new ResizeObserver(() => this._resetPosition());
this._resizeObserver.observe(this);
window.addEventListener('keydown', this._onKeyDown);
@@ -95,7 +91,6 @@ export default class TwoUp extends HTMLElement {
disconnectedCallback() {
window.removeEventListener('keydown', this._onKeyDown);
window.removeEventListener('resize', this._onResize);
if (this._resizeObserver) this._resizeObserver.disconnect();
}
@@ -133,8 +128,6 @@ export default class TwoUp extends HTMLElement {
}
};
private _onResize = () => this._resetPosition();
private _resetPosition() {
// Set the initial position of the handle.
requestAnimationFrame(() => {