Repaint clean up

This commit is contained in:
Sam Potts 2019-06-03 20:12:21 +10:00
parent ab89e055de
commit c94ab2a39f
2 changed files with 10 additions and 9 deletions

View File

@ -73,9 +73,6 @@ function toggleFallback(toggle = false) {
.filter(part => part.trim() !== property)
.join(',');
}
// Force a repaint as sometimes Safari doesn't want to fill the screen
setTimeout(() => repaint(this.target), 100);
}
// Toggle button and fire events

View File

@ -2,7 +2,6 @@
// Animation utils
// ==========================================================================
import { toggleHidden } from './elements';
import is from './is';
export const transitionEndEvent = (() => {
@ -21,14 +20,19 @@ export const transitionEndEvent = (() => {
})();
// Force repaint of element
export function repaint(element) {
export function repaint(element, delay) {
setTimeout(() => {
try {
toggleHidden(element, true);
element.offsetHeight; // eslint-disable-line
toggleHidden(element, false);
// eslint-disable-next-line no-param-reassign
element.hidden = true;
// eslint-disable-next-line no-unused-expressions
element.offsetHeight;
// eslint-disable-next-line no-param-reassign
element.hidden = false;
} catch (e) {
// Do nothing
}
}, 0);
}, delay);
}