Skip to content

Commit a255e69

Browse files
TatuLundpaodb
authored andcommitted
Wrap resize observer in animation frame
This will effectively debounce
1 parent 0c0c585 commit a255e69

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/vcf-date-range-picker.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,17 @@ import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
373373

374374
const wc = this;
375375
const resizeObserver = new ResizeObserver(entries => {
376-
for (let entry of entries) {
377-
if(entry.contentBoxSize) {
378-
var size = wc.shadowRoot.host.offsetWidth;
379-
wc._inputStartElement.shadowRoot.querySelector('[part="label"]')
380-
.setAttribute('style', "width: " + size + "px; max-width: max-content; overflow: hidden;");
381-
wc._inputStartElement.shadowRoot.querySelector('[part="error-message"]')
382-
.setAttribute('style', "width: " + size + "px; max-width: max-content; overflow: hidden;");
376+
requestAnimationFrame(() => {
377+
for (let entry of entries) {
378+
if(entry.contentBoxSize) {
379+
var size = wc.shadowRoot.host.offsetWidth;
380+
wc._inputStartElement.shadowRoot.querySelector('[part="label"]')
381+
.setAttribute('style', "width: " + size + "px; max-width: max-content; overflow: hidden;");
382+
wc._inputStartElement.shadowRoot.querySelector('[part="error-message"]')
383+
.setAttribute('style', "width: " + size + "px; max-width: max-content; overflow: hidden;");
384+
}
383385
}
384-
}
386+
});
385387
});
386388

387389
resizeObserver.observe(this);

0 commit comments

Comments
 (0)