Skip to content

Commit

Permalink
refactor: return when static value is found in animatedValueStaticChe…
Browse files Browse the repository at this point in the history
…cker (#108)

* refactor(extract-features): improve animatedValueStaticChecker

* docs: add changeset

* refactor: fix format
  • Loading branch information
Aidosmf authored Aug 28, 2024
1 parent bfbe50b commit d470856
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-panthers-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lottiefiles/relottie-extract-features': patch
---

refactor: break a loop when static-value is found in animatedValueStaticChecker
10 changes: 6 additions & 4 deletions packages/relottie-extract-features/src/used-features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,15 @@ export const animatedValueStaticChecker: IsFeatureUsedChecker<Element> = (node):

if (valueNode.title !== OT.animatedValueStatic) return objectNodeChecker(valueNode);

const staticValueNode = valueNode.children.find((child) => child.title === NT.staticValue);
for (const childNode of valueNode.children) {
if (childNode.title !== NT.staticValue) continue;

const targetNode = staticValueNode?.children[0];
const staticValueNode = childNode.children[0];

if (targetNode?.type !== 'primitive') return false;
if (staticValueNode?.value === 0) return false;

if (targetNode.value === 0) return false;
return true;
}

return true;
};
Expand Down

0 comments on commit d470856

Please sign in to comment.