Skip to content

Commit

Permalink
fix: fix shaking restore function
Browse files Browse the repository at this point in the history
  • Loading branch information
kmkzt committed May 15, 2019
1 parent 419e628 commit 6dff4de
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions src/SvgAnimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,24 @@ export class SvgAnimation extends Two {
})
}

// to fix original position
const toBasePosition = () =>
const sceneChildrenRestore = () =>
this.scene.children.map((child: Two.Object) => {
this.scene.children.map((child: Two.Object) => {
const vertices = (child as Two.Path).vertices
if (!vertices) return
vertices.map((v: Two.Anchor | any) => {
// TODO: define position types
if (!v.position) {
return
}
v.x = v.position.x
v.y = v.position.y
delete v.position
})
const vertices = (child as Two.Path).vertices
if (!vertices) return
vertices.map((v: Two.Anchor | any) => {
// TODO: define position types
if (!v.position) {
return
}
v.x = v.position.x
v.y = v.position.y
delete v.position
})
})
this.bind('update', updateShake).play()
return () => {
this.unbind('update', updateShake)
toBasePosition()
sceneChildrenRestore()
}
}
/**
Expand Down

0 comments on commit 6dff4de

Please sign in to comment.