easy-layout 5.0.102 → 5.0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example.js +264 -49
- package/lib/div/splitter/horizontal.js +19 -19
- package/lib/div/splitter/vertical.js +19 -19
- package/lib/div/splitter.js +18 -13
- package/lib/index.js +8 -1
- package/lib/section/sizeable.js +189 -0
- package/package.json +1 -1
- package/src/div/splitter/horizontal.js +18 -18
- package/src/div/splitter/vertical.js +18 -18
- package/src/div/splitter.js +22 -11
- package/src/index.js +1 -0
- package/src/section/sizeable.js +19 -0
package/package.json
CHANGED
|
@@ -29,22 +29,22 @@ class HorizontalSplitter extends Splitter {
|
|
|
29
29
|
|
|
30
30
|
if (dragging) {
|
|
31
31
|
const direction = this.getDirection(),
|
|
32
|
-
|
|
32
|
+
sizeableElement = this.getSizeableElement();
|
|
33
33
|
|
|
34
34
|
const previousMouseTop = this.getPreviousMouseTop(),
|
|
35
|
-
|
|
35
|
+
previousSizeableElementHeight = this.getPreviousSizeableElementHeight(),
|
|
36
36
|
relativeMouseTop = mouseTop - previousMouseTop;
|
|
37
37
|
|
|
38
|
-
let
|
|
38
|
+
let sizeableElementHeight = previousSizeableElementHeight - direction * relativeMouseTop;
|
|
39
39
|
|
|
40
|
-
const height =
|
|
40
|
+
const height = sizeableElementHeight, ///
|
|
41
41
|
eventType = DRAG_EVENT_TYPE;
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
sizeableElement.setHeight(height);
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
sizeableElementHeight = sizeableElement.getHeight(); ///
|
|
46
46
|
|
|
47
|
-
this.callHandlers(eventType,
|
|
47
|
+
this.callHandlers(eventType, sizeableElementHeight);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -56,14 +56,14 @@ class HorizontalSplitter extends Splitter {
|
|
|
56
56
|
|
|
57
57
|
if (!disabled) {
|
|
58
58
|
const dragging = this.isDragging(),
|
|
59
|
-
|
|
59
|
+
sizeableElement = this.getSizeableElement(),
|
|
60
60
|
previousMouseTop = mouseTop, ///
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
sizeableElementHeight = sizeableElement.getHeight(),
|
|
62
|
+
previousSizeableElementHeight = sizeableElementHeight; ///
|
|
63
63
|
|
|
64
64
|
this.setPreviousMouseTop(previousMouseTop);
|
|
65
65
|
|
|
66
|
-
this.
|
|
66
|
+
this.setPreviousSizeableElementHeight(previousSizeableElementHeight);
|
|
67
67
|
|
|
68
68
|
rowResizeCursor();
|
|
69
69
|
|
|
@@ -80,11 +80,11 @@ class HorizontalSplitter extends Splitter {
|
|
|
80
80
|
return previousMouseTop;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
getPreviousSizeableElementHeight() {
|
|
84
84
|
const state = this.getState(),
|
|
85
|
-
{
|
|
85
|
+
{ previousSizeableElementHeight } = state;
|
|
86
86
|
|
|
87
|
-
return
|
|
87
|
+
return previousSizeableElementHeight;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
setPreviousMouseTop(previousMouseTop) {
|
|
@@ -93,19 +93,19 @@ class HorizontalSplitter extends Splitter {
|
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
setPreviousSizeableElementHeight(previousSizeableElementHeight) {
|
|
97
97
|
this.updateState({
|
|
98
|
-
|
|
98
|
+
previousSizeableElementHeight
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
setInitialState() {
|
|
103
103
|
const previousMouseTop = null,
|
|
104
|
-
|
|
104
|
+
previousSizeableElementHeight = null;
|
|
105
105
|
|
|
106
106
|
this.setState({
|
|
107
107
|
previousMouseTop,
|
|
108
|
-
|
|
108
|
+
previousSizeableElementHeight
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -29,22 +29,22 @@ class VerticalSplitter extends Splitter {
|
|
|
29
29
|
|
|
30
30
|
if (dragging) {
|
|
31
31
|
const direction = this.getDirection(),
|
|
32
|
-
|
|
32
|
+
sizeableElement = this.getSizeableElement();
|
|
33
33
|
|
|
34
34
|
const previousMouseLeft = this.getPreviousMouseLeft(),
|
|
35
|
-
|
|
35
|
+
previousSizeableElementWidth = this.getPreviousSizeableElementWidth(),
|
|
36
36
|
relativeMouseLeft = mouseLeft - previousMouseLeft;
|
|
37
37
|
|
|
38
|
-
let
|
|
38
|
+
let sizeableElementWidth = previousSizeableElementWidth - direction * relativeMouseLeft;
|
|
39
39
|
|
|
40
|
-
const width =
|
|
40
|
+
const width = sizeableElementWidth, ///
|
|
41
41
|
eventType = DRAG_EVENT_TYPE;
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
sizeableElement.setWidth(width);
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
sizeableElementWidth = sizeableElement.getWidth(); ///
|
|
46
46
|
|
|
47
|
-
this.callHandlers(eventType,
|
|
47
|
+
this.callHandlers(eventType, sizeableElementWidth);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -56,14 +56,14 @@ class VerticalSplitter extends Splitter {
|
|
|
56
56
|
|
|
57
57
|
if (!disabled) {
|
|
58
58
|
const dragging = this.isDragging(),
|
|
59
|
-
|
|
59
|
+
sizeableElement = this.getSizeableElement(),
|
|
60
60
|
previousMouseLeft = mouseLeft, ///
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
sizeableElementWidth = sizeableElement.getWidth(),
|
|
62
|
+
previousSizeableElementWidth = sizeableElementWidth; ///
|
|
63
63
|
|
|
64
64
|
this.setPreviousMouseLeft(previousMouseLeft);
|
|
65
65
|
|
|
66
|
-
this.
|
|
66
|
+
this.setPreviousSizeableElementWidth(previousSizeableElementWidth);
|
|
67
67
|
|
|
68
68
|
columnResizeCursor();
|
|
69
69
|
|
|
@@ -80,11 +80,11 @@ class VerticalSplitter extends Splitter {
|
|
|
80
80
|
return previousMouseLeft;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
getPreviousSizeableElementWidth() {
|
|
84
84
|
const state = this.getState(),
|
|
85
|
-
{
|
|
85
|
+
{ previousSizeableElementWidth } = state;
|
|
86
86
|
|
|
87
|
-
return
|
|
87
|
+
return previousSizeableElementWidth;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
setPreviousMouseLeft(previousMouseLeft) {
|
|
@@ -93,19 +93,19 @@ class VerticalSplitter extends Splitter {
|
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
setPreviousSizeableElementWidth(previousSizeableElementWidth) {
|
|
97
97
|
this.updateState({
|
|
98
|
-
|
|
98
|
+
previousSizeableElementWidth
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
setInitialState() {
|
|
103
103
|
const previousMouseLeft = null,
|
|
104
|
-
|
|
104
|
+
previousSizeableElementWidth = null;
|
|
105
105
|
|
|
106
106
|
this.setState({
|
|
107
107
|
previousMouseLeft,
|
|
108
|
-
|
|
108
|
+
previousSizeableElementWidth
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
|
package/src/div/splitter.js
CHANGED
|
@@ -5,6 +5,7 @@ import withStyle from "easy-with-style"; ///
|
|
|
5
5
|
import { window, Element, eventTypes } from "easy";
|
|
6
6
|
|
|
7
7
|
import SizeableDiv from "../div/sizeable";
|
|
8
|
+
import SizeableSection from "../section/sizeable";
|
|
8
9
|
|
|
9
10
|
import { resetCursor } from "../cursor";
|
|
10
11
|
import { ESCAPE_KEY_CODE } from "../constants";
|
|
@@ -114,34 +115,38 @@ class SplitterDiv extends Element {
|
|
|
114
115
|
let direction;
|
|
115
116
|
|
|
116
117
|
const nextSiblingElement = this.getNextSiblingElement(),
|
|
117
|
-
previousSiblingElement = this.getPreviousSiblingElement()
|
|
118
|
+
previousSiblingElement = this.getPreviousSiblingElement(),
|
|
119
|
+
nextSiblingElementSizeableElement = isElementSizeableElement(nextSiblingElement),
|
|
120
|
+
previousSiblingElementSizeableElement = isElementSizeableElement(previousSiblingElement);
|
|
118
121
|
|
|
119
|
-
if (
|
|
122
|
+
if (nextSiblingElementSizeableElement) {
|
|
120
123
|
direction = +1;
|
|
121
124
|
}
|
|
122
125
|
|
|
123
|
-
if (
|
|
126
|
+
if (previousSiblingElementSizeableElement) {
|
|
124
127
|
direction = -1;
|
|
125
128
|
}
|
|
126
129
|
|
|
127
130
|
return direction;
|
|
128
131
|
}
|
|
129
132
|
|
|
130
|
-
|
|
131
|
-
let
|
|
133
|
+
getSizeableElement() {
|
|
134
|
+
let sizeableElement;
|
|
132
135
|
|
|
133
136
|
const nextSiblingElement = this.getNextSiblingElement(),
|
|
134
|
-
previousSiblingElement = this.getPreviousSiblingElement()
|
|
137
|
+
previousSiblingElement = this.getPreviousSiblingElement(),
|
|
138
|
+
nextSiblingElementSizeableElement = isElementSizeableElement(nextSiblingElement),
|
|
139
|
+
previousSiblingElementSizeableElement = isElementSizeableElement(previousSiblingElement);
|
|
135
140
|
|
|
136
|
-
if (
|
|
137
|
-
|
|
141
|
+
if (nextSiblingElementSizeableElement) {
|
|
142
|
+
sizeableElement = nextSiblingElement; ///
|
|
138
143
|
}
|
|
139
144
|
|
|
140
|
-
if (
|
|
141
|
-
|
|
145
|
+
if (previousSiblingElementSizeableElement) {
|
|
146
|
+
sizeableElement = previousSiblingElement; ///
|
|
142
147
|
}
|
|
143
148
|
|
|
144
|
-
return
|
|
149
|
+
return sizeableElement;
|
|
145
150
|
}
|
|
146
151
|
|
|
147
152
|
startDrag() {
|
|
@@ -283,3 +288,9 @@ export default withStyle(SplitterDiv)`
|
|
|
283
288
|
flex-shrink: 0;
|
|
284
289
|
|
|
285
290
|
`;
|
|
291
|
+
|
|
292
|
+
function isElementSizeableElement(element) {
|
|
293
|
+
const elementSizeableElement = (element instanceof SizeableDiv) || (element instanceof SizeableSection);
|
|
294
|
+
|
|
295
|
+
return elementSizeableElement;
|
|
296
|
+
}
|
package/src/index.js
CHANGED
|
@@ -8,5 +8,6 @@ export { default as ColumnDiv } from "./div/column";
|
|
|
8
8
|
export { default as ColumnsDiv } from "./div/columns";
|
|
9
9
|
export { default as SplitterDiv } from "./div/splitter";
|
|
10
10
|
export { default as SizeableDiv } from "./div/sizeable";
|
|
11
|
+
export { default as SizeableSection } from "./section/sizeable";
|
|
11
12
|
export { default as VerticalSplitterDiv } from "./div/splitter/vertical";
|
|
12
13
|
export { default as HorizontalSplitterDiv } from "./div/splitter/horizontal";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import withStyle from "easy-with-style"; ///
|
|
4
|
+
|
|
5
|
+
import { Element } from "easy";
|
|
6
|
+
|
|
7
|
+
class SizeableSection extends Element {
|
|
8
|
+
static tagName = "section";
|
|
9
|
+
|
|
10
|
+
static defaultProperties = {
|
|
11
|
+
className: "sizeable"
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default withStyle(SizeableSection)`
|
|
16
|
+
|
|
17
|
+
display: flex;
|
|
18
|
+
|
|
19
|
+
`;
|