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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "easy-layout",
3
3
  "author": "James Smith",
4
- "version": "5.0.102",
4
+ "version": "5.0.104",
5
5
  "license": "MIT, Anti-996",
6
6
  "homepage": "https://github.com/djalbat/easy-layout",
7
7
  "description": "Layout elements that work with CSS flexbox.",
@@ -29,22 +29,22 @@ class HorizontalSplitter extends Splitter {
29
29
 
30
30
  if (dragging) {
31
31
  const direction = this.getDirection(),
32
- sizeableDiv = this.getSizeableDiv();
32
+ sizeableElement = this.getSizeableElement();
33
33
 
34
34
  const previousMouseTop = this.getPreviousMouseTop(),
35
- previousSizeableDivHeight = this.getPreviousSizeableDivHeight(),
35
+ previousSizeableElementHeight = this.getPreviousSizeableElementHeight(),
36
36
  relativeMouseTop = mouseTop - previousMouseTop;
37
37
 
38
- let sizeableDivHeight = previousSizeableDivHeight - direction * relativeMouseTop;
38
+ let sizeableElementHeight = previousSizeableElementHeight - direction * relativeMouseTop;
39
39
 
40
- const height = sizeableDivHeight, ///
40
+ const height = sizeableElementHeight, ///
41
41
  eventType = DRAG_EVENT_TYPE;
42
42
 
43
- sizeableDiv.setHeight(height);
43
+ sizeableElement.setHeight(height);
44
44
 
45
- sizeableDivHeight = sizeableDiv.getHeight(); ///
45
+ sizeableElementHeight = sizeableElement.getHeight(); ///
46
46
 
47
- this.callHandlers(eventType, sizeableDivHeight);
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
- sizeableDiv = this.getSizeableDiv(),
59
+ sizeableElement = this.getSizeableElement(),
60
60
  previousMouseTop = mouseTop, ///
61
- sizeableDivHeight = sizeableDiv.getHeight(),
62
- previousSizeableDivHeight = sizeableDivHeight; ///
61
+ sizeableElementHeight = sizeableElement.getHeight(),
62
+ previousSizeableElementHeight = sizeableElementHeight; ///
63
63
 
64
64
  this.setPreviousMouseTop(previousMouseTop);
65
65
 
66
- this.setPreviousSizeableDivHeight(previousSizeableDivHeight);
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
- getPreviousSizeableDivHeight() {
83
+ getPreviousSizeableElementHeight() {
84
84
  const state = this.getState(),
85
- { previousSizeableDivHeight } = state;
85
+ { previousSizeableElementHeight } = state;
86
86
 
87
- return previousSizeableDivHeight;
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
- setPreviousSizeableDivHeight(previousSizeableDivHeight) {
96
+ setPreviousSizeableElementHeight(previousSizeableElementHeight) {
97
97
  this.updateState({
98
- previousSizeableDivHeight
98
+ previousSizeableElementHeight
99
99
  });
100
100
  }
101
101
 
102
102
  setInitialState() {
103
103
  const previousMouseTop = null,
104
- previousSizeableDivHeight = null;
104
+ previousSizeableElementHeight = null;
105
105
 
106
106
  this.setState({
107
107
  previousMouseTop,
108
- previousSizeableDivHeight
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
- sizeableDiv = this.getSizeableDiv();
32
+ sizeableElement = this.getSizeableElement();
33
33
 
34
34
  const previousMouseLeft = this.getPreviousMouseLeft(),
35
- previousSizeableDivWidth = this.getPreviousSizeableDivWidth(),
35
+ previousSizeableElementWidth = this.getPreviousSizeableElementWidth(),
36
36
  relativeMouseLeft = mouseLeft - previousMouseLeft;
37
37
 
38
- let sizeableDivWidth = previousSizeableDivWidth - direction * relativeMouseLeft;
38
+ let sizeableElementWidth = previousSizeableElementWidth - direction * relativeMouseLeft;
39
39
 
40
- const width = sizeableDivWidth, ///
40
+ const width = sizeableElementWidth, ///
41
41
  eventType = DRAG_EVENT_TYPE;
42
42
 
43
- sizeableDiv.setWidth(width);
43
+ sizeableElement.setWidth(width);
44
44
 
45
- sizeableDivWidth = sizeableDiv.getWidth(); ///
45
+ sizeableElementWidth = sizeableElement.getWidth(); ///
46
46
 
47
- this.callHandlers(eventType, sizeableDivWidth);
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
- sizeableDiv = this.getSizeableDiv(),
59
+ sizeableElement = this.getSizeableElement(),
60
60
  previousMouseLeft = mouseLeft, ///
61
- sizeableDivWidth = sizeableDiv.getWidth(),
62
- previousSizeableDivWidth = sizeableDivWidth; ///
61
+ sizeableElementWidth = sizeableElement.getWidth(),
62
+ previousSizeableElementWidth = sizeableElementWidth; ///
63
63
 
64
64
  this.setPreviousMouseLeft(previousMouseLeft);
65
65
 
66
- this.setPreviousSizeableDivWidth(previousSizeableDivWidth);
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
- getPreviousSizeableDivWidth() {
83
+ getPreviousSizeableElementWidth() {
84
84
  const state = this.getState(),
85
- { previousSizeableDivWidth } = state;
85
+ { previousSizeableElementWidth } = state;
86
86
 
87
- return previousSizeableDivWidth;
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
- setPreviousSizeableDivWidth(previousSizeableDivWidth) {
96
+ setPreviousSizeableElementWidth(previousSizeableElementWidth) {
97
97
  this.updateState({
98
- previousSizeableDivWidth
98
+ previousSizeableElementWidth
99
99
  });
100
100
  }
101
101
 
102
102
  setInitialState() {
103
103
  const previousMouseLeft = null,
104
- previousSizeableDivWidth = null;
104
+ previousSizeableElementWidth = null;
105
105
 
106
106
  this.setState({
107
107
  previousMouseLeft,
108
- previousSizeableDivWidth
108
+ previousSizeableElementWidth
109
109
  });
110
110
  }
111
111
 
@@ -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 (nextSiblingElement instanceof SizeableDiv) {
122
+ if (nextSiblingElementSizeableElement) {
120
123
  direction = +1;
121
124
  }
122
125
 
123
- if (previousSiblingElement instanceof SizeableDiv) {
126
+ if (previousSiblingElementSizeableElement) {
124
127
  direction = -1;
125
128
  }
126
129
 
127
130
  return direction;
128
131
  }
129
132
 
130
- getSizeableDiv() {
131
- let sizeableDiv;
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 (nextSiblingElement instanceof SizeableDiv) {
137
- sizeableDiv = nextSiblingElement; ///
141
+ if (nextSiblingElementSizeableElement) {
142
+ sizeableElement = nextSiblingElement; ///
138
143
  }
139
144
 
140
- if (previousSiblingElement instanceof SizeableDiv) {
141
- sizeableDiv = previousSiblingElement; ///
145
+ if (previousSiblingElementSizeableElement) {
146
+ sizeableElement = previousSiblingElement; ///
142
147
  }
143
148
 
144
- return sizeableDiv;
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
+ `;