Skip to content
Snippets Groups Projects
Commit baf46b21 authored by adroitwhiz's avatar adroitwhiz Committed by Ben Wheeler
Browse files

Only call renderer.pick() on draggable drawables

parent b12d8248
No related branches found
No related tags found
No related merge requests found
...@@ -342,16 +342,24 @@ class Stage extends React.Component { ...@@ -342,16 +342,24 @@ class Stage extends React.Component {
} }
onStartDrag (x, y) { onStartDrag (x, y) {
if (this.state.dragId) return; if (this.state.dragId) return;
const drawableId = this.renderer.pick(x, y);
// Because pick queries are expensive, only perform them for drawables that are currently draggable.
let draggableTargets = this.props.vm.runtime.targets;
if (!this.props.useEditorDragStyle) {
draggableTargets = draggableTargets.filter(
target => Number.isFinite(target.drawableID) && target.draggable
);
}
if (draggableTargets.length === 0) return;
const draggableIDs = draggableTargets.map(target => target.drawableID);
const drawableId = this.renderer.pick(x, y, 1, 1, draggableIDs);
if (drawableId === null) return; if (drawableId === null) return;
const targetId = this.props.vm.getTargetIdForDrawableId(drawableId); const targetId = this.props.vm.getTargetIdForDrawableId(drawableId);
if (targetId === null) return; if (targetId === null) return;
const target = this.props.vm.runtime.getTargetById(targetId); const target = this.props.vm.runtime.getTargetById(targetId);
// Do not start drag unless in editor drag mode or target is draggable
if (!(this.props.useEditorDragStyle || target.draggable)) return;
// Dragging always brings the target to the front // Dragging always brings the target to the front
target.goToFront(); target.goToFront();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment