-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Dragging elements in a rotated coordinate system #751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,12 +103,13 @@ export function createCoreData(draggable: DraggableCore, x: number, y: number): | |
// Create an data exposed by <Draggable>'s events | ||
export function createDraggableData(draggable: Draggable, coreData: DraggableData): DraggableData { | ||
const scale = draggable.props.scale; | ||
const angleRadian = Math.PI * draggable.props.angle / 180.0; | ||
return { | ||
node: coreData.node, | ||
x: draggable.state.x + (coreData.deltaX / scale), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is nice; however the vast majority of usage of this library will have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Certainly! |
||
y: draggable.state.y + (coreData.deltaY / scale), | ||
deltaX: (coreData.deltaX / scale), | ||
deltaY: (coreData.deltaY / scale), | ||
x: draggable.state.x + coreData.deltaX * Math.cos(angleRadian) / scale + coreData.deltaY * Math.sin(angleRadian) / scale, | ||
y: draggable.state.y - coreData.deltaX * Math.sin(angleRadian) / scale + coreData.deltaY * Math.cos(angleRadian) / scale, | ||
deltaX: coreData.deltaX * Math.cos(angleRadian) / scale + coreData.deltaY * Math.sin(angleRadian) / scale, | ||
deltaY: -coreData.deltaX * Math.sin(angleRadian) / scale + coreData.deltaY * Math.cos(angleRadian) / scale, | ||
lastX: draggable.state.x, | ||
lastY: draggable.state.y | ||
}; | ||
|
Uh oh!
There was an error while loading. Please reload this page.