8
0
Просмотр исходного кода

Internal: Visible resizer change should not be throttled.

Marek Lewandowski 6 лет назад
Родитель
Сommit
ef82187266
1 измененных файлов с 8 добавлено и 4 удалено
  1. 8 4
      packages/ckeditor5-widget/src/widgetresize.js

+ 8 - 4
packages/ckeditor5-widget/src/widgetresize.js

@@ -94,19 +94,23 @@ export default class WidgetResize extends Plugin {
 			}
 		} );
 
-		const redrawFocusedResizer = throttle( () => {
+		const redrawFocusedResizer = () => {
 			if ( this._visibleResizer ) {
 				this._visibleResizer.redraw();
 			}
-		}, 200 ); // 5 fps
+		}; // 5 fps
 
+		const redrawFocusedResizerThrottled = throttle( redrawFocusedResizer, 16 ); // ~60fps
+
+		// Redraws occurring upon change of visible resizer must not be throttled, as it is crucial for the initial
+		// render. Without it the resizer frame would be misaligned with resizing host for a fraction of second.
 		this.on( 'change:_visibleResizer', redrawFocusedResizer );
 
 		// Redrawing on any change of the UI of the editor (including content changes).
-		this.editor.ui.on( 'update', redrawFocusedResizer );
+		this.editor.ui.on( 'update', redrawFocusedResizerThrottled );
 
 		// Resizers need to be redrawn upon window resize, because new window might shrink resize host.
-		this._observer.listenTo( global.window, 'resize', redrawFocusedResizer );
+		this._observer.listenTo( global.window, 'resize', redrawFocusedResizerThrottled );
 
 		const viewSelection = this.editor.editing.view.document.selection;