UNPKG

postit-js-core

Version:

[![Netlify Status](https://api.netlify.com/api/v1/badges/72130b1d-f56b-473e-8f3b-50a5af916e64/deploy-status)](https://app.netlify.com/sites/postit-js-demo/deploys) ![Build Status](https://github.com/pinussilvestrus/postit-js/workflows/ci/badge.svg)

42 lines (34 loc) 1.07 kB
import { is } from '../../../util/ModelUtil'; var HIGH_PRIORITY = 1500; /** * Correct hover targets in certain situations to improve diagram interaction. * * @param {ElementRegistry} elementRegistry * @param {EventBus} eventBus * @param {Canvas} canvas */ export default function FixHoverBehavior(elementRegistry, eventBus, canvas) { eventBus.on([ 'create.hover', 'create.move', 'create.end', 'shape.move.hover', 'shape.move.move', 'shape.move.end' ], HIGH_PRIORITY, function(event) { var context = event.context, shape = context.shape || event.shape, hover = event.hover; var rootElement = canvas.getRootElement(); // ensure group & label elements are dropped always onto the root if (hover !== rootElement && (shape.labelTarget || is(shape, 'postit:Group'))) { event.hover = rootElement; event.hoverGfx = elementRegistry.getGraphics(event.hover); } }); } FixHoverBehavior.$inject = [ 'elementRegistry', 'eventBus', 'canvas' ];