瀏覽代碼

Prevent layout thrashing by status text

Jeroen Hermans 4 年之前
父節點
當前提交
aaa7c02b5c
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      js/reveal.js

+ 5 - 1
js/reveal.js

@@ -1335,7 +1335,11 @@ export default function( revealElement, options ) {
 		}
 
 		// Announce the current slide contents to screen readers
-		announceStatus( getStatusText( currentSlide ) );
+		// Use animation frame to prevent getComputedStyle in getStatusText
+		// from triggering layout mid-frame
+		requestAnimationFrame( function() {
+			announceStatus( getStatusText( currentSlide ) );
+		});
 
 		progress.update();
 		controls.update();