process-analytics / bpmn-visualization-addons

Add-ons for `bpmn-visualization`.
https://process-analytics.github.io/bpmn-visualization-addons/
Apache License 2.0
3 stars 0 forks source link

[FEAT] Add a plugin that provides an API to translate/scroll a BPMN element #169

Open tbouffard opened 11 months ago

tbouffard commented 11 months ago

Is your feature request related to a problem? Please describe.

A BPMN element may require special attention, so it may be required to position/scroll it at a specific location in the BPMN container.

Describe the solution you'd like

Implement a ScrollElementsApiPlugin plugin that provides an API to scroll an BPMN element given its id. This will be a generalization of #165. This should work when the BPMN container has scrollbars.

API proposal

type ScrollElementOptions = {
  // same as bpmn-visualization OverlayShapePosition + 'center' and 'visible'
  position?: 'top-left' | 'top-right' | 'top-center' | 'bottom-left' | 'bottom-right' | 'bottom-center' | 'middle-left' | 'middle-right' | 'center' |  'visible' , // default 'top-left'
  margin-bottom?: number, // default 0
  margin-left?: number, // default 0
  margin-right?: number, // default 0
  margin-top?: number, // default 0
}

scrollElement(bpmnId: string, options?: {}): void

The margin properties don't always apply. For example:

Negative values for margins could be accepted.

Disclaimer: this will probably only work with a BPMN container that have a "fixed computed size" (as for the fit feature).

Name of the plugin. Be consistent with:

Future implementation: we may provide another plugin that takes the name of the BPMN element instead of its id, as we do in #75 or #76.

Screenshots

Positions and margins Positions and margins

Scrolling an hidden elements to make it visible Scrolling an hidden elements to make it visible

Additional context

A POC has been done for the top-left and center position in https://github.com/process-analytics/bpmn-visualization-js/pull/2885

Implementation of visible/center