Skip to content

Commit b1f892b

Browse files
committed
fix: loading files like MyFile.json should be seen as res
1 parent ac58e11 commit b1f892b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/lottie.android.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,13 @@ export class LottieView extends LottieViewBase {
142142
}
143143
if (src[0] === '~') {
144144
this.nativeView.setAnimation('app/' + src.substring(2));
145-
return;
145+
} else if (!src.startsWith('file:/') && src[0] !== '/') {
146+
this.nativeView.setAnimation(src);
147+
} else {
148+
loadLottieJSON(src).then((r) => {
149+
this.nativeView.setAnimationFromJson(r, null);
150+
});
146151
}
147-
loadLottieJSON(src).then((r) => {
148-
this.nativeView.setAnimationFromJson(r, null);
149-
});
150152
}
151153

152154
if (this.autoPlay) {

src/lottie.ios.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ export class LottieView extends LottieViewBase {
5757
if (!/.(json|zip|lottie)$/.test(src)) {
5858
src += '.json';
5959
}
60-
if (src.endsWith('.lottie')) {
60+
if (!src.startsWith('file:/') && src[0] !== '/') {
61+
// seen as res
62+
this.nativeView.compatibleAnimation = CompatibleAnimation.alloc().initWithNameBundle(
63+
src.replace('.json', '').replace('.lottie', ''),
64+
NSBundle.mainBundle
65+
);
66+
} else if (src.endsWith('.lottie')) {
6167
DotLottie.objcLoadFromShouldCacheCompletion(NSURL.URLWithString(src), true, (animation) => {
6268
this.nativeView.animation = animation;
6369
});

0 commit comments

Comments
 (0)