@threlte/flex 0.1.1 → 1.0.1
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>import { T, createRawEventDispatcher, currentWritable,
|
|
1
|
+
<script>import { T, createRawEventDispatcher, currentWritable, useTask } from '@threlte/core';
|
|
2
2
|
import { onDestroy } from 'svelte';
|
|
3
3
|
import { Box3, Group, Vector3 } from 'three';
|
|
4
4
|
import { Direction } from 'yoga-layout';
|
|
@@ -19,6 +19,7 @@ export let scaleFactor = 1000;
|
|
|
19
19
|
export let classParser = undefined;
|
|
20
20
|
let _class = '';
|
|
21
21
|
export { _class as class };
|
|
22
|
+
export let reflowStage = undefined;
|
|
22
23
|
const dispatch = createRawEventDispatcher();
|
|
23
24
|
const rootGroup = new Group();
|
|
24
25
|
rootGroup.userData.isNode = true;
|
|
@@ -31,7 +32,7 @@ const { width: computedWidth, height: computedHeight } = createUseDimensionsCont
|
|
|
31
32
|
/**
|
|
32
33
|
* Reflowing inside useFrame automatically batches reflows to 1 per frame.
|
|
33
34
|
*/
|
|
34
|
-
const { start: reflow, stop } =
|
|
35
|
+
const { start: reflow, stop } = useTask(Symbol('threlte-flex-reflow'), () => {
|
|
35
36
|
flexContext.emit('reflow:before');
|
|
36
37
|
for (const { node, group, props } of flexContext.nodes.values()) {
|
|
37
38
|
const scaledWidth = typeof props.width === 'number' ? props.width * scaleFactor : props.width;
|
|
@@ -81,7 +82,10 @@ const { start: reflow, stop } = useFrame(() => {
|
|
|
81
82
|
height: computedHeight.current
|
|
82
83
|
});
|
|
83
84
|
stop();
|
|
84
|
-
}, {
|
|
85
|
+
}, {
|
|
86
|
+
stage: reflowStage,
|
|
87
|
+
autoStart: false
|
|
88
|
+
});
|
|
85
89
|
const flexContext = createFlexContext({
|
|
86
90
|
yoga,
|
|
87
91
|
nodes: new Map(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { Stage } from '@threlte/core'
|
|
1
2
|
import { SvelteComponent } from 'svelte'
|
|
2
3
|
import type { Direction, Yoga } from 'yoga-layout'
|
|
3
|
-
import type { NodeProps } from '../lib/props'
|
|
4
|
-
import type { ClassParser, FlexPlane } from '../lib/props'
|
|
4
|
+
import type { ClassParser, FlexPlane, NodeProps } from '../lib/props'
|
|
5
5
|
|
|
6
6
|
type InnerFlexProps = NodeProps & {
|
|
7
7
|
yoga: Yoga
|
|
@@ -12,6 +12,7 @@ type InnerFlexProps = NodeProps & {
|
|
|
12
12
|
scaleFactor?: number
|
|
13
13
|
class?: string
|
|
14
14
|
classParser?: ClassParser
|
|
15
|
+
reflowStage?: Stage
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
type InnerFlexEvents = {
|
package/dist/Flex/context.js
CHANGED
package/package.json
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@threlte/flex",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"author": "Grischa Erbe <hello@legrisch.com> (https://legrisch.com)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@sveltejs/adapter-auto": "^
|
|
8
|
-
"@sveltejs/kit": "^
|
|
9
|
-
"@sveltejs/package": "^2.
|
|
10
|
-
"@
|
|
11
|
-
"@types/
|
|
12
|
-
"@
|
|
13
|
-
"@typescript-eslint/
|
|
14
|
-
"@
|
|
15
|
-
"
|
|
16
|
-
"eslint
|
|
17
|
-
"eslint-
|
|
18
|
-
"
|
|
19
|
-
"prettier
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"svelte
|
|
24
|
-
"svelte-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"@threlte/
|
|
7
|
+
"@sveltejs/adapter-auto": "^3.1.1",
|
|
8
|
+
"@sveltejs/kit": "^2.4.3",
|
|
9
|
+
"@sveltejs/package": "^2.2.6",
|
|
10
|
+
"@sveltejs/vite-plugin-svelte": "^3.0.0",
|
|
11
|
+
"@types/node": "^20.11.6",
|
|
12
|
+
"@types/three": "^0.160.0",
|
|
13
|
+
"@typescript-eslint/eslint-plugin": "^6.19.1",
|
|
14
|
+
"@typescript-eslint/parser": "^6.19.1",
|
|
15
|
+
"@yushijinhun/three-minifier-rollup": "^0.4.0",
|
|
16
|
+
"eslint": "^8.56.0",
|
|
17
|
+
"eslint-config-prettier": "^9.1.0",
|
|
18
|
+
"eslint-plugin-svelte": "^2.35.1",
|
|
19
|
+
"prettier": "^3.2.4",
|
|
20
|
+
"prettier-plugin-svelte": "^3.1.2",
|
|
21
|
+
"publint": "^0.2.7",
|
|
22
|
+
"rimraf": "^5.0.5",
|
|
23
|
+
"svelte": "^4.2.9",
|
|
24
|
+
"svelte-check": "^3.6.3",
|
|
25
|
+
"svelte-preprocess": "^5.1.3",
|
|
26
|
+
"svelte2tsx": "^0.7.0",
|
|
27
|
+
"three": "^0.160.1",
|
|
28
|
+
"tslib": "^2.6.2",
|
|
29
|
+
"typescript": "^5.3.3",
|
|
30
|
+
"vite": "^5.0.12",
|
|
31
|
+
"@threlte/core": "7.0.12",
|
|
32
|
+
"@threlte/extras": "8.5.0"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"mitt": "^3.0.1",
|
|
35
|
-
"yoga-layout": "^2.0.
|
|
36
|
+
"yoga-layout": "^2.0.1"
|
|
36
37
|
},
|
|
37
38
|
"peerDependencies": {
|
|
38
39
|
"svelte": ">=4",
|