mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Canvas: Add support to rotate a group of elements (#87358)
This commit is contained in:
parent
7bcda34b55
commit
1ef1cc7e3f
@ -489,11 +489,14 @@ export class ElementState implements LayerElement {
|
||||
};
|
||||
|
||||
applyRotate = (event: OnRotate) => {
|
||||
const absoluteRotationDegree = event.absoluteRotation;
|
||||
|
||||
const rotationDelta = event.delta;
|
||||
const placement = this.options.placement!;
|
||||
const placementRotation = placement.rotation ?? 0;
|
||||
|
||||
const calculatedRotation = placementRotation + rotationDelta;
|
||||
|
||||
// Ensure rotation is between 0 and 360
|
||||
placement.rotation = absoluteRotationDegree - Math.floor(absoluteRotationDegree / 360) * 360;
|
||||
placement.rotation = calculatedRotation - Math.floor(calculatedRotation / 360) * 360;
|
||||
event.target.style.transform = event.transform;
|
||||
};
|
||||
|
||||
|
@ -463,6 +463,14 @@ export class Scene {
|
||||
targetedElement.applyRotate(event);
|
||||
}
|
||||
})
|
||||
.on('rotateGroup', (e) => {
|
||||
for (let event of e.events) {
|
||||
const targetedElement = this.findElementByTarget(event.target);
|
||||
if (targetedElement) {
|
||||
targetedElement.applyRotate(event);
|
||||
}
|
||||
}
|
||||
})
|
||||
.on('rotateEnd', () => {
|
||||
this.enableCustomables();
|
||||
// Update the editor with the new rotation
|
||||
|
Loading…
Reference in New Issue
Block a user