mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Canvas: Show constraints on element drag #52074
This commit is contained in:
parent
2f942c57e8
commit
48e757ff87
@ -44,11 +44,8 @@ export const constraintViewable = (scene: Scene) => ({
|
|||||||
const rect = moveable.getRect();
|
const rect = moveable.getRect();
|
||||||
const targetElement = scene.findElementByTarget(moveable.state.target);
|
const targetElement = scene.findElementByTarget(moveable.state.target);
|
||||||
|
|
||||||
// If target is currently in motion or selection is more than 1 element don't display constraint visualizations
|
// If selection is more than 1 element don't display constraint visualizations
|
||||||
if (
|
if (scene.selecto?.getSelectedTargets() && scene.selecto?.getSelectedTargets().length > 1) {
|
||||||
targetElement?.isMoving ||
|
|
||||||
(scene.selecto?.getSelectedTargets() && scene.selecto?.getSelectedTargets().length > 1)
|
|
||||||
) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,9 +26,6 @@ export class ElementState implements LayerElement {
|
|||||||
sizeStyle: CSSProperties = {};
|
sizeStyle: CSSProperties = {};
|
||||||
dataStyle: CSSProperties = {};
|
dataStyle: CSSProperties = {};
|
||||||
|
|
||||||
// Determine whether or not element is in motion or not (via moveable)
|
|
||||||
isMoving = false;
|
|
||||||
|
|
||||||
// Temp stored constraint for visualization purposes (switch to top / left constraint to simplify some functionality)
|
// Temp stored constraint for visualization purposes (switch to top / left constraint to simplify some functionality)
|
||||||
tempConstraint: Constraint | undefined;
|
tempConstraint: Constraint | undefined;
|
||||||
|
|
||||||
|
@ -326,12 +326,6 @@ export class Scene {
|
|||||||
.on('clickGroup', (event) => {
|
.on('clickGroup', (event) => {
|
||||||
this.selecto!.clickTarget(event.inputEvent, event.inputTarget);
|
this.selecto!.clickTarget(event.inputEvent, event.inputTarget);
|
||||||
})
|
})
|
||||||
.on('dragStart', (event) => {
|
|
||||||
const targetedElement = this.findElementByTarget(event.target);
|
|
||||||
if (targetedElement) {
|
|
||||||
targetedElement.isMoving = true;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.on('drag', (event) => {
|
.on('drag', (event) => {
|
||||||
const targetedElement = this.findElementByTarget(event.target);
|
const targetedElement = this.findElementByTarget(event.target);
|
||||||
targetedElement!.applyDrag(event);
|
targetedElement!.applyDrag(event);
|
||||||
@ -346,7 +340,6 @@ export class Scene {
|
|||||||
const targetedElement = this.findElementByTarget(event.target);
|
const targetedElement = this.findElementByTarget(event.target);
|
||||||
if (targetedElement) {
|
if (targetedElement) {
|
||||||
targetedElement.setPlacementFromConstraint();
|
targetedElement.setPlacementFromConstraint();
|
||||||
targetedElement.isMoving = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.moved.next(Date.now());
|
this.moved.next(Date.now());
|
||||||
|
Loading…
Reference in New Issue
Block a user