Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
feat: add easing functions support for json importing.
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepbox8646 committed Aug 11, 2024
1 parent 23be742 commit 1dc5ebf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/json/src/import-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,23 @@ export function importWidget<T extends typeof Widget>(
widgetData: WidgetFormat | string,
widgets: Record<string, T>,
anims: Record<string, () => any>,
easingFunctions: Record<string, (t: number) => number>,
) {
if (typeof widgetData === 'string') {
widgetData = JSON.parse(widgetData) as WidgetFormat
}
const widget = new widgets[widgetData.type](...processArguments(widgetData.arguments), processOptions(widgetData.options))
if (widgetData.children) {
widget.add(...widgetData.children.map((child) => {
return importWidget(child, widgets, anims)
return importWidget(child, widgets, anims, easingFunctions)
}))
}
if (widgetData.animations) {
widgetData.animations.forEach((animation) => {
widget.animate(anims[animation.type]().withAttr(animation.parameters))
widget.animate(anims[animation.type]().withAttr({
...animation.parameters,
by: easingFunctions[animation.parameters.easingFunctions as string],
}))
})
}
if (widgetData.actions) {
Expand Down

0 comments on commit 1dc5ebf

Please sign in to comment.