Dragging multiple selected elements #1669
-
Hi i'm using JointJS and Rappid 3.5. i'm trying to implement selecting multiple elements in a similar way as in Kitchensink https://resources.jointjs.com/demos/kitchensink |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 6 replies
-
Here's an answer from Google Groups.
.selection-box {
opacity: 0.3;
/* pointer-events: none; */ is was this line
}
By default, we capture the pointer event on the selection box element and translate all selected elements while the user is dragging. That's why the The |
Beta Was this translation helpful? Give feedback.
-
@kumilingus @Ndmanh123 Hi :) https://resources.jointjs.com/demos/qad Is there a way to solve both issues? |
Beta Was this translation helpful? Give feedback.
-
Doing
together with |
Beta Was this translation helpful? Give feedback.
-
This is the most elegant solution I came up with so far.
import { ui, dia } from '@clientio/rappid';
import styles from './CustomSelection.module.scss';
class CustomSelection extends ui.Selection {
constructor(options: ui.Selection.Options) {
super(options);
this.el.classList.add(styles.customSelection);
options.paper.on(
'element:pointerdown',
this.initiateSelectionForEventTarget.bind(this),
);
}
protected initiateSelectionForEventTarget(
elementView: dia.ElementView,
event: dia.Event,
) {
// allows us to drag multiple selected blocks while still
// using pointer-events: none;
return this.onSelectionBoxPointerDown(event);
}
}
export default CustomSelection;
.customSelection {
:global .selection-box.selection-box {
pointer-events: none; // allows clicking on the port while cell is selected
}
} |
Beta Was this translation helpful? Give feedback.
-
@kumilingus Unfortunately, I started experiencing a bug when selecting a single shape and moving the mouse quickly at the same time to draging. It often caused the selection box to not appear exactly over the shape and was sometimes off by quite a bit.
Thanks to doing
this bug no longer happens for me. |
Beta Was this translation helpful? Give feedback.
Here's an answer from Google Groups.
By default, we capture the pointer event on the selection box element and translate all selected elements while the user is dragging. That's why the
pointer-events: auto
on.selection-box
is important (without this property the target of the pointer event would be the element view itself and the default drag and drop mechanism would be triggered). Please make sure that is not overridden in your application.The