Skip to content

Commit b26b0d4

Browse files
committed
fix: fix shaking restore function
1 parent f484618 commit b26b0d4

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/SvgAnimation.ts

+12-15
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,24 @@ export class SvgAnimation extends Two {
5050
})
5151
}
5252

53-
// to fix original position
54-
const toBasePosition = () =>
53+
const sceneChildrenRestore = () =>
5554
this.scene.children.map((child: Two.Object) => {
56-
this.scene.children.map((child: Two.Object) => {
57-
const vertices = (child as Two.Path).vertices
58-
if (!vertices) return
59-
vertices.map((v: Two.Anchor | any) => {
60-
// TODO: define position types
61-
if (!v.position) {
62-
return
63-
}
64-
v.x = v.position.x
65-
v.y = v.position.y
66-
delete v.position
67-
})
55+
const vertices = (child as Two.Path).vertices
56+
if (!vertices) return
57+
vertices.map((v: Two.Anchor | any) => {
58+
// TODO: define position types
59+
if (!v.position) {
60+
return
61+
}
62+
v.x = v.position.x
63+
v.y = v.position.y
64+
delete v.position
6865
})
6966
})
7067
this.bind('update', updateShake).play()
7168
return () => {
7269
this.unbind('update', updateShake)
73-
toBasePosition()
70+
sceneChildrenRestore()
7471
}
7572
}
7673
/**

0 commit comments

Comments
 (0)