You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-38Lines changed: 33 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,74 +5,69 @@ A simple bounding box widget empowering users with the ability to move, rotate o
5
5
6
6
## Usage
7
7
8
-
```
9
8
# create a new ldr instance.
10
9
ldr = new ldResize ...
11
10
12
11
# attach to certain node.
13
12
ldr.attach node
14
13
15
14
ldr.on \resize, -> ...
16
-
satate = ldr.get!
15
+
state = ldr.get!
17
16
18
17
ldr.detach!
19
-
```
20
18
21
19
22
20
## Configuration
23
21
24
22
configs are set in a object which is passed into the ldResize constructor. For example:
25
23
26
-
```
27
24
new ldResize({root: ".root"});
28
-
```
29
25
30
26
31
27
## Configuration
32
28
33
-
* host - CSS selector or element where to put resize widget elements. will use `root` if `host` is omitted.
34
-
* root - CSS selector or element for the container of the elements to be resized.
29
+
*`host` - CSS selector or element where to put resize widget elements. will use `root` if `host` is omitted.
30
+
*`root` - CSS selector or element for the container of the elements to be resized.
35
31
ldResize automatically intercept mouse events for elements in `root` and handle the interactions.
36
-
* filter(n) - callback function to determine if an element `n` should be resized.
32
+
*`filter(n)` - callback function to determine if an element `n` should be resized.
37
33
ldResize by default resizes all elements if filter is omitted.
38
34
called on mousedown on root element.
39
-
* mousedown - TBD
40
-
* visible-ctrl-r - default false. show all rotating ctrl node if true.
35
+
*`mousedown` - TBD
36
+
*`visible-ctrl-r` - default false. show all rotating ctrl node if true.
41
37
42
38
43
39
## API
44
40
45
-
46
-
* attach(n,append): attach resizer to certain node(s) and show resize widget.
47
-
- n: node(s) to be attached. can be a list or a single node. equivalent to detech if n = null.
48
-
- append: default false. append n to current attached list if true.
49
-
* detect(): clear attached list and hide resize widget.
50
-
* render(): update transformation of resize widget and attached nodes.
51
-
* pts: internal api ( TBD )
52
-
* box-offset: internal api ( TBD )
53
-
* get(): return an object representing transformation information as follow:
54
-
- t: {x, y} - translate
55
-
- s: {x, y} - scale
56
-
- r - rotate
57
-
- x, y, w, h - Bounding Rect. ( TBD? )
58
-
- box - TBD
59
-
* on(name, cb) - handle specific event `name` with function `cb`.
41
+
*`attach(n,append)`: attach resizer to certain node(s) and show resize widget.
42
+
-`n`: node(s) to be attached. can be a list or a single node. equivalent to detech if n = null.
43
+
-`append`: default false. append n to current attached list if true.
44
+
*`detect()`: clear attached list and hide resize widget.
45
+
*`render()`: update transformation of resize widget and attached nodes.
46
+
*`pts`: internal api ( TBD )
47
+
*`box-offset`: internal api ( TBD )
48
+
*`get()`: return an object representing transformation information as follow:
49
+
-`t`: {x, y} - translate
50
+
-`s`: {x, y} - scale
51
+
-`r`: rotate
52
+
-`x, y, w, h`: Bounding Rect. ( TBD? )
53
+
-`box`: TBD
54
+
*`on(name, cb)`: handle specific event `name` with function `cb`.
60
55
61
56
### API ( WIP )
62
-
* set({t: {x, y}, s: {x, y}, r}, delta) - set affine transformation for attached node. ( No Yet Implemented )
57
+
*`set({t`: {x, y}, s: {x, y}, r}, delta): set affine transformation for attached node. ( No Yet Implemented )
63
58
if delta is true, all values in params are relative to current values.
64
59
65
60
66
61
## Events
67
62
68
-
*`resize` - fire when resizing ( including translating, rotating and scaling ). arguments:
69
-
- dim: transformation information. see `get` API for more information.
70
-
- targets: list of affected nods
63
+
*`resize`: fire when resizing ( including translating, rotating and scaling ). arguments:
64
+
-`dim`: transformation information. see `get` API for more information.
65
+
-`targets`: list of affected nods
71
66
72
67
73
68
## Widget Hierarchy
74
69
75
-
ldResize will add a set of SVG elements for controlling the resize of any elements. this reizer widget is constructed as following hierarchy:
70
+
ldResize will add a set of SVG elements for controlling the resize of any elements. This reizer widget is constructed with following structure:
76
71
77
72
* g
78
73
- path.ldr-ctrl.bbox
@@ -82,21 +77,21 @@ ldResize will add a set of SVG elements for controlling the resize of any elemen
82
77
83
78
## CSS Classes Used
84
79
85
-
* ldr-host - host element
86
-
- ldr-host-standalone - added on host element if root != host
87
-
* ldr-ctrl - control points
88
-
-r - ctrl points for rotating
89
-
-s - ctrl points for resizing
90
-
- bbox - wireframe of the resize rectangle
80
+
*`ldr-host` - host element
81
+
-`ldr-host-standalone` - added on host element if root != host
82
+
*`ldr-ctrl` - control points
83
+
-`r` - ctrl points for rotating
84
+
-`s` - ctrl points for resizing
85
+
-`bbox` - wireframe of the resize rectangle
91
86
92
87
93
88
## Technical Note
94
89
95
90
* Additional interface:
96
-
*```node._lasttransform``` - old transform attribute will be stored in this attribute of specific node when ldResize is going to overwrite it.
91
+
*`node._lasttransform` - old transform attribute will be stored in this attribute of specific node when ldResize is going to overwrite it.
97
92
- currently, this is only done when _lasttransform is undefined.
98
93
- TODO: add opt for customize attr name and store timing?
99
-
* ldResize store transformation matrix for both parent and node in _mo and _mi member of an element. Also, old transform info is stored in _lasttransform. This is somewhat hacky, maybe we can find a better way to replace these in the future.
94
+
* ldResize store transformation matrix for both parent and node in `_mo` and `_mi` member of an element. Also, old transform info is stored in `_lasttransform`. This is somewhat hacky, maybe we can find a better way to replace these in the future.
0 commit comments