How to use the react-mosaic-component.createDragToUpdates function in react-mosaic-component

To help you get started, we’ve selected a few react-mosaic-component examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cruise-automation / webviz / packages / webviz-core / src / components / PanelToolbar / MosaicDragHandle.js View on Github external
endDrag: (props, monitor, component) => {
    const { hideTimer } = monitor.getItem();
    // If the hide call hasn't happened yet, cancel it
    window.clearTimeout(hideTimer);

    const { mosaicWindowActions, mosaicActions } = component.context;
    const type = getPanelTypeFromMosiac(mosaicWindowActions, mosaicActions);

    getGlobalHooks().onPanelDrag(type);
    const ownPath = component.context.mosaicWindowActions.getPath();
    const dropResult = monitor.getDropResult() || {};
    const { position, path: destinationPath } = dropResult;
    if (position != null && destinationPath != null && !_.isEqual(destinationPath, ownPath)) {
      mosaicActions.updateTree(createDragToUpdates(mosaicActions.getRoot(), ownPath, destinationPath, position));
    } else {
      mosaicActions.updateTree([
        {
          path: _.dropRight(ownPath),
          spec: {
            splitPercentage: {
              $set: null,
            },
          },
        },
      ]);
    }
  },
};