Skip to content

Commit

Permalink
feat: added transform origin support
Browse files Browse the repository at this point in the history
  • Loading branch information
nichollascarter committed Feb 13, 2022
1 parent 7995cf5 commit 75e33de
Show file tree
Hide file tree
Showing 7 changed files with 360 additions and 159 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018-2021
Copyright (c) 2018-2022

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,24 @@ xDraggable.applyAlignment('tr');
// useful when element's container was transformed from outside
xDraggable.fitControlsToSize();

// Returns rotation point handle to default position
xDraggable.resetCenterPoint();
```
// Sets the origin for an element's transformations
xDraggable.setTransformOrigin(
{
x, // absolute the origin's position x coordinate
y, // absolute he origin's position y coordinate
dx, // offset the origin's position x coordinate
dy // offset the origin's position y coordinate
},
pin // leaves current origin fixed if true or not if false
);

// Sets transform origin to default
xDraggable.resetTransformOrigin();

// Returns element's current dimensions
xDraggable.getDimensions();
```
transformOrigin
### Options

|Property|Description|Type|Default|
Expand All @@ -149,6 +163,7 @@ xDraggable.resetCenterPoint();
| **restrict** | Restricts element dragging/resizing/rotation | `'selector'` \| `element` | - |
| **rotatorAnchor** | Rotator anchor direction | `string`: 'n' \| 's' \| 'w' \| 'e' | 'e' |
| **rotatorOffset** | Rotator offset | `number` | 50 |
| **transformOrigin** | Sets the origin for an element's transformations | `boolean` \| Array<number> | false |

#### Notice: In most cases, it is recommended to use 'proportions' option

Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const libraryName = 'subjx';

const banner = `/*@license
* Drag/Rotate/Resize Library
* Released under the MIT license, 2018-2021
* Released under the MIT license, 2018-2022
* Karen Sarksyan
* [email protected]
*/`;
Expand Down
Loading

0 comments on commit 75e33de

Please sign in to comment.