Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Other: Replace getResizeObserver helper with new ResizeObserver class…
Browse files Browse the repository at this point in the history
… in ToolbarView.

Follow-up on: ckeditor/ckeditor5-utils/pull/320
  • Loading branch information
panr committed Feb 6, 2020
1 parent a6b9c09 commit be98aa4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/toolbar/toolbarview.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker';
import FocusCycler from '../focuscycler';
import KeystrokeHandler from '@ckeditor/ckeditor5-utils/src/keystrokehandler';
import ToolbarSeparatorView from './toolbarseparatorview';
import getResizeObserver from '@ckeditor/ckeditor5-utils/src/dom/getresizeobserver';
import ResizeObserver from '@ckeditor/ckeditor5-utils/src/dom/resizeobserver';
import preventDefault from '../bindings/preventdefault.js';
import Rect from '@ckeditor/ckeditor5-utils/src/dom/rect';
import global from '@ckeditor/ckeditor5-utils/src/dom/global';
Expand Down Expand Up @@ -494,7 +494,7 @@ class DynamicGrouping {
* **Note:** Created in {@link #_enableGroupingOnResize}.
*
* @readonly
* @member {module:utils/dom/getresizeobserver~ResizeObserver}
* @member {module:utils/dom/resizeobserver~ResizeObserver}
*/
this.resizeObserver = null;

Expand Down Expand Up @@ -580,7 +580,7 @@ class DynamicGrouping {
// so let's make sure it's actually destroyed along with the toolbar.
this.groupedItemsDropdown.destroy();

this.resizeObserver.disconnect();
this.resizeObserver.destroy();
}

/**
Expand Down Expand Up @@ -683,16 +683,14 @@ class DynamicGrouping {
let previousWidth;

// TODO: Consider debounce.
this.resizeObserver = getResizeObserver( ( [ entry ] ) => {
this.resizeObserver = new ResizeObserver( this.viewElement, entry => {
if ( !previousWidth || previousWidth !== entry.contentRect.width ) {
this._updateGrouping();

previousWidth = entry.contentRect.width;
}
} );

this.resizeObserver.observe( this.viewElement );

this._updateGrouping();
}

Expand Down

0 comments on commit be98aa4

Please sign in to comment.