@lightningjs/blits 1.9.2 → 1.10.0
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/CHANGELOG.md +12 -0
- package/docs/built-in/layout.md +8 -0
- package/package.json +2 -2
- package/src/component.js +2 -1
- package/src/components/RouterView.js +5 -2
- package/src/components/RouterView.orig.js +5 -2
- package/src/engines/L3/element.js +35 -11
- package/src/focus.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.10.0
|
|
4
|
+
|
|
5
|
+
_8 nov 2024_
|
|
6
|
+
|
|
7
|
+
- Fixed issue with back button not bubbling to App component after last page in router history is popped
|
|
8
|
+
- Added `align-items` attribute to Layout component
|
|
9
|
+
- Fixed issue with watching nested state variables and global state
|
|
10
|
+
- Upgraded to renderer 2.6.2
|
|
11
|
+
- Fixed issue with white background for Elements with falsy src attribute
|
|
12
|
+
- Fixed issue with calling focus on component that already is focussed
|
|
13
|
+
|
|
14
|
+
|
|
3
15
|
## v1.9.2
|
|
4
16
|
|
|
5
17
|
_5 nov 2024_
|
package/docs/built-in/layout.md
CHANGED
|
@@ -37,6 +37,14 @@ In order to align vertically use `<Layout direction="vertical"></Layout>`. And u
|
|
|
37
37
|
|
|
38
38
|
By default the Layout-component places each Element directly besides (or below) the previous one. By adding the `gap`-attribute you can control how much space will be added between each Element or Component. The `gap`-attribute accepts a number in pixels.
|
|
39
39
|
|
|
40
|
+
### Aligning items
|
|
41
|
+
|
|
42
|
+
The layout component positions its children based on the provided direction (`horizontal` or `vertical`). With the `align-items`-attribute you can specify how to align the children on the opposite axis:
|
|
43
|
+
|
|
44
|
+
- `start` (the default value) - aligns the children in the _top_ for horizontal layouts, and on the _left_ for vertical layouts
|
|
45
|
+
- `center` - align the children in the center
|
|
46
|
+
- `end` - aligns the children in the _bottom_ for horizontal layouts, and on the _right_ for vertical layouts
|
|
47
|
+
|
|
40
48
|
### Dynamic dimensions
|
|
41
49
|
|
|
42
50
|
For the Layout component to work properly, the direct children all need to have dimensions (i.e `w` and `h` attributes). The exception here being Text elements.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightningjs/blits",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Blits: The Lightning 3 App Development Framework",
|
|
5
5
|
"bin": "bin/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@lightningjs/msdf-generator": "^1.1.0",
|
|
53
|
-
"@lightningjs/renderer": "^2.6.
|
|
53
|
+
"@lightningjs/renderer": "^2.6.2"
|
|
54
54
|
},
|
|
55
55
|
"repository": {
|
|
56
56
|
"type": "git",
|
package/src/component.js
CHANGED
|
@@ -176,6 +176,7 @@ const Component = (name = required('name'), config = required('config')) => {
|
|
|
176
176
|
for (let i = 0; i < watcherkeysLength; i++) {
|
|
177
177
|
let target = this
|
|
178
178
|
let key = watcherkeys[i]
|
|
179
|
+
const watchKey = key
|
|
179
180
|
// when dot notation used, find the nested target
|
|
180
181
|
if (key.indexOf('.') > -1) {
|
|
181
182
|
const keys = key.split('.')
|
|
@@ -190,7 +191,7 @@ const Component = (name = required('name'), config = required('config')) => {
|
|
|
190
191
|
effect((force = false) => {
|
|
191
192
|
const newValue = target[key]
|
|
192
193
|
if (old !== newValue || force === true) {
|
|
193
|
-
this[symbols.watchers][
|
|
194
|
+
this[symbols.watchers][watchKey].apply(this, [newValue, old])
|
|
194
195
|
old = newValue
|
|
195
196
|
}
|
|
196
197
|
})
|
|
@@ -24,9 +24,11 @@ import Settings from '../../settings.js'
|
|
|
24
24
|
|
|
25
25
|
const layoutFn = function (config) {
|
|
26
26
|
let offset = 0
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const
|
|
27
|
+
const position = config.direction === 'vertical' ? 'y' : 'x'
|
|
28
|
+
const oppositePosition = config.direction === 'vertical' ? 'x' : 'y'
|
|
29
|
+
const oppositeMount = config.direction === 'vertical' ? 'mountX' : 'mountY'
|
|
30
|
+
const dimension = config.direction === 'vertical' ? 'height' : 'width'
|
|
31
|
+
const oppositeDimension = config.direction === 'vertical' ? 'width' : 'height'
|
|
30
32
|
|
|
31
33
|
const children = this.children
|
|
32
34
|
const childrenLength = children.length
|
|
@@ -34,11 +36,11 @@ const layoutFn = function (config) {
|
|
|
34
36
|
const gap = config.gap || 0
|
|
35
37
|
for (let i = 0; i < childrenLength; i++) {
|
|
36
38
|
const node = children[i]
|
|
37
|
-
node[
|
|
39
|
+
node[position] = offset
|
|
38
40
|
// todo: temporary text check, due to 1px width of empty text node
|
|
39
|
-
if (
|
|
41
|
+
if (dimension === 'width') {
|
|
40
42
|
offset += node.width + (node.width !== ('text' in node ? 1 : 0) ? gap : 0)
|
|
41
|
-
} else if (
|
|
43
|
+
} else if (dimension === 'height') {
|
|
42
44
|
offset +=
|
|
43
45
|
'text' in node
|
|
44
46
|
? node.width > 1
|
|
@@ -48,11 +50,25 @@ const layoutFn = function (config) {
|
|
|
48
50
|
? node.height + gap
|
|
49
51
|
: 0
|
|
50
52
|
}
|
|
51
|
-
otherDimension = Math.max(otherDimension, node[
|
|
53
|
+
otherDimension = Math.max(otherDimension, node[oppositeDimension])
|
|
52
54
|
}
|
|
53
55
|
// adjust the size of the layout container
|
|
54
|
-
this[
|
|
55
|
-
this[
|
|
56
|
+
this[dimension] = offset - gap
|
|
57
|
+
this[oppositeDimension] = otherDimension
|
|
58
|
+
|
|
59
|
+
const align = {
|
|
60
|
+
start: 0,
|
|
61
|
+
end: 1,
|
|
62
|
+
center: 0.5,
|
|
63
|
+
}[config['align-items'] || 'start']
|
|
64
|
+
|
|
65
|
+
if (align !== 0) {
|
|
66
|
+
for (let i = 0; i < childrenLength; i++) {
|
|
67
|
+
const node = children[i]
|
|
68
|
+
node[oppositePosition] = otherDimension
|
|
69
|
+
node[oppositeMount] = align
|
|
70
|
+
}
|
|
71
|
+
}
|
|
56
72
|
}
|
|
57
73
|
|
|
58
74
|
const isTransition = (value) => {
|
|
@@ -146,7 +162,7 @@ const propsTransformer = {
|
|
|
146
162
|
set src(v) {
|
|
147
163
|
this.props['src'] = v
|
|
148
164
|
if (this.raw['color'] === undefined) {
|
|
149
|
-
this.props['color'] = 0xffffffff
|
|
165
|
+
this.props['color'] = this.props['src'] ? 0xffffffff : 0x00000000
|
|
150
166
|
}
|
|
151
167
|
},
|
|
152
168
|
set texture(v) {
|
|
@@ -225,7 +241,15 @@ const propsTransformer = {
|
|
|
225
241
|
}
|
|
226
242
|
},
|
|
227
243
|
set show(v) {
|
|
228
|
-
|
|
244
|
+
if (v) {
|
|
245
|
+
this.props['alpha'] = 1
|
|
246
|
+
this.props['width'] = this.raw['w'] || this.raw['width']
|
|
247
|
+
this.props['height'] = this.raw['h'] || this.raw['height']
|
|
248
|
+
} else {
|
|
249
|
+
this.props['alpha'] = 0
|
|
250
|
+
this.props['width'] = 0
|
|
251
|
+
this.props['height'] = 0
|
|
252
|
+
}
|
|
229
253
|
},
|
|
230
254
|
set alpha(v) {
|
|
231
255
|
this.props['alpha'] = v
|
package/src/focus.js
CHANGED
|
@@ -38,6 +38,7 @@ export default {
|
|
|
38
38
|
return focusedComponent
|
|
39
39
|
},
|
|
40
40
|
set(component, event) {
|
|
41
|
+
if (component === focusedComponent) return
|
|
41
42
|
clearTimeout(setFocusTimeout)
|
|
42
43
|
focusedComponent && focusedComponent !== component.parent && focusedComponent.unfocus()
|
|
43
44
|
focusChain.reverse().forEach((cmp) => cmp.unfocus())
|