From c94ab2a39fde5ce41a2473f7e9ac29f51886fe18 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Mon, 3 Jun 2019 20:12:21 +1000 Subject: [PATCH] Repaint clean up --- src/js/fullscreen.js | 3 --- src/js/utils/animation.js | 16 ++++++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/js/fullscreen.js b/src/js/fullscreen.js index c86bf877..d4d15b23 100644 --- a/src/js/fullscreen.js +++ b/src/js/fullscreen.js @@ -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 diff --git a/src/js/utils/animation.js b/src/js/utils/animation.js index 6b950b61..3f721b5a 100644 --- a/src/js/utils/animation.js +++ b/src/js/utils/animation.js @@ -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); }