Skip to content

Commit 3d97468

Browse files
committed
fix manual frameloop
1 parent 47b56b7 commit 3d97468

File tree

3 files changed

+44
-45
lines changed

3 files changed

+44
-45
lines changed

.size-snapshot.json

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"gzipped": 1999
2020
},
2121
"dist/web.js": {
22-
"bundled": 63059,
23-
"minified": 29978,
24-
"gzipped": 10898,
22+
"bundled": 63153,
23+
"minified": 30004,
24+
"gzipped": 10904,
2525
"treeshaked": {
2626
"rollup": {
2727
"code": 11455,
@@ -38,9 +38,9 @@
3838
"gzipped": 11641
3939
},
4040
"dist/native.js": {
41-
"bundled": 60184,
42-
"minified": 28050,
43-
"gzipped": 9921,
41+
"bundled": 60278,
42+
"minified": 28076,
43+
"gzipped": 9927,
4444
"treeshaked": {
4545
"rollup": {
4646
"code": 8256,
@@ -52,9 +52,9 @@
5252
}
5353
},
5454
"dist/universal.js": {
55-
"bundled": 47621,
56-
"minified": 21340,
57-
"gzipped": 7118,
55+
"bundled": 47715,
56+
"minified": 21366,
57+
"gzipped": 7125,
5858
"treeshaked": {
5959
"rollup": {
6060
"code": 1235,
@@ -66,9 +66,9 @@
6666
}
6767
},
6868
"dist/konva.js": {
69-
"bundled": 58681,
70-
"minified": 27202,
71-
"gzipped": 9829,
69+
"bundled": 58775,
70+
"minified": 27228,
71+
"gzipped": 9834,
7272
"treeshaked": {
7373
"rollup": {
7474
"code": 8974,
@@ -157,14 +157,14 @@
157157
"gzipped": 9928
158158
},
159159
"dist/web.cjs.js": {
160-
"bundled": 71464,
161-
"minified": 33758,
162-
"gzipped": 11481
160+
"bundled": 71558,
161+
"minified": 33790,
162+
"gzipped": 11484
163163
},
164164
"dist/native.cjs.js": {
165-
"bundled": 69070,
166-
"minified": 32016,
167-
"gzipped": 10476
165+
"bundled": 69164,
166+
"minified": 32048,
167+
"gzipped": 10484
168168
},
169169
"dist/renderprops.cjs.js": {
170170
"bundled": 77632,
@@ -192,9 +192,9 @@
192192
"gzipped": 10452
193193
},
194194
"dist/universal.cjs.js": {
195-
"bundled": 55697,
196-
"minified": 24987,
197-
"gzipped": 7681
195+
"bundled": 55791,
196+
"minified": 25019,
197+
"gzipped": 7687
198198
},
199199
"dist/test.js": {
200200
"bundled": 32365,
@@ -216,27 +216,27 @@
216216
"gzipped": 5405
217217
},
218218
"dist/konva.cjs.js": {
219-
"bundled": 66798,
220-
"minified": 30880,
221-
"gzipped": 10381
219+
"bundled": 66892,
220+
"minified": 30912,
221+
"gzipped": 10387
222222
},
223223
"dist/three.js": {
224-
"bundled": 58622,
225-
"minified": 27013,
226-
"gzipped": 9703,
224+
"bundled": 58973,
225+
"minified": 27132,
226+
"gzipped": 9745,
227227
"treeshaked": {
228228
"rollup": {
229-
"code": 8805,
230-
"import_statements": 313
229+
"code": 10339,
230+
"import_statements": 344
231231
},
232232
"webpack": {
233-
"code": 10009
233+
"code": 11539
234234
}
235235
}
236236
},
237237
"dist/three.cjs.js": {
238-
"bundled": 66753,
239-
"minified": 30697,
240-
"gzipped": 10253
238+
"bundled": 67146,
239+
"minified": 30864,
240+
"gzipped": 10293
241241
}
242242
}

src/animated/FrameLoop.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,24 +130,23 @@ const update = () => {
130130
if (controllers.size) {
131131
if (manualFrameloop) manualFrameloop()
132132
else requestFrame(update)
133-
} else active = false
133+
} else {
134+
active = false
135+
}
134136
return active
135137
}
136138

137139
const start = (controller: Controller) => {
138-
if (!controllers.has(controller)) {
139-
controllers.add(controller)
140-
if (!active) {
141-
if (manualFrameloop) requestFrame(manualFrameloop)
142-
else requestFrame(update)
143-
}
140+
if (!controllers.has(controller)) controllers.add(controller)
141+
if (!active) {
144142
active = true
143+
if (manualFrameloop) requestFrame(manualFrameloop)
144+
else requestFrame(update)
145145
}
146146
}
147147

148148
const stop = (controller: Controller) => {
149-
if (controllers.has(controller))
150-
controllers.delete(controller)
149+
if (controllers.has(controller)) controllers.delete(controller)
151150
}
152151

153152
export { start, stop, update }

src/targets/three/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as THREE from 'three'
2-
import { applyProps, addEffect, invalidate } from 'react-three-fiber'
2+
import { invalidate, applyProps, addEffect } from 'react-three-fiber'
33
import { interpolate } from '../../interpolate'
44
import animated from '../../animated/createAnimatedComponent'
55
import * as Globals from '../../animated/Globals'
@@ -20,8 +20,8 @@ const extendedAnimated = apply(THREE)
2020
if (addEffect) {
2121
// Add the update function as a global effect to react-three-fibers update loop
2222
addEffect(update)
23-
// Hook up the invalidate function to react-springs update-loop
24-
Globals.injectManualFrameloop(invalidate)
23+
// We don't really need to invalidate, since react-spring is most likely causing invalidation through applyProps
24+
Globals.injectManualFrameloop(() => invalidate())
2525
}
2626

2727
// Set default native-element

0 commit comments

Comments
 (0)