├── .eslintrc.js
├── .github
├── FUNDING.yml
└── workflows
│ ├── build.yml
│ └── release.yml
├── .gitignore
├── .gitmodules
├── .npmrc
├── .prettierignore
├── .prettierrc.js
├── .yarnrc.yml
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── build.gradle
├── config.json
├── demo-snippets
├── assets
│ ├── LottieLogo1.json
│ └── Mobilo
│ │ └── A.json
├── ng
│ ├── basic
│ │ ├── basic.component.html
│ │ └── basic.component.ts
│ ├── install.module.ts
│ └── styles.scss
├── package.json
└── vue
│ ├── Basic.vue
│ └── install.ts
├── docs
├── .nojekyll
├── assets
│ ├── hierarchy.js
│ ├── highlight.css
│ ├── icons.js
│ ├── icons.svg
│ ├── main.js
│ ├── navigation.js
│ ├── search.js
│ └── style.css
├── classes
│ └── LottieView.html
├── enums
│ └── RenderMode.html
├── index.html
├── interfaces
│ └── KeyPathColors.html
└── modules.html
├── lerna.json
├── package.json
├── packages
└── lottie
│ ├── .npmignore
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── blueprint.md
│ ├── package.json
│ ├── platforms
│ ├── android
│ │ ├── include.gradle
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── nativescript
│ │ │ │ └── lottie
│ │ │ │ └── LottieAnimationView.java
│ │ └── native-api-usage.json
│ └── ios
│ │ └── Podfile
│ └── tsconfig.json
├── pnpm-workspace.yaml
├── references.d.ts
├── sample-effects
├── 9squares-AlBoardman.json
├── EmptyState.json
├── HamburgerArrow.json
├── LightBulb.json
├── LottieLogo1.json
├── LottieLogo2.json
├── Mobilo
│ ├── A.json
│ ├── B.json
│ ├── D.json
│ ├── N.json
│ ├── R.json
│ └── S.json
├── TwitterHeart.json
├── WalkThrough.json
├── motioncorpse.json
└── pinjump.json
├── screens
├── android_assets.png
├── ios_assets.png
└── lottieDemo.gif
├── src
└── lottie
│ ├── angular
│ ├── index.ts
│ ├── ng-package.json
│ ├── package.json
│ └── tsconfig.json
│ ├── index.android.ts
│ ├── index.common.ts
│ ├── index.d.ts
│ ├── index.ios.ts
│ ├── typings
│ ├── android.d.ts
│ ├── android.nativescript.d.ts
│ ├── dotlottie.ios.d.ts
│ └── ios.d.ts
│ ├── utils.ts
│ └── vue
│ └── index.ts
├── svelte.config.js
├── tsconfig.json
├── tsconfig.vue3.json
└── yarn.lock
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: './tools/.eslintrc.js'
3 | };
4 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: [farfromrefug]
2 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build CI
2 |
3 | # Trigger the workflow on push or pull request
4 | on: [push]
5 |
6 | jobs:
7 | build:
8 | name: Build
9 |
10 | runs-on: macos-latest
11 | steps:
12 | - uses: actions/checkout@v1
13 |
14 | - name: Set Node.js 10.x
15 | uses: actions/setup-node@v1
16 | with:
17 | node-version: "10.x"
18 |
19 | - name: Build Plugin Source
20 | run: cd src && npm i && npm i -g typescript && tsc
21 |
22 | - name: Lint
23 | run: cd src && npm run tslint
24 |
25 | - name: Setup JDK 1.8
26 | uses: actions/setup-java@v1
27 | with:
28 | java-version: 1.8
29 |
30 | - name: Install PIP
31 | run: |
32 | sudo pip install --upgrade pip
33 | sudo pip install six
34 |
35 | - name: Setup NativeScript CLI
36 | run: |
37 | echo no | npm i -g nativescript
38 | tns usage-reporting disable
39 | tns error-reporting disable
40 |
41 | - name: Build Android Demo App
42 | run: |
43 | cd demo
44 | tns build android --env.uglify
45 | - name: Build iOS Demo App
46 | run: |
47 | cd demo
48 | tns build ios --env.uglify
49 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: 'release'
2 |
3 | on:
4 | workflow_dispatch:
5 | inputs:
6 | release_type:
7 | type: choice
8 | default: auto
9 | description: What kind of version upgrade
10 | options:
11 | - auto
12 | - patch
13 | - minor
14 | - major
15 |
16 | jobs:
17 | release:
18 | runs-on: ubuntu-latest
19 | steps:
20 | - name: Checkout repository
21 | uses: actions/checkout@v4
22 | with:
23 | fetch-depth: "0"
24 | submodules: true
25 |
26 | - name: setup node
27 | uses: actions/setup-node@v4
28 | with:
29 | node-version: lts/*
30 | registry-url: 'https://registry.npmjs.org'
31 |
32 |
33 | - uses: oNaiPs/secrets-to-env-action@v1
34 | with:
35 | secrets: ${{ toJSON(secrets) }}
36 |
37 |
38 | - uses: oleksiyrudenko/gha-git-credentials@v2-latest
39 | with:
40 | token: '${{ secrets.GITHUB_TOKEN }}'
41 | name: Martin Guillon
42 | email: dev@akylas.fr
43 |
44 | - name: install jq
45 | run: sudo apt install jq
46 |
47 | - name: Enable CorePack
48 | run: |
49 | corepack enable
50 | yarn config get globalFolder # the yarn command will ensure the correct yarn version is downloaded and installed
51 |
52 | - name: Get yarn cache directory path
53 | id: yarn-cache-dir-path
54 | run: echo "::set-output name=dir::$(yarn config get globalFolder)"
55 |
56 | - name: Remove package.json resolutions
57 | run: echo "`jq 'delpaths([["resolutions"]])' package.json`" > package.json
58 |
59 | - uses: actions/cache@v4
60 | name: Handle node_modules Cache
61 | id: yarn-node_modules # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
62 | with:
63 | path: node_modules
64 | key: ${{ runner.os }}-yarn-node_modules-${{ hashFiles('**/yarn.lock') }}
65 | restore-keys: |
66 | ${{ runner.os }}-node_modules-
67 |
68 | - uses: actions/cache@v4
69 | if: steps.yarn-node_modules.outputs.cache-hit != 'true'
70 | name: Handle Yarn cache
71 | id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
72 | with:
73 | path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
74 | key: ${{ runner.os }}-yarn-cache-${{ hashFiles('**/yarn.lock') }}
75 | restore-keys: |
76 | ${{ runner.os }}-yarn-
77 |
78 | - name: Install deps
79 | if: steps.yarn-node_modules.outputs.cache-hit != 'true'
80 | uses: bahmutov/npm-install@v1
81 | with:
82 | install-command: yarn install --silent
83 | env:
84 | YARN_ENABLE_IMMUTABLE_INSTALLS: false
85 |
86 | - name: run setup
87 | run: |
88 | npm run setup
89 |
90 | - name: "NPM Identity"
91 | env:
92 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
93 | run: |
94 | echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
95 |
96 | - name: publish auto
97 | if: github.event.inputs.release_type == 'auto'
98 | run: |
99 | npm run publish -- --force-publish --no-verify-access --no-private --no-commit-hooks --yes
100 | env:
101 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
102 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104 |
105 | - name: publish
106 | if: github.event.inputs.release_type != 'auto'
107 | run: |
108 | npm run publish -- --force-publish --no-verify-access --no-private --no-commit-hooks --yes --bump ${{ github.event.inputs.release_type }}
109 | env:
110 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
111 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # NativeScript
2 | hooks/
3 | node_modules/
4 | platforms
5 |
6 | # NativeScript Template
7 | *.js.map
8 | !ngcc.config.js
9 | !webpack.config.js
10 |
11 | # Logs
12 | logs
13 | *.log
14 | npm-debug.log*
15 | yarn-debug.log*
16 | yarn-error.log*
17 |
18 | # General
19 | .DS_Store
20 | .AppleDouble
21 | .LSOverride
22 | .idea
23 | .cloud
24 | .gradle
25 | .project
26 | .yarn
27 | .cxx
28 | tmp/
29 |
30 | !.eslintrc.js
31 | !.prettierrc.js
32 |
33 | !e2e/*.js
34 | !detox.config.js
35 | devices.js
36 |
37 | *.framework
38 | *.xcframework
39 | **/*.js.map
40 | src/**/*.js
41 | packages/**/*.js
42 | packages/**/*.d.ts
43 | bin
44 | build
45 | Pods
46 | !packages/*/platforms
47 | /packages/**/*.aar
48 | /packages/**/*.framework
49 | /packages/**/*.xcframework
50 | /demo-snippets/**/*.aar
51 | *.xcuserdatad
52 | /packages/README.md
53 | packages/**/*js.map
54 | packages/**/*js
55 | packages/angular
56 | packages/typings
57 | packages/**/angular/*.json
58 | packages/**/*.ngsummary.json
59 | packages/**/*.metadata.json
60 |
61 | .vscode/settings.json
62 |
63 | /blueprint.md
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "demo-vue"]
2 | path = demo-vue
3 | url = https://github.com/nativescript-community/plugin-seed-demo-vue.git
4 | [submodule "tools"]
5 | path = tools
6 | url = https://github.com/nativescript-community/plugin-seed-tools.git
7 | [submodule "demo-ng"]
8 | path = demo-ng
9 | url = https://github.com/nativescript-community/plugin-seed-demo-ng.git
10 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | shamefully-hoist=true
2 | public-hoist-pattern[]=*eslint*
3 | public-hoist-pattern[]=source-map-support
4 | public-hoist-pattern[]=ts-patch
5 | public-hoist-pattern[]=typescript
6 | public-hoist-pattern[]=cpy-cli
7 | strict-peer-dependencies=false
8 | shell-emulator=true
9 | auto-install-peers=false
10 | loglevel=error
11 | engine-strict=true
12 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | package-lock.json
2 | node_modules/
3 | plugin/
4 | docs/
5 |
--------------------------------------------------------------------------------
/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | printWidth: 200,
3 | semi: true,
4 | tabWidth: 4,
5 | trailingComma: 'none',
6 | singleQuote: true
7 | };
8 |
--------------------------------------------------------------------------------
/.yarnrc.yml:
--------------------------------------------------------------------------------
1 | compressionLevel: mixed
2 |
3 | nmHoistingLimits: workspaces
4 |
5 | nodeLinker: node-modules
6 |
7 | yarnPath: tools/.yarn/releases/yarn-4.0.1.cjs
8 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 |
6 | # [6.0.0](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.11...v6.0.0) (2024-03-21)
7 |
8 | ### Bug Fixes
9 |
10 | - **ios:** updated native SDK ([b1d9f73](https://github.com/farfromrefug/nativescript-lottie/commit/b1d9f734988658a30838944923563bcac16a78ab))
11 |
12 | ### BREAKING CHANGES
13 |
14 | - **ios:** min deployment target has been raised to 13.0
15 |
16 | ## [5.0.11](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.10...v5.0.11) (2024-03-15)
17 |
18 | ### Bug Fixes
19 |
20 | - **ios:** ensure animation start playing on src change with autoPlay ([80ea818](https://github.com/farfromrefug/nativescript-lottie/commit/80ea81853d8ac225a37c623809c7383498ea68ee))
21 |
22 | ## [5.0.10](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.9...v5.0.10) (2023-11-21)
23 |
24 | ### Bug Fixes
25 |
26 | - **ios:** multiple iOS fixes ([c0fcda6](https://github.com/farfromrefug/nativescript-lottie/commit/c0fcda6acffd03c7c97c2c033f20c14adc8e190e))
27 |
28 | ## [5.0.9](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.8...v5.0.9) (2023-11-21)
29 |
30 | ### Bug Fixes
31 |
32 | - **ios:** update to latest sdk ([5cee6cb](https://github.com/farfromrefug/nativescript-lottie/commit/5cee6cb1380f1b4396f5b1a43ff392ccbab1468a))
33 |
34 | ## [5.0.8](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.7...v5.0.8) (2023-11-20)
35 |
36 | ### Features
37 |
38 | - keyPathColors property (`setColor` as a property) ([fed5025](https://github.com/farfromrefug/nativescript-lottie/commit/fed50251d67f217900b796882edb34eb6d509dcf))
39 |
40 | ## [5.0.7](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.6...v5.0.7) (2023-11-19)
41 |
42 | ### Bug Fixes
43 |
44 | - **android:** src is now loaded sync. You can change the behavior with the new `async` property ([7b28195](https://github.com/farfromrefug/nativescript-lottie/commit/7b281956afc0d31702ae12f8eada54796c09c798))
45 | - BREAKING CHANGE renamed `setOpacityValueDelegateForKeyPath` to `setOpacity` and `setColorValueDelegateForKeyPath` to `setColor` ([927a64f](https://github.com/farfromrefug/nativescript-lottie/commit/927a64fbeb21c2151f6647cb0360e4a79e0d4b11))
46 |
47 | ## [5.0.6](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.5...v5.0.6) (2023-03-11)
48 |
49 | ### Bug Fixes
50 |
51 | - use color filter to set color on android ([af275e4](https://github.com/farfromrefug/nativescript-lottie/commit/af275e4f6e51a98845a7bc85d2dcf1201218f16c))
52 |
53 | ## [5.0.5](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.4...v5.0.5) (2023-01-24)
54 |
55 | ### Bug Fixes
56 |
57 | - **android:** native-api-usage fix ([ad3a299](https://github.com/farfromrefug/nativescript-lottie/commit/ad3a29994b033b9cb0786d7ff99e5c218a51603f))
58 |
59 | ## [5.0.4](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.3...v5.0.4) (2023-01-13)
60 |
61 | ### Bug Fixes
62 |
63 | - **android:** lottie does not support clearing animation (src=null) ([024b7d5](https://github.com/farfromrefug/nativescript-lottie/commit/024b7d5a9de23bcc2fd0a754188cf5026fe3e031))
64 |
65 | ## [5.0.3](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.2...v5.0.3) (2022-12-21)
66 |
67 | **Note:** Version bump only for package @nativescript-community/ui-lottie
68 |
69 | ## [5.0.2](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.1...v5.0.2) (2022-12-21)
70 |
71 | ### Bug Fixes
72 |
73 | - **ios:** try to fix animation not playing after navigation ([bbed469](https://github.com/farfromrefug/nativescript-lottie/commit/bbed4690b957174d0b850bc4800c799c1b17d3b1))
74 |
75 | ## [5.0.1](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.0...v5.0.1) (2022-12-01)
76 |
77 | **Note:** Version bump only for package @nativescript-community/ui-lottie
78 |
79 | # [5.0.0](https://github.com/farfromrefug/nativescript-lottie/compare/v4.4.5...v5.0.0) (2022-08-19)
80 |
81 | **Note:** Version bump only for package @nativescript-community/ui-lottie
82 |
83 | ## [4.4.5](https://github.com/farfromrefug/nativescript-lottie/compare/v4.4.4...v4.4.5) (2022-08-19)
84 |
85 | ### Bug Fixes
86 |
87 | - **ios:** for now rollback to old lottie which supports ios < 12 ([54f318b](https://github.com/farfromrefug/nativescript-lottie/commit/54f318b273bb04183d381fd8c53d63fb23ef9a20))
88 |
89 | ## [4.4.4](https://github.com/farfromrefug/nativescript-lottie/compare/v4.4.3...v4.4.4) (2022-08-15)
90 |
91 | ### Bug Fixes
92 |
93 | - **ios:** wrong podfile ([f17dc1f](https://github.com/farfromrefug/nativescript-lottie/commit/f17dc1fd0bfe26b9e4f715ec259c147c78812649))
94 |
95 | ## [4.4.3](https://github.com/farfromrefug/nativescript-lottie/compare/v4.4.2...v4.4.3) (2022-08-14)
96 |
97 | ### Bug Fixes
98 |
99 | - **android:** upgrade native lib version ([3ac5059](https://github.com/farfromrefug/nativescript-lottie/commit/3ac50592b3ae997579e2f6235bfb53f77da5bb76))
100 | - **ios:** use branch for pod repo to prevent future errors ([1ffbc38](https://github.com/farfromrefug/nativescript-lottie/commit/1ffbc38a68d38692a6cade0049553606e05f6a2c))
101 |
102 | ## [4.4.2](https://github.com/farfromrefug/nativescript-lottie/compare/v4.4.1...v4.4.2) (2022-08-14)
103 |
104 | **Note:** Version bump only for package @nativescript-community/ui-lottie
105 |
106 | ## [4.4.1](https://github.com/farfromrefug/nativescript-lottie/compare/v4.4.0...v4.4.1) (2022-02-16)
107 |
108 | ### Bug Fixes
109 |
110 | - **android:** revert broken change ([ee1da5b](https://github.com/farfromrefug/nativescript-lottie/commit/ee1da5b77a603cc5957b39d4632f3f38d3660427))
111 |
112 | # [4.4.0](https://github.com/farfromrefug/nativescript-lottie/compare/v4.3.3...v4.4.0) (2022-02-15)
113 |
114 | ### Bug Fixes
115 |
116 | - **android:** dont include appCompat to try and prevent users issues ([c8e6963](https://github.com/farfromrefug/nativescript-lottie/commit/c8e696351440d1cf3e4bcfd538ce86cc3936f2a3))
117 |
118 | ### Features
119 |
120 | - angular module & vue element ([1b6d0cf](https://github.com/farfromrefug/nativescript-lottie/commit/1b6d0cfdb37df9056e7b70b1da456db20e9c5b3f))
121 |
122 | ## [4.3.3](https://github.com/farfromrefug/nativescript-lottie/compare/v4.3.2...v4.3.3) (2022-01-06)
123 |
124 | ### Bug Fixes
125 |
126 | - **android:** bump native lib version to fix build issue with bintray ([7a55d70](https://github.com/farfromrefug/nativescript-lottie/commit/7a55d70d665f7ea4e52bd64b2cd9c743167c2afe))
127 |
128 | ## [4.3.2](https://github.com/farfromrefug/nativescript-lottie/compare/v4.3.1...v4.3.2) (2021-11-14)
129 |
130 | ### Bug Fixes
131 |
132 | - added strech property. Sizing now behaves like N Image ([0a91948](https://github.com/farfromrefug/nativescript-lottie/commit/0a919484894ce05cddb76407f88ac788745a7a9a))
133 |
134 | ## [4.3.1](https://github.com/farfromrefug/nativescript-lottie/compare/v4.3.0...v4.3.1) (2021-11-03)
135 |
136 | ### Bug Fixes
137 |
138 | - loading files like `MyFile.json` should be seen as res ([b1f892b](https://github.com/farfromrefug/nativescript-lottie/commit/b1f892b6a17bb96c263c9d93fe49e6e224eab342))
139 |
140 | # [4.3.0](https://github.com/farfromrefug/nativescript-lottie/compare/v4.1.0...v4.3.0) (2021-10-29)
141 |
142 | ### Bug Fixes
143 |
144 | - **android:** correctly allow override of appcompat version ([0f866ac](https://github.com/farfromrefug/nativescript-lottie/commit/0f866ac84366f2b98382b7a494db2c48d5609bc4))
145 | - **ios:** working dotLottie files ([c4d7871](https://github.com/farfromrefug/nativescript-lottie/commit/c4d787110a9c02eced3e655472f5ddfc8900db00))
146 | - quick fix after merge ([d560f81](https://github.com/farfromrefug/nativescript-lottie/commit/d560f81139379b20b1048b3f411cfd453d67603d))
147 | - update deps and support dotLottie files ([749210e](https://github.com/farfromrefug/nativescript-lottie/commit/749210e16698b863df928deb531243f7e75a2aeb))
148 |
149 | ### Features
150 |
151 | - **android:** native-api-usage ([50d4019](https://github.com/farfromrefug/nativescript-lottie/commit/50d40197c799baa3906754a970329af094ed77fb))
152 |
153 | # [4.2.0](https://github.com/farfromrefug/nativescript-lottie/compare/v4.1.3...v4.2.0) (2021-10-21)
154 |
155 | ### Features
156 |
157 | - **android:** native-api-usage ([735118f](https://github.com/farfromrefug/nativescript-lottie/commit/735118f0072e92d96b62c3666bea3d50e70b8d2b))
158 |
159 | ## [4.1.3](https://github.com/farfromrefug/nativescript-lottie/compare/v4.1.2...v4.1.3) (2021-10-02)
160 |
161 | ### Bug Fixes
162 |
163 | - **android:** correctly allow override of appcompat version ([5675f09](https://github.com/farfromrefug/nativescript-lottie/commit/5675f09c48f578602291b4fbc03f4f4c7ed18da8))
164 |
165 | ## [4.1.2](https://github.com/farfromrefug/nativescript-lottie/compare/v4.1.1...v4.1.2) (2021-07-07)
166 |
167 | ### Bug Fixes
168 |
169 | - quick fix after merge ([d84ad97](https://github.com/farfromrefug/nativescript-lottie/commit/d84ad9735c79adf45f13baf0a850253fc805849e))
170 |
171 | ## [4.1.1](https://github.com/farfromrefug/nativescript-lottie/compare/v4.1.0...v4.1.1) (2021-07-07)
172 |
173 | **Note:** Version bump only for package @nativescript-community/ui-lottie
174 |
175 | # [4.1.0](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.14...v4.1.0) (2020-09-07)
176 |
177 | ### Features
178 |
179 | - N 7 and new plugin name ([33c0f1c](https://github.com/farfromrefug/nativescript-lottie/commit/33c0f1cea3737e782f26d96cade311177e9b5d4b))
180 |
181 | ## [4.0.14](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.13...v4.0.14) (2020-05-21)
182 |
183 | **Note:** Version bump only for package @nativescript-community/ui-lottie
184 |
185 | ## [4.0.13](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.12...v4.0.13) (2020-05-21)
186 |
187 | ### Bug Fixes
188 |
189 | - sideEffects for tree shacking ([d66adf8](https://github.com/farfromrefug/nativescript-lottie/commit/d66adf866f805baf25e8b3060976ed74cdd5ad3a))
190 |
191 | ## [4.0.12](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.11...v4.0.12) (2020-05-21)
192 |
193 | ### Bug Fixes
194 |
195 | - esm using import for tree shaking ([a9c6a5d](https://github.com/farfromrefug/nativescript-lottie/commit/a9c6a5dbc766213be2fc459edbdd2c3ecf8696cf))
196 |
197 | ## [4.0.11](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.10...v4.0.11) (2020-05-21)
198 |
199 | ### Bug Fixes
200 |
201 | - full esm support ([73fdff0](https://github.com/farfromrefug/nativescript-lottie/commit/73fdff026394911436bd71b0b8f237a5a4edbfba))
202 |
203 | ## [4.0.10](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.9...v4.0.10) (2020-05-01)
204 |
205 | ### Bug Fixes
206 |
207 | - **android:** better loading ([1f49748](https://github.com/farfromrefug/nativescript-lottie/commit/1f497489588a81d9592d2d1a163e5cfecd617ad3))
208 |
209 | ## [4.0.9](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.8...v4.0.9) (2020-05-01)
210 |
211 | ### Bug Fixes
212 |
213 | - src not being loaded ([dfd1c17](https://github.com/farfromrefug/nativescript-lottie/commit/dfd1c175305dccdeb5e67674370f10fdc016229a))
214 |
215 | ## [4.0.8](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.7...v4.0.8) (2020-04-29)
216 |
217 | ### Bug Fixes
218 |
219 | - clear animation on null src ([1d908e9](https://github.com/farfromrefug/nativescript-lottie/commit/1d908e9e07f3ba1ad472a67017a11b6a8d6fa7d5))
220 |
221 | ## [4.0.7](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.6...v4.0.7) (2020-02-26)
222 |
223 | ### Bug Fixes
224 |
225 | - **android:** cleanup and profilling ([6088040](https://github.com/farfromrefug/nativescript-lottie/commit/60880408382cf6a3c4d25cc123017292afe42f3e))
226 |
227 | ## [4.0.6](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.5...v4.0.6) (2020-02-24)
228 |
229 | ### Bug Fixes
230 |
231 | - **android:** for now isAnimating does not seem to work ([5fd9727](https://github.com/farfromrefug/nativescript-lottie/commit/5fd97271a698c5e29e4b9e7a53c8a2d2fa6f34f4))
232 |
233 | ## [4.0.5](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.4...v4.0.5) (2020-02-18)
234 |
235 | ### Bug Fixes
236 |
237 | - make progress a property ([caf6d5c](https://github.com/farfromrefug/nativescript-lottie/commit/caf6d5c7279211c75e49958d631720b4dcc7ffd4))
238 |
239 | ## [4.0.4](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.3...v4.0.4) (2020-02-14)
240 |
241 | ### Bug Fixes
242 |
243 | - better handle of completion block ([021cfad](https://github.com/farfromrefug/nativescript-lottie/commit/021cfad0326a1c1de1c5b0194e249ba35da3c822))
244 |
245 | ## [4.0.3](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.2...v4.0.3) (2020-02-13)
246 |
247 | **Note:** Version bump only for package @nativescript-community/ui-lottie
248 |
249 | ## 4.0.2 (2020-02-13)
250 |
251 | ## 3.0.2 (2019-03-06)
252 |
253 | # 3.0.0 (2019-01-22)
254 |
255 | ## 2.1.2 (2018-12-12)
256 |
257 | ### Bug Fixes
258 |
259 | - **iOS:** unhandled transient rejection ([d07e7d5](https://github.com/farfromrefug/nativescript-lottie/commit/d07e7d5057dd62401b3be493046d118b597c3433))
260 |
261 | ### Features
262 |
263 | - adjust dynamic properties - color ([dbeeae0](https://github.com/farfromrefug/nativescript-lottie/commit/dbeeae04478ef3b84ca4f95988c14f573eed52fe))
264 |
265 | # 2.0.0 (2018-04-23)
266 |
267 | ### Bug Fixes
268 |
269 | - **iOS:** update to reflect rename of swift class ([b11123c](https://github.com/farfromrefug/nativescript-lottie/commit/b11123cb524b2007cd9066d3b2072fc1796b7450))
270 |
271 | ### Features
272 |
273 | - **iOS:** animations rendering now ([29bb703](https://github.com/farfromrefug/nativescript-lottie/commit/29bb703d74ed9065ff0b4596daa8218976e0b68e))
274 | - **iOS:** fixed up onLoaded to fire event ([5558094](https://github.com/farfromrefug/nativescript-lottie/commit/5558094c21d3a38c3d3d5e0aac1fec924addf11c))
275 | - **iOS:** play action working ([99f63e6](https://github.com/farfromrefug/nativescript-lottie/commit/99f63e63c28dde25df74094ee5a29b42e3e20de9))
276 | - **iOS:** wip ([6c63391](https://github.com/farfromrefug/nativescript-lottie/commit/6c633915af5b50ac03aadecf895de55eda8a2de9))
277 | - **iOS:** wip ([033e315](https://github.com/farfromrefug/nativescript-lottie/commit/033e3156b57710643cdafbcae78d83bb21149d9d))
278 | - **iOS:** working ([92d2170](https://github.com/farfromrefug/nativescript-lottie/commit/92d21703a2d925344f340baee7b6e2086561acd9))
279 |
280 | # Changelog
281 |
282 | All notable changes to this project from 2019-01-21 will be documented in this file.
283 |
284 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
285 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
286 |
287 | ## [3.0.2] - 2019-03-05
288 |
289 | ### Added
290 |
291 | - Fixed [#37](https://github.com/farfromrefug/nativescript-lottie/issues/37) allowing Android lottie `src` to be set without the `.json` file extension. Thanks to [@mudlabs](https://github.com/mudlabs) PR.
292 |
293 | ## [3.0.1] - 2019-03-01
294 |
295 | ### Added
296 |
297 | - NativeScript Vue demo
298 | - Enabled Travis CI builds for demo projects
299 | - Republished to correct missing README from npm.
300 |
301 | ## [3.0.0] - 2019-01-22
302 |
303 | ### Added
304 |
305 | - Added documentation to the interface.
306 | - Added the `completionBlock` property for executing work upon completion of the animation.
307 | - Added the `playAnimationFromProgressToProgress` function for playing the animation from the specified start and end progress values.
308 | - Added the `setColorValueDelegateForKeyPath` function for setting the provided color value on each property that matches the specified keyPath.
309 | - Added the `setOpacityValueDelegateForKeyPath` function for setting the provided opacity value on each property that matches the specified keyPath.
310 |
311 | ### Changed
312 |
313 | - Changed the iOS implementation to remove unnecessary layout and measurement logic.
314 | - Changed both the android and iOS implementations to align them where possible.
315 | - Changed both the Angular and plan demos to align them, and to demonstrate the newly added apis.
316 |
317 | ### Removed
318 |
319 | - Removed exposed properties with no backing implementation have been removed.
320 | - Removed the `theme` property removed in favour of `setColorValueDelegateForKeyPath`.
321 | - Removed the LottieHelper jar.
322 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | nativescript-lottie
4 | Copyright (c) 2017, Brad Martin
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | this software and associated documentation files (the "Software"), to deal in
8 | the Software without restriction, including without limitation the rights to
9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | the Software, and to permit persons to whom the Software is furnished to do so,
11 | subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java'
2 |
3 | // Use maven repository
4 | repositories {
5 | mavenCentral()
6 | google()
7 | }
8 |
9 | apply from: 'plugin/platforms/android/include.gradle'
10 | dependencies {
11 | implementation files('/Volumes/dev/androidSDK/platforms/android-28/android.jar')
12 | }
13 | sourceSets {
14 | main {
15 | java {
16 | srcDirs = ["plugin/platforms/android/java"]
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "readme": true,
3 | "angular": true,
4 | "demos": [
5 | "vue",
6 | "ng"
7 | ]
8 | }
--------------------------------------------------------------------------------
/demo-snippets/ng/basic/basic.component.html:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
13 |
18 |
19 |
24 |
29 |
30 |
31 |
36 |
41 |
42 |
48 |
54 |
60 |
66 |
72 |
78 |
84 |
90 |
96 |
102 |
103 |
108 |
109 |
110 |
115 |
120 |
121 |
126 |
127 |
128 |
133 |
138 |
143 |
144 |
145 |
146 |
--------------------------------------------------------------------------------
/demo-snippets/ng/basic/basic.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { LottieView } from '@nativescript-community/ui-lottie';
3 | import { Color } from '@nativescript/core';
4 |
5 | const ANDROID_WAVE_KEYPATHS = [
6 | ['Shirt', 'Group 5', 'Fill 1'],
7 | ['LeftArmWave', 'LeftArm', 'Group 6', 'Fill 1'],
8 | ['RightArm', 'Group 6', 'Fill 1']
9 | ];
10 |
11 | @Component({
12 | selector: 'ns-home',
13 | templateUrl: './basic.component.html',
14 | moduleId: module.id
15 | })
16 | export class BasicComponent {
17 | public animationIndex: number = 0;
18 | public animations: string[] = [
19 | 'Mobilo/B.json',
20 | 'Mobilo/A.json',
21 | 'Mobilo/D.json',
22 | 'Mobilo/N.json',
23 | 'Mobilo/R.json',
24 | 'Mobilo/S.json'
25 | ];
26 | public thirdLottieProgressTo: string = 'Try it!';
27 |
28 | /**
29 | * For demoing cycling through the sample animations.
30 | */
31 | private _lottieViewOne: LottieView;
32 |
33 | /**
34 | * For demoing changing colors and opacity dynamically at runtime.
35 | */
36 | private _lottieViewTwo: LottieView;
37 |
38 | /**
39 | * For demoing partially animating a composition.
40 | */
41 | private _lottieViewThree: LottieView;
42 |
43 | /**
44 | * For demoing the completion block (i.e for async work).
45 | */
46 | private _lottieViewFour: LottieView;
47 |
48 | public firstLottieLoaded(event) {
49 | this._lottieViewOne = event.object as LottieView;
50 | this._lottieViewOne.autoPlay = true;
51 | this._lottieViewOne.loop = true;
52 | this._lottieViewOne.src = this.animations[this.animationIndex];
53 | }
54 |
55 | public secondLottieLoaded(event) {
56 | this._lottieViewTwo = event.object as LottieView;
57 | this._lottieViewTwo.autoPlay = true;
58 | this._lottieViewTwo.loop = true;
59 | this._lottieViewTwo.src = 'AndroidWave.json';
60 | }
61 |
62 | public thirdLottieLoaded(event) {
63 | this._lottieViewThree = event.object as LottieView;
64 | this._lottieViewThree.autoPlay = true;
65 | this._lottieViewThree.loop = false;
66 | this._lottieViewThree.src = 'Mobilo/N.json';
67 | }
68 |
69 | public fourthLottieLoaded(event) {
70 | this._lottieViewFour = event.object as LottieView;
71 | this._lottieViewFour.autoPlay = false;
72 | this._lottieViewFour.src = 'doughnut.json';
73 |
74 | this.setFourthLottieToLoadingState();
75 | }
76 |
77 | public next() {
78 | this.animationIndex++;
79 | if (this.animationIndex >= this.animations.length) {
80 | this.animationIndex = 0;
81 | }
82 | this._lottieViewOne.src = this.animations[this.animationIndex];
83 | }
84 |
85 | public toggleAnimation() {
86 | if (this._lottieViewOne.isAnimating()) {
87 | this._lottieViewOne.cancelAnimation();
88 | } else {
89 | this._lottieViewOne.playAnimation();
90 | }
91 | }
92 |
93 | public toggleLoop() {
94 | this._lottieViewOne.loop = !this._lottieViewOne.loop;
95 | }
96 |
97 | public setTheme(value) {
98 | const color = new Color(value);
99 | ANDROID_WAVE_KEYPATHS.forEach(keyPath => {
100 | this._lottieViewTwo.setColor(color, [...keyPath]);
101 | });
102 | }
103 |
104 | public setSecondLottieRandomOpacity() {
105 | const opacity = getRandomWithPrecision(2);
106 | ANDROID_WAVE_KEYPATHS.forEach(keyPath => {
107 | this._lottieViewTwo.setOpacity(opacity, [
108 | ...keyPath
109 | ]);
110 | });
111 | }
112 |
113 | public setThirdLottieRandomProgress() {
114 | const progress = getRandomWithPrecision(2);
115 | this.thirdLottieProgressTo = `Animated to ${progress}`;
116 | this._lottieViewThree.playAnimationFromProgressToProgress(0, progress);
117 | }
118 |
119 | public setFourthLottieToLoadingState() {
120 | this._lottieViewFour.loop = true;
121 | this._lottieViewFour.playAnimationFromProgressToProgress(0, 0.5);
122 | }
123 |
124 | public setFourthLottieToLoadedState() {
125 | this._lottieViewFour.completionBlock = (animationFinished: boolean) => {
126 | console.log(
127 | `lottieViewFour completionBlock animationFinished: ${animationFinished}`
128 | );
129 |
130 | this._lottieViewFour.playAnimationFromProgressToProgress(0.5, 0.85);
131 | this._lottieViewFour.completionBlock = null;
132 | };
133 |
134 | // Trigger the completion block by disabling looping and allowing the final loop to lapse.
135 | this._lottieViewFour.loop = false;
136 | }
137 | }
138 |
139 | function getRandomWithPrecision(precision?: number): number {
140 | const multiplier = Math.pow(10, precision || 0);
141 | return Math.round(Math.random() * multiplier) / multiplier;
142 | }
143 |
--------------------------------------------------------------------------------
/demo-snippets/ng/install.module.ts:
--------------------------------------------------------------------------------
1 | import { NO_ERRORS_SCHEMA, NgModule } from '@angular/core';
2 |
3 | import { BasicComponent } from './basic/basic.component';
4 |
5 | export const COMPONENTS = [BasicComponent];
6 | @NgModule({
7 | schemas: [NO_ERRORS_SCHEMA]
8 | })
9 | export class InstallModule {}
10 |
11 | export function installPlugin() {
12 | }
13 |
14 | export const demos = [
15 | { name: 'Basic', path: 'basic', component: BasicComponent }
16 | ];
17 |
--------------------------------------------------------------------------------
/demo-snippets/ng/styles.scss:
--------------------------------------------------------------------------------
1 | .item {
2 | padding: 10;
3 | color: white;
4 |
5 | .title {
6 | font-size: 17;
7 | font-weight: bold;
8 | }
9 |
10 | .subtitle {
11 | font-size: 14;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/demo-snippets/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@nativescript-community/template-snippet",
3 | "version": "0.0.1",
4 | "private": true,
5 | "dependencies": {
6 | "@nativescript-community/ui-lottie": "*"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/demo-snippets/vue/Basic.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
44 |
45 |
59 |
--------------------------------------------------------------------------------
/demo-snippets/vue/install.ts:
--------------------------------------------------------------------------------
1 | import Vue from 'nativescript-vue';
2 | import Basic from './Basic.vue';
3 | import LottieView from '@nativescript-community/ui-lottie/vue';
4 |
5 | export function installPlugin() {
6 | Vue.use(LottieView);
7 |
8 | }
9 |
10 | export const demos = [{ name: 'Basic', path: 'basic', component: Basic }];
11 |
--------------------------------------------------------------------------------
/docs/.nojekyll:
--------------------------------------------------------------------------------
1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
--------------------------------------------------------------------------------
/docs/assets/hierarchy.js:
--------------------------------------------------------------------------------
1 | window.hierarchyData = "data:application/octet-stream;base64,H4sIAAAAAAAAA6tWKsrPLylWsoqO1VEqSk3LSU0uyczPK1ayqq6tBQAWeT+5HQAAAA=="
--------------------------------------------------------------------------------
/docs/assets/highlight.css:
--------------------------------------------------------------------------------
1 | :root {
2 | --light-hl-0: #AF00DB;
3 | --dark-hl-0: #C586C0;
4 | --light-hl-1: #000000;
5 | --dark-hl-1: #D4D4D4;
6 | --light-hl-2: #001080;
7 | --dark-hl-2: #9CDCFE;
8 | --light-hl-3: #A31515;
9 | --dark-hl-3: #CE9178;
10 | --light-hl-4: #795E26;
11 | --dark-hl-4: #DCDCAA;
12 | --light-hl-5: #0000FF;
13 | --dark-hl-5: #569CD6;
14 | --light-hl-6: #267F99;
15 | --dark-hl-6: #4EC9B0;
16 | --light-hl-7: #008000;
17 | --dark-hl-7: #6A9955;
18 | --light-hl-8: #098658;
19 | --dark-hl-8: #B5CEA8;
20 | --light-hl-9: #000000;
21 | --dark-hl-9: #C8C8C8;
22 | --light-code-background: #FFFFFF;
23 | --dark-code-background: #1E1E1E;
24 | }
25 |
26 | @media (prefers-color-scheme: light) { :root {
27 | --hl-0: var(--light-hl-0);
28 | --hl-1: var(--light-hl-1);
29 | --hl-2: var(--light-hl-2);
30 | --hl-3: var(--light-hl-3);
31 | --hl-4: var(--light-hl-4);
32 | --hl-5: var(--light-hl-5);
33 | --hl-6: var(--light-hl-6);
34 | --hl-7: var(--light-hl-7);
35 | --hl-8: var(--light-hl-8);
36 | --hl-9: var(--light-hl-9);
37 | --code-background: var(--light-code-background);
38 | } }
39 |
40 | @media (prefers-color-scheme: dark) { :root {
41 | --hl-0: var(--dark-hl-0);
42 | --hl-1: var(--dark-hl-1);
43 | --hl-2: var(--dark-hl-2);
44 | --hl-3: var(--dark-hl-3);
45 | --hl-4: var(--dark-hl-4);
46 | --hl-5: var(--dark-hl-5);
47 | --hl-6: var(--dark-hl-6);
48 | --hl-7: var(--dark-hl-7);
49 | --hl-8: var(--dark-hl-8);
50 | --hl-9: var(--dark-hl-9);
51 | --code-background: var(--dark-code-background);
52 | } }
53 |
54 | :root[data-theme='light'] {
55 | --hl-0: var(--light-hl-0);
56 | --hl-1: var(--light-hl-1);
57 | --hl-2: var(--light-hl-2);
58 | --hl-3: var(--light-hl-3);
59 | --hl-4: var(--light-hl-4);
60 | --hl-5: var(--light-hl-5);
61 | --hl-6: var(--light-hl-6);
62 | --hl-7: var(--light-hl-7);
63 | --hl-8: var(--light-hl-8);
64 | --hl-9: var(--light-hl-9);
65 | --code-background: var(--light-code-background);
66 | }
67 |
68 | :root[data-theme='dark'] {
69 | --hl-0: var(--dark-hl-0);
70 | --hl-1: var(--dark-hl-1);
71 | --hl-2: var(--dark-hl-2);
72 | --hl-3: var(--dark-hl-3);
73 | --hl-4: var(--dark-hl-4);
74 | --hl-5: var(--dark-hl-5);
75 | --hl-6: var(--dark-hl-6);
76 | --hl-7: var(--dark-hl-7);
77 | --hl-8: var(--dark-hl-8);
78 | --hl-9: var(--dark-hl-9);
79 | --code-background: var(--dark-code-background);
80 | }
81 |
82 | .hl-0 { color: var(--hl-0); }
83 | .hl-1 { color: var(--hl-1); }
84 | .hl-2 { color: var(--hl-2); }
85 | .hl-3 { color: var(--hl-3); }
86 | .hl-4 { color: var(--hl-4); }
87 | .hl-5 { color: var(--hl-5); }
88 | .hl-6 { color: var(--hl-6); }
89 | .hl-7 { color: var(--hl-7); }
90 | .hl-8 { color: var(--hl-8); }
91 | .hl-9 { color: var(--hl-9); }
92 | pre, code { background: var(--code-background); }
93 |
--------------------------------------------------------------------------------
/docs/assets/icons.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | addIcons();
3 | function addIcons() {
4 | if (document.readyState === "loading") return document.addEventListener("DOMContentLoaded", addIcons);
5 | const svg = document.body.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg"));
6 | svg.innerHTML = `MMNEPVFCICPMFPCPTTAAATR`;
7 | svg.style.display = "none";
8 | if (location.protocol === "file:") updateUseElements();
9 | }
10 |
11 | function updateUseElements() {
12 | document.querySelectorAll("use").forEach(el => {
13 | if (el.getAttribute("href").includes("#icon-")) {
14 | el.setAttribute("href", el.getAttribute("href").replace(/.*#/, "#"));
15 | }
16 | });
17 | }
18 | })()
--------------------------------------------------------------------------------
/docs/assets/icons.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/assets/navigation.js:
--------------------------------------------------------------------------------
1 | window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA1WMuwrCMBSG3+XMwWBBkayOKoiDS3EIzS8JpknJOVJF+u5uxszfpf+Q4CVk6ILkUE7ZgRRNVjwZQnqOrCtZeRkjKXqE5MjsFvWrj1kk4Bow13qIlhmsK2v7dfd/OOB9tuL3OebCdRKSoNztANaN0a66zXa5fQFNTarxzAAAAA=="
--------------------------------------------------------------------------------
/docs/assets/search.js:
--------------------------------------------------------------------------------
1 | window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA62YX2/bNhTFvwv7Sji+tOV/b163YsVWJMiy7kEwAlViGiGSKFB0ssDwdx8oy+KlyUaMujfDuuccSvzxitSBSPHSkE18IE95lZHNipIqKTnZkFteZVx+ERknlOxlQTaEV/uyuTIXJo+qLAglaZE0DW/IhpAjPTvBorfa/n13/WV79/nj204fkr0SZaLy1PakpE4kr5Q9KG/S79vbX//Z3v42EPSYyOwlkXx0zl/Xn+4CchrxoN6fwyIT9Ad/vUnU40dRCNn0aXmluHxIUt5cWQVvTwgzk/unUCrnX3P+0nt2mitz6U23CFjvloqqUXKfKiGH7D7Ytf6ngkaHhj9l8z4xqTIp8mwwzdSNTcpFM5hyqhl9L3slborkdfhm9krUp8KxWako64KrXFS/FCJ9Cpitc/23rv4dyYsomhmS7+/Va83fm9irhnInl7f2wydQKV4pq6+9waquLU+1Y595tpeJHtZgHCocm1UIUQ/mdEVjM2opvkveDC8LVDg2q6k5H17l56rRKTIdzpA/fit5E9h0bvptmlQpL7ZVXoahcKpPUP3Y5LzpUqvvw32sSVDt2MSGq/ZtNPxIuUq7wp/Iuq6TNFfD3bPhSvSlY/N0+w2fRV39f8yhlfpJivKmW1l34iZ4MeKxPEhRnlenEu9apztK8irj/5LNgTxz2eg72xA2mU3WhJKHnBeZ3k+ehk71C6fUJpRkIt23P3dd2VeuNwG6+FR9NSU0nlK2msBsvtvR+CxuL7R/nD3MP60QCI3BJwRHCJaQERozn5A5QmYJZ4TGM59w5ghnlnBOaDz3CeeOcG4JI0LjyCeMHGFkCReExgufcOEIF5ZwSWi89AmXjnBpCVeExiufcOUIV5ZwTWi89gnXjnBtA6B5AC874MIDF/S0+Pj58QBkEwSaC/AyBC5EYFMEmg3wcgQuSGCTBJoP8LIELkxg0wSaEfDyBC5QYBMFmhPwMgUuVGBTBZoV8HIFLlhgkwWaF/CyBS5cYNMFmhnw8gUuYGATxjQzzEsYcwljNmFMM8O8hDGXMHbRo9om5e9SnjZlE8Y0M8xLGHMJ6/5qW/wzl4pnn0+tPo777fuB3Hf9H+D8gjoQALI5HI+m328OR9Ty9TWd1B/HjMvSmCzDPMxHAjQWNJRgl9NZypisjck6yMTZpaEBrdCIVmFul2ct5DZFbtNAN3TONk4LY7QI9TFnIDQihkbEgpzM8QbZzJDNLMjGfLsxNmgwYWNpT+xGjyYrbK6snTK6HYQQhDH0xF/rRD2m3Qce4zU3VvMgp9OxDg0GOUCohd7oPbefhYxRZHyiIJuLfS+aJzxRYTMVtG9FCQgoFgaUzwbQPUPYTcv2U97lOkELN2zdmkMRuinkwoJt+tMOMkJ9koU1SvMJ09igZxz2iLsDOnq+qA9BWCNqD+DIAb04IODNsaOkzmte5BUnm3h3PP4HZ4rS5vsWAAA=";
--------------------------------------------------------------------------------
/docs/enums/RenderMode.html:
--------------------------------------------------------------------------------
1 |
RenderMode | @nativescript-community/ui-lottie Enumeration Members
AUTOMATIC
AUTOMATIC: number
5 |
--------------------------------------------------------------------------------
/docs/interfaces/KeyPathColors.html:
--------------------------------------------------------------------------------
1 | KeyPathColors | @nativescript-community/ui-lottie
2 |
--------------------------------------------------------------------------------
/docs/modules.html:
--------------------------------------------------------------------------------
1 | @nativescript-community/ui-lottie@nativescript-community/ui-lottie
Enumerations
- RenderMode
Classes
- LottieView
Interfaces
- KeyPathColors
2 |
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "6.0.0",
3 | "$schema": "node_modules/@lerna-lite/cli/schemas/lerna-schema.json",
4 | "packages": [
5 | "packages/*"
6 | ],
7 | "npmClient": "yarn",
8 | "useWorkspaces": true,
9 | "command": {
10 | "publish": {
11 | "cleanupTempFiles": true
12 | }
13 | },
14 | "npmClientArgs": [
15 | "--no-package-lock"
16 | ],
17 | "commitHooks": false,
18 | "createRelease": "github",
19 | "conventionalCommits": true,
20 | "private": false,
21 | "message": "chore(release): publish new version %v",
22 | "changelogPreset": "conventional-changelog-conventionalcommits",
23 | "ignoreChanges": [
24 | "**/__fixtures__/**",
25 | "**/__tests__/**",
26 | "**/*.md"
27 | ]
28 | }
29 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "repository": {
3 | "type": "git",
4 | "url": "https://github.com/farfromrefug/nativescript-lottie.git"
5 | },
6 | "keywords": [
7 | "NativeScript",
8 | "nativescript-lottie",
9 | "Lottie",
10 | "Android",
11 | "Animation",
12 | "iOS",
13 | "TypeScript",
14 | "bradmartin"
15 | ],
16 | "author": {
17 | "name": "Brad Martin",
18 | "email": "bradwaynemartin@gmail.com"
19 | },
20 | "contributors": [
21 | {
22 | "name": "Nathan Walker",
23 | "email": "walkerrunpdx@gmail.com"
24 | },
25 | {
26 | "name": "JB",
27 | "url": "https://github.com/rhanb"
28 | },
29 | {
30 | "name": "Dirk Rudolph",
31 | "url": "https://github.com/Buuhuu"
32 | },
33 | {
34 | "name": "Hamdi Wanis",
35 | "url": "https://github.com/hamdiwanis"
36 | },
37 | {
38 | "name": "itstheceo",
39 | "url": "https://github.com/itstheceo"
40 | }
41 | ],
42 | "license": "MIT",
43 | "bugs": {
44 | "url": "https://github.com/farfromrefug/nativescript-lottie/issues"
45 | },
46 | "homepage": "https://github.com/farfromrefug/nativescript-lottie",
47 | "readmeFilename": "README.md",
48 | "scripts": {
49 | "setup": "npm run submodules && ts-patch install",
50 | "prepare": "npm run setup",
51 | "tsc": "cpy '**/*.d.ts' '../plugin' --parents --cwd=src && tsc -skipLibCheck -d",
52 | "clean": "rimraf 'packages/**/*.d.ts' 'packages/**/*.js' 'packages/**/*.js.map' 'packages/**/*.metada' 'packages/**/angular/ng-package.json'",
53 | "build.plugin": "cp README.md plugin/ && rm -f .tsbuildinfo && npm run tsc",
54 | "build.android": "bash src-native/android/build.sh",
55 | "build.ios": "bash src-native/ios/build.sh",
56 | "build.native": "npm run build.android && npm run build.ios",
57 | "build": "lerna run build",
58 | "publish": "npm run setup && npm run clean && npm run build.all && npm run readme && npm run doc && npm run commit_readme_doc_changes && lerna publish",
59 | "demo.ios": "npm i && npm run tsc && cd demo && tns run ios",
60 | "demo.android": "npm i && npm run tsc && cd demo && tns run android",
61 | "clean.demo": "rimraf demo/hooks demo/node_modules demo/platforms",
62 | "plugin.watch.tsc": "npm run tsc -- -w",
63 | "plugin.watch.android": "npm i && npm-watch build.android",
64 | "plugin.watch.ios": "npm i && npm-watch build.ios",
65 | "plugin.watch": "npm run plugin.watch.tsc & npm run plugin.watch.android & npm run plugin.watch.ios",
66 | "commitmsg": "commitlint -e $GIT_PARAMS",
67 | "sync": "node ./tools/sync.js",
68 | "generate.typings.ios": "cd ../demo && TNS_DEBUG_METADATA_PATH=\"$(pwd)/metadata\" tns build ios && TNS_TYPESCRIPT_DECLARATIONS_PATH=\"$(pwd)/typings\" tns build ios && echo 'Now look for your library typings in demo/typings!'",
69 | "precommit": "lint-staged",
70 | "build.all": "lerna run build.all",
71 | "fullclean": "npm run clean && rimraf 'packages/**/node_modules' 'demo-*/hooks' 'demo-*/node_modules' 'package-lock.json' 'pnpm-lock.yaml' 'node_modules'",
72 | "demo.ng.android": "cd ./demo-ng && ns run android --no-hmr --env.watchNodeModules",
73 | "demo.ng.clean": "cd ./demo-ng && ns clean",
74 | "demo.ng.ios": "cd ./demo-ng && ns run ios --no-hmr --env.watchNodeModules",
75 | "demo.vue.android": "cd ./demo-vue && ns run android --no-hmr --env.watchNodeModules",
76 | "demo.vue.clean": "cd ./demo-vue && ns clean",
77 | "demo.vue.ios": "cd ./demo-vue && ns run ios --no-hmr --env.watchNodeModules",
78 | "doc": "node tools/builddoc.mjs",
79 | "commit_readme_doc_changes": "git add docs/** *.md ; git commit -m \"readme/doc\" ; echo \"commit readme doc done\"",
80 | "postinstall": "npm run setup",
81 | "readme": "lerna run readme && node ./tools/readme.js",
82 | "start": "./node_modules/.bin/ntl -A -s 15 -o",
83 | "submodules": "git submodule update --init",
84 | "update": "node ./tools/update.js",
85 | "build.angular": "lerna run build.angular"
86 | },
87 | "dependencies": {
88 | "@nativescript-community/plugin-seed-tools": "file:tools"
89 | },
90 | "ntl": {
91 | "descriptions": {
92 | "build": "Build the plugin",
93 | "build.angular": "Build the plugin for Angular",
94 | "build.all": "Build the plugin for all platforms",
95 | "clean": "Clean the local environment.",
96 | "demo.ng.android": "Runs the Angular demo on Android.",
97 | "demo.ng.ios": "Runs the Angular demo on iOS.",
98 | "demo.vue.android": "Runs the Vue demo on Android.",
99 | "demo.vue.ios": "Runs the Vue demo on iOS.",
100 | "watch": "Watch for changes in the plugin source and re-build."
101 | }
102 | },
103 | "workspaces": [
104 | "packages/*",
105 | "demo*"
106 | ],
107 | "engines": {
108 | "npm": "please use yarn or pnpm",
109 | "yarn": ">=1.19.1",
110 | "pnpm": ">=7.0.0",
111 | "node": "^14.20.0 || ^16.13.0 || >=18.10.0"
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/packages/lottie/.npmignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | tsconfig.json
3 | node_modules/
4 | pnpm-global/
5 | CHANGELOG.md
6 | blueprint.md
7 | *.aar
8 | *.jar
--------------------------------------------------------------------------------
/packages/lottie/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5 |
6 | # [6.0.0](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.11...v6.0.0) (2024-03-21)
7 |
8 | ### Bug Fixes
9 |
10 | - **ios:** updated native SDK ([b1d9f73](https://github.com/farfromrefug/nativescript-lottie/commit/b1d9f734988658a30838944923563bcac16a78ab))
11 |
12 | ### BREAKING CHANGES
13 |
14 | - **ios:** min deployment target has been raised to 13.0
15 |
16 | ## [5.0.11](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.10...v5.0.11) (2024-03-15)
17 |
18 | **Note:** Version bump only for package @nativescript-community/ui-lottie
19 |
20 | ## [5.0.10](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.9...v5.0.10) (2023-11-21)
21 |
22 | **Note:** Version bump only for package @nativescript-community/ui-lottie
23 |
24 | ## [5.0.9](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.8...v5.0.9) (2023-11-21)
25 |
26 | ### Bug Fixes
27 |
28 | - **ios:** update to latest sdk ([5cee6cb](https://github.com/farfromrefug/nativescript-lottie/commit/5cee6cb1380f1b4396f5b1a43ff392ccbab1468a))
29 |
30 | ## [5.0.8](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.7...v5.0.8) (2023-11-20)
31 |
32 | **Note:** Version bump only for package @nativescript-community/ui-lottie
33 |
34 | ## [5.0.7](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.6...v5.0.7) (2023-11-19)
35 |
36 | ### Bug Fixes
37 |
38 | - **android:** src is now loaded sync. You can change the behavior with the new `async` property ([7b28195](https://github.com/farfromrefug/nativescript-lottie/commit/7b281956afc0d31702ae12f8eada54796c09c798))
39 |
40 | ## [5.0.6](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.5...v5.0.6) (2023-03-11)
41 |
42 | **Note:** Version bump only for package @nativescript-community/ui-lottie
43 |
44 | ## [5.0.5](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.4...v5.0.5) (2023-01-24)
45 |
46 | ### Bug Fixes
47 |
48 | - **android:** native-api-usage fix ([ad3a299](https://github.com/farfromrefug/nativescript-lottie/commit/ad3a29994b033b9cb0786d7ff99e5c218a51603f))
49 |
50 | ## [5.0.4](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.3...v5.0.4) (2023-01-13)
51 |
52 | **Note:** Version bump only for package @nativescript-community/ui-lottie
53 |
54 | ## [5.0.3](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.2...v5.0.3) (2022-12-21)
55 |
56 | **Note:** Version bump only for package @nativescript-community/ui-lottie
57 |
58 | ## [5.0.2](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.1...v5.0.2) (2022-12-21)
59 |
60 | **Note:** Version bump only for package @nativescript-community/ui-lottie
61 |
62 | ## [5.0.1](https://github.com/farfromrefug/nativescript-lottie/compare/v5.0.0...v5.0.1) (2022-12-01)
63 |
64 | **Note:** Version bump only for package @nativescript-community/ui-lottie
65 |
66 | # [5.0.0](https://github.com/farfromrefug/nativescript-lottie/compare/v4.4.5...v5.0.0) (2022-08-19)
67 |
68 | **Note:** Version bump only for package @nativescript-community/ui-lottie
69 |
70 | ## [4.4.5](https://github.com/farfromrefug/nativescript-lottie/compare/v4.4.4...v4.4.5) (2022-08-19)
71 |
72 | ### Bug Fixes
73 |
74 | - **ios:** for now rollback to old lottie which supports ios < 12 ([54f318b](https://github.com/farfromrefug/nativescript-lottie/commit/54f318b273bb04183d381fd8c53d63fb23ef9a20))
75 |
76 | ## [4.4.4](https://github.com/farfromrefug/nativescript-lottie/compare/v4.4.3...v4.4.4) (2022-08-15)
77 |
78 | ### Bug Fixes
79 |
80 | - **ios:** wrong podfile ([f17dc1f](https://github.com/farfromrefug/nativescript-lottie/commit/f17dc1fd0bfe26b9e4f715ec259c147c78812649))
81 |
82 | ## [4.4.3](https://github.com/farfromrefug/nativescript-lottie/compare/v4.4.2...v4.4.3) (2022-08-14)
83 |
84 | ### Bug Fixes
85 |
86 | - **android:** upgrade native lib version ([3ac5059](https://github.com/farfromrefug/nativescript-lottie/commit/3ac50592b3ae997579e2f6235bfb53f77da5bb76))
87 | - **ios:** use branch for pod repo to prevent future errors ([1ffbc38](https://github.com/farfromrefug/nativescript-lottie/commit/1ffbc38a68d38692a6cade0049553606e05f6a2c))
88 |
89 | ## [4.4.2](https://github.com/farfromrefug/nativescript-lottie/compare/v4.4.1...v4.4.2) (2022-08-14)
90 |
91 | **Note:** Version bump only for package @nativescript-community/ui-lottie
92 |
93 | ## [4.4.1](https://github.com/farfromrefug/nativescript-lottie/compare/v4.4.0...v4.4.1) (2022-02-16)
94 |
95 | ### Bug Fixes
96 |
97 | - **android:** revert broken change ([ee1da5b](https://github.com/farfromrefug/nativescript-lottie/commit/ee1da5b77a603cc5957b39d4632f3f38d3660427))
98 |
99 | # [4.4.0](https://github.com/farfromrefug/nativescript-lottie/compare/v4.3.3...v4.4.0) (2022-02-15)
100 |
101 | ### Bug Fixes
102 |
103 | - **android:** dont include appCompat to try and prevent users issues ([c8e6963](https://github.com/farfromrefug/nativescript-lottie/commit/c8e696351440d1cf3e4bcfd538ce86cc3936f2a3))
104 |
105 | ### Features
106 |
107 | - angular module & vue element ([1b6d0cf](https://github.com/farfromrefug/nativescript-lottie/commit/1b6d0cfdb37df9056e7b70b1da456db20e9c5b3f))
108 |
109 | ## [4.3.3](https://github.com/farfromrefug/nativescript-lottie/compare/v4.3.2...v4.3.3) (2022-01-06)
110 |
111 | ### Bug Fixes
112 |
113 | - **android:** bump native lib version to fix build issue with bintray ([7a55d70](https://github.com/farfromrefug/nativescript-lottie/commit/7a55d70d665f7ea4e52bd64b2cd9c743167c2afe))
114 |
115 | ## [4.3.2](https://github.com/farfromrefug/nativescript-lottie/compare/v4.3.1...v4.3.2) (2021-11-14)
116 |
117 | ### Bug Fixes
118 |
119 | - added strech property. Sizing now behaves like N Image ([0a91948](https://github.com/farfromrefug/nativescript-lottie/commit/0a919484894ce05cddb76407f88ac788745a7a9a))
120 |
121 | ## [4.3.1](https://github.com/farfromrefug/nativescript-lottie/compare/v4.3.0...v4.3.1) (2021-11-03)
122 |
123 | **Note:** Version bump only for package @nativescript-community/ui-lottie
124 |
125 | # [4.3.0](https://github.com/farfromrefug/nativescript-lottie/compare/v4.1.0...v4.3.0) (2021-10-29)
126 |
127 | ### Bug Fixes
128 |
129 | - **android:** correctly allow override of appcompat version ([0f866ac](https://github.com/farfromrefug/nativescript-lottie/commit/0f866ac84366f2b98382b7a494db2c48d5609bc4))
130 | - **ios:** working dotLottie files ([c4d7871](https://github.com/farfromrefug/nativescript-lottie/commit/c4d787110a9c02eced3e655472f5ddfc8900db00))
131 | - update deps and support dotLottie files ([749210e](https://github.com/farfromrefug/nativescript-lottie/commit/749210e16698b863df928deb531243f7e75a2aeb))
132 |
133 | ### Features
134 |
135 | - **android:** native-api-usage ([50d4019](https://github.com/farfromrefug/nativescript-lottie/commit/50d40197c799baa3906754a970329af094ed77fb))
136 |
137 | # [4.2.0](https://github.com/farfromrefug/nativescript-lottie/compare/v4.1.3...v4.2.0) (2021-10-21)
138 |
139 | ### Features
140 |
141 | - **android:** native-api-usage ([735118f](https://github.com/farfromrefug/nativescript-lottie/commit/735118f0072e92d96b62c3666bea3d50e70b8d2b))
142 |
143 | ## [4.1.3](https://github.com/farfromrefug/nativescript-lottie/compare/v4.1.2...v4.1.3) (2021-10-02)
144 |
145 | ### Bug Fixes
146 |
147 | - **android:** correctly allow override of appcompat version ([5675f09](https://github.com/farfromrefug/nativescript-lottie/commit/5675f09c48f578602291b4fbc03f4f4c7ed18da8))
148 |
149 | ## [4.1.2](https://github.com/farfromrefug/nativescript-lottie/compare/v4.1.1...v4.1.2) (2021-07-07)
150 |
151 | **Note:** Version bump only for package @nativescript-community/ui-lottie
152 |
153 | ## [4.1.1](https://github.com/farfromrefug/nativescript-lottie/compare/v4.1.0...v4.1.1) (2021-07-07)
154 |
155 | **Note:** Version bump only for package @nativescript-community/ui-lottie
156 |
157 | # [4.1.0](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.14...v4.1.0) (2020-09-07)
158 |
159 | ### Features
160 |
161 | - N 7 and new plugin name ([33c0f1c](https://github.com/farfromrefug/nativescript-lottie/commit/33c0f1cea3737e782f26d96cade311177e9b5d4b))
162 |
163 | ## [4.0.14](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.13...v4.0.14) (2020-05-21)
164 |
165 | **Note:** Version bump only for package @nativescript-community/ui-lottie
166 |
167 | ## [4.0.13](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.12...v4.0.13) (2020-05-21)
168 |
169 | ### Bug Fixes
170 |
171 | - sideEffects for tree shacking ([d66adf8](https://github.com/farfromrefug/nativescript-lottie/commit/d66adf866f805baf25e8b3060976ed74cdd5ad3a))
172 |
173 | ## [4.0.12](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.11...v4.0.12) (2020-05-21)
174 |
175 | **Note:** Version bump only for package @nativescript-community/ui-lottie
176 |
177 | ## [4.0.11](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.10...v4.0.11) (2020-05-21)
178 |
179 | ### Bug Fixes
180 |
181 | - full esm support ([73fdff0](https://github.com/farfromrefug/nativescript-lottie/commit/73fdff026394911436bd71b0b8f237a5a4edbfba))
182 |
183 | ## [4.0.10](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.9...v4.0.10) (2020-05-01)
184 |
185 | **Note:** Version bump only for package @nativescript-community/ui-lottie
186 |
187 | ## [4.0.9](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.8...v4.0.9) (2020-05-01)
188 |
189 | **Note:** Version bump only for package @nativescript-community/ui-lottie
190 |
191 | ## [4.0.8](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.7...v4.0.8) (2020-04-29)
192 |
193 | **Note:** Version bump only for package @nativescript-community/ui-lottie
194 |
195 | ## [4.0.7](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.6...v4.0.7) (2020-02-26)
196 |
197 | **Note:** Version bump only for package @nativescript-community/ui-lottie
198 |
199 | ## [4.0.6](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.5...v4.0.6) (2020-02-24)
200 |
201 | **Note:** Version bump only for package @nativescript-community/ui-lottie
202 |
203 | ## [4.0.5](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.4...v4.0.5) (2020-02-18)
204 |
205 | **Note:** Version bump only for package @nativescript-community/ui-lottie
206 |
207 | ## [4.0.4](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.3...v4.0.4) (2020-02-14)
208 |
209 | **Note:** Version bump only for package @nativescript-community/ui-lottie
210 |
211 | ## [4.0.3](https://github.com/farfromrefug/nativescript-lottie/compare/v4.0.2...v4.0.3) (2020-02-13)
212 |
213 | **Note:** Version bump only for package @nativescript-community/ui-lottie
214 |
215 | ## 4.0.2 (2020-02-13)
216 |
217 | **Note:** Version bump only for package @nativescript-community/ui-lottie
218 |
--------------------------------------------------------------------------------
/packages/lottie/README.md:
--------------------------------------------------------------------------------
1 |
2 |
21 | @nativescript-community/ui-lottie
22 |
23 |
24 |
25 |
26 |
27 |
28 | NativeScript plugin to expose AirBnB Lottie library
29 |
30 |
31 |
32 |
33 |
34 |
35 | |
|
36 | | --- | ----------- |
37 | | iOS Demo | Android Demo |
38 |
39 |
40 | [](#table-of-contents)
41 |
42 | ## Table of Contents
43 |
44 | * [Installation](#installation)
45 | * [Usage](#usage)
46 | * [NativeScript (Core)](#nativescript-core)
47 | * [XML](#xml)
48 | * [TS](#ts)
49 | * [NativeScript Angular](#nativescript-angular)
50 | * [Module](#module)
51 | * [XML](#xml-1)
52 | * [Component](#component)
53 | * [NativeScript Vue](#nativescript-vue)
54 | * [Bootstrap](#bootstrap)
55 | * [Component](#component-1)
56 | * [Assets](#assets)
57 | * [Android](#android)
58 | * [iOS](#ios)
59 | * [Properties (bindable)](#properties-bindable)
60 | * [Properties](#properties)
61 | * [Methods](#methods)
62 | * [Contributors](#contributors)
63 | * [Demos and Development](#demos-and-development)
64 | * [Repo Setup](#repo-setup)
65 | * [Build](#build)
66 | * [Demos](#demos)
67 | * [Contributing](#contributing)
68 | * [Update repo ](#update-repo-)
69 | * [Update readme ](#update-readme-)
70 | * [Update doc ](#update-doc-)
71 | * [Publish](#publish)
72 | * [modifying submodules](#modifying-submodules)
73 | * [Questions](#questions)
74 |
75 |
76 | [](#installation)
77 |
78 | ## Installation
79 | Run the following command from the root of your project:
80 |
81 | `ns plugin add @nativescript-community/ui-lottie`
82 |
83 |
84 | [](#usage)
85 |
86 | ## Usage
87 |
88 | ### NativeScript (Core)
89 |
90 | #### XML
91 |
92 | ```xml
93 |
96 |
97 |
98 |
99 |
100 | ```
101 |
102 | #### TS
103 |
104 | ```typescript
105 | import { LottieView } from "@nativescript-community/ui-lottie";
106 |
107 | public yourLoadedEvent(args) {
108 | this._myLottie = args.object as LottieView; /// this is the instance of the LottieAnimationView
109 | }
110 | ```
111 |
112 | ---
113 |
114 | ### NativeScript Angular
115 |
116 | #### Module
117 |
118 | First you need to include the `NativeScriptLottieModule` in your `app.module.ts`
119 |
120 | ```typescript
121 | import { NativeScriptLottieModule} from '@nativescript-community/ui-lottie/angular';
122 |
123 | @NgModule({
124 | imports: [
125 | NativeScriptLottieModule
126 | ],
127 | ...
128 | })
129 | ```
130 |
131 | #### XML
132 |
133 | ```xml
134 |
135 |
136 |
137 | ```
138 |
139 | #### Component
140 |
141 | ```typescript
142 | import { Component } from '@angular/core';
143 | import { LottieView } from '@nativescript-community/ui-lottie';
144 |
145 | @Component({
146 | templateUrl: 'home.component.html',
147 | moduleId: module.id
148 | })
149 | export class HomeComponent {
150 | public loop: boolean = true;
151 | public src: string;
152 | public autoPlay: boolean = true;
153 | public animations: Array;
154 |
155 | private _lottieView: LottieView;
156 |
157 | constructor() {
158 | this.animations = [
159 | 'Mobilo/A.json',
160 | 'Mobilo/D.json',
161 | 'Mobilo/N.json',
162 | 'Mobilo/S.json'
163 | ];
164 | this.src = this.animations[0];
165 | }
166 |
167 | lottieViewLoaded(event) {
168 | this._lottieView = event.object;
169 | }
170 | }
171 | ```
172 |
173 | ---
174 |
175 |
176 | [](#nativescript-vue)
177 |
178 | ## NativeScript Vue
179 |
180 | ### Bootstrap
181 |
182 | If you want to use this plugin with Vue, do this in your `app.js` or `main.js`:
183 |
184 | ```javascript
185 | import LottieView from '@nativescript-community/ui-lottie/vue';
186 |
187 | Vue.use(LottieView);
188 | ```
189 |
190 | This will install and register `LottieView` component to your `Vue` instance and now you can use the plugin.
191 |
192 | ### Component
193 |
194 | ```xml
195 |
196 |
197 |
198 |
199 |
200 |
202 |
203 |
217 | ```
218 |
219 | ---
220 |
221 |
222 | [](#assets)
223 |
224 | ## Assets
225 |
226 | :fire: You can find animations in the `sample-effects` folder.
227 |
228 | ### Android
229 |
230 | Place your animation files in the NS app's `app/App_Resources/Android/src/main/assets` folder.
231 |
232 | Note: In a nativescript-vue project the above folder may not exist. Place the files in `platforms/android/app/src/main/assets`.
233 |
234 | ### iOS
235 |
236 | Place your animations files in your `app/App_Resources/iOS/` folder.
237 |
238 |
239 | [](#properties-bindable)
240 |
241 | ## Properties (bindable)
242 |
243 | | Property | Type | Default | Description |
244 | | ---------- | --------- | ------- | --------------------------------------------- |
245 | | `autoPlay` | `boolean` | `false` | Start LottieView animation on load if `true`. |
246 | | `loop` | `boolean` | `false` | Loop continuously animation if `true`. |
247 | | `src` | `string` | `null` | Animation path to `.json` file. |
248 |
249 |
250 | [](#properties)
251 |
252 | ## Properties
253 |
254 | | Property | Type | Default | Description |
255 | | ----------------- | ------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
256 | | `completionBlock` | `(boolean) => void` | `null` | Completion block to be executed upon completion of the animation. The animation is considered complete when it finishes playing and is no longer looping. |
257 | | `duration` | `number` | `null` | Get the duration of the animation. |
258 | | `progress` | `number` | `0` | Get/set the progress of the animation. |
259 | | `speed` | `number` | `1` | Get/set the speed of the animation. |
260 |
261 |
262 | [](#methods)
263 |
264 | ## Methods
265 |
266 | | Method | Return | Parameters | Description |
267 | | ------------------------------------- | --------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
268 | | `cancelAnimation` | `void` | None | Pauses the animation for the LottieView instance. |
269 | | `isAnimating` | `boolean` | None | Returns true if the LottieView is animating, else false. |
270 | | `playAnimation` | `void` | None | Plays the animation for the LottieView instance. |
271 | | `playAnimationFromProgressToProgress` | `void` | startProgress, endProgress | Plays the animation for the LottieView instance from the specified start and end progress values (between 0 and 1). |
272 | | `setColor` | `void` | value, keyPath | Sets the provided color value on each property that matches the specified keyPath in the LottieView instance. |
273 | | `setOpacity` | `void` | value, keyPath | Sets the provided opacity value (0 - 1) on each property that matches the specified keyPath in the LottieView instance. |
274 |
275 |
276 | [](#contributors)
277 |
278 | ## Contributors
279 |
280 | | [
](https://github.com/bradmartin) | [
](https://github.com/NathanWalker/) | [
](https://github.com/rhanb) | [
](https://github.com/hamdiwanis) |
281 | | :-----------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: |
282 | | [bradmartin](https://github.com/bradmartin) | [NathanWalker](https://github.com/NathanWalker) | [rhanb](https://github.com/rhanb) | [HamdiWanis](https://github.com/hamdiwanis) |
283 |
284 | | [
](https://github.com/itstheceo) | [
](https://github.com/mudlabs) |
285 | | :--------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------: |
286 | | [itstheceo](https://github.com/itstheceo) | [mudlabs](https://github.com/mudlabs) |
287 |
288 |
289 |
290 | [](#demos-and-development)
291 |
292 | ## Demos and Development
293 |
294 |
295 | ### Repo Setup
296 |
297 | The repo uses submodules. If you did not clone with ` --recursive` then you need to call
298 | ```
299 | git submodule update --init
300 | ```
301 |
302 | The package manager used to install and link dependencies must be `pnpm` or `yarn`. `npm` wont work.
303 |
304 | To develop and test:
305 | if you use `yarn` then run `yarn`
306 | if you use `pnpm` then run `pnpm i`
307 |
308 | **Interactive Menu:**
309 |
310 | To start the interactive menu, run `npm start` (or `yarn start` or `pnpm start`). This will list all of the commonly used scripts.
311 |
312 | ### Build
313 |
314 | ```bash
315 | npm run build.all
316 | ```
317 | WARNING: it seems `yarn build.all` wont always work (not finding binaries in `node_modules/.bin`) which is why the doc explicitly uses `npm run`
318 |
319 | ### Demos
320 |
321 | ```bash
322 | npm run demo.[ng|react|svelte|vue].[ios|android]
323 |
324 | npm run demo.svelte.ios # Example
325 | ```
326 |
327 | Demo setup is a bit special in the sense that if you want to modify/add demos you dont work directly in `demo-[ng|react|svelte|vue]`
328 | Instead you work in `demo-snippets/[ng|react|svelte|vue]`
329 | You can start from the `install.ts` of each flavor to see how to register new demos
330 |
331 |
332 | [](#contributing)
333 |
334 | ## Contributing
335 |
336 | ### Update repo
337 |
338 | You can update the repo files quite easily
339 |
340 | First update the submodules
341 |
342 | ```bash
343 | npm run update
344 | ```
345 |
346 | Then commit the changes
347 | Then update common files
348 |
349 | ```bash
350 | npm run sync
351 | ```
352 | Then you can run `yarn|pnpm`, commit changed files if any
353 |
354 | ### Update readme
355 | ```bash
356 | npm run readme
357 | ```
358 |
359 | ### Update doc
360 | ```bash
361 | npm run doc
362 | ```
363 |
364 | ### Publish
365 |
366 | The publishing is completely handled by `lerna` (you can add `-- --bump major` to force a major release)
367 | Simply run
368 | ```shell
369 | npm run publish
370 | ```
371 |
372 | ### modifying submodules
373 |
374 | The repo uses https:// for submodules which means you won't be able to push directly into the submodules.
375 | One easy solution is t modify `~/.gitconfig` and add
376 | ```
377 | [url "ssh://git@github.com/"]
378 | pushInsteadOf = https://github.com/
379 | ```
380 |
381 |
382 | [](#questions)
383 |
384 | ## Questions
385 |
386 | If you have any questions/issues/comments please feel free to create an issue or start a conversation in the [NativeScript Community Discord](https://nativescript.org/discord).
387 |
--------------------------------------------------------------------------------
/packages/lottie/blueprint.md:
--------------------------------------------------------------------------------
1 | {{ load:../../tools/readme/edit-warning.md }}
2 | {{ template:title }}
3 | {{ template:badges }}
4 | {{ template:description }}
5 |
6 | |
|
7 | | --- | ----------- |
8 | | iOS Demo | Android Demo |
9 |
10 | {{ template:toc }}
11 |
12 | ## Installation
13 | Run the following command from the root of your project:
14 |
15 | `ns plugin add {{ pkg.name }}`
16 |
17 | ## Usage
18 |
19 | ### NativeScript (Core)
20 |
21 | #### XML
22 |
23 | ```xml
24 |
27 |
28 |
29 |
30 |
31 | ```
32 |
33 | #### TS
34 |
35 | ```typescript
36 | import { LottieView } from "@nativescript-community/ui-lottie";
37 |
38 | public yourLoadedEvent(args) {
39 | this._myLottie = args.object as LottieView; /// this is the instance of the LottieAnimationView
40 | }
41 | ```
42 |
43 | ---
44 |
45 | ### NativeScript Angular
46 |
47 | #### Module
48 |
49 | First you need to include the `NativeScriptLottieModule` in your `app.module.ts`
50 |
51 | ```typescript
52 | import { NativeScriptLottieModule} from '@nativescript-community/ui-lottie/angular';
53 |
54 | @NgModule({
55 | imports: [
56 | NativeScriptLottieModule
57 | ],
58 | ...
59 | })
60 | ```
61 |
62 | #### XML
63 |
64 | ```xml
65 |
66 |
67 |
68 | ```
69 |
70 | #### Component
71 |
72 | ```typescript
73 | import { Component } from '@angular/core';
74 | import { LottieView } from '@nativescript-community/ui-lottie';
75 |
76 | @Component({
77 | templateUrl: 'home.component.html',
78 | moduleId: module.id
79 | })
80 | export class HomeComponent {
81 | public loop: boolean = true;
82 | public src: string;
83 | public autoPlay: boolean = true;
84 | public animations: Array;
85 |
86 | private _lottieView: LottieView;
87 |
88 | constructor() {
89 | this.animations = [
90 | 'Mobilo/A.json',
91 | 'Mobilo/D.json',
92 | 'Mobilo/N.json',
93 | 'Mobilo/S.json'
94 | ];
95 | this.src = this.animations[0];
96 | }
97 |
98 | lottieViewLoaded(event) {
99 | this._lottieView = event.object;
100 | }
101 | }
102 | ```
103 |
104 | ---
105 |
106 | ## NativeScript Vue
107 |
108 | ### Bootstrap
109 |
110 | If you want to use this plugin with Vue, do this in your `app.js` or `main.js`:
111 |
112 | ```javascript
113 | import LottieView from '@nativescript-community/ui-lottie/vue';
114 |
115 | Vue.use(LottieView);
116 | ```
117 |
118 | This will install and register `LottieView` component to your `Vue` instance and now you can use the plugin.
119 |
120 | ### Component
121 |
122 | ```xml
123 |
124 |
125 |
126 |
127 |
128 |
130 |
131 |
145 | ```
146 |
147 | ---
148 |
149 | ## Assets
150 |
151 | :fire: You can find animations in the `sample-effects` folder.
152 |
153 | ### Android
154 |
155 | Place your animation files in the NS app's `app/App_Resources/Android/src/main/assets` folder.
156 |
157 | Note: In a nativescript-vue project the above folder may not exist. Place the files in `platforms/android/app/src/main/assets`.
158 |
159 | ### iOS
160 |
161 | Place your animations files in your `app/App_Resources/iOS/` folder.
162 |
163 | ## Properties (bindable)
164 |
165 | | Property | Type | Default | Description |
166 | | ---------- | --------- | ------- | --------------------------------------------- |
167 | | `autoPlay` | `boolean` | `false` | Start LottieView animation on load if `true`. |
168 | | `loop` | `boolean` | `false` | Loop continuously animation if `true`. |
169 | | `src` | `string` | `null` | Animation path to `.json` file. |
170 |
171 | ## Properties
172 |
173 | | Property | Type | Default | Description |
174 | | ----------------- | ------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
175 | | `completionBlock` | `(boolean) => void` | `null` | Completion block to be executed upon completion of the animation. The animation is considered complete when it finishes playing and is no longer looping. |
176 | | `duration` | `number` | `null` | Get the duration of the animation. |
177 | | `progress` | `number` | `0` | Get/set the progress of the animation. |
178 | | `speed` | `number` | `1` | Get/set the speed of the animation. |
179 |
180 | ## Methods
181 |
182 | | Method | Return | Parameters | Description |
183 | | ------------------------------------- | --------- | -------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
184 | | `cancelAnimation` | `void` | None | Pauses the animation for the LottieView instance. |
185 | | `isAnimating` | `boolean` | None | Returns true if the LottieView is animating, else false. |
186 | | `playAnimation` | `void` | None | Plays the animation for the LottieView instance. |
187 | | `playAnimationFromProgressToProgress` | `void` | startProgress, endProgress | Plays the animation for the LottieView instance from the specified start and end progress values (between 0 and 1). |
188 | | `setColor` | `void` | value, keyPath | Sets the provided color value on each property that matches the specified keyPath in the LottieView instance. |
189 | | `setOpacity` | `void` | value, keyPath | Sets the provided opacity value (0 - 1) on each property that matches the specified keyPath in the LottieView instance. |
190 |
191 | ## Contributors
192 |
193 | | [
](https://github.com/bradmartin) | [
](https://github.com/NathanWalker/) | [
](https://github.com/rhanb) | [
](https://github.com/hamdiwanis) |
194 | | :-----------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: |
195 | | [bradmartin](https://github.com/bradmartin) | [NathanWalker](https://github.com/NathanWalker) | [rhanb](https://github.com/rhanb) | [HamdiWanis](https://github.com/hamdiwanis) |
196 |
197 | | [
](https://github.com/itstheceo) | [
](https://github.com/mudlabs) |
198 | | :--------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------: |
199 | | [itstheceo](https://github.com/itstheceo) | [mudlabs](https://github.com/mudlabs) |
200 |
201 |
202 | {{ load:../../tools/readme/demos-and-development.md }}
203 | {{ load:../../tools/readme/questions.md }}
204 |
--------------------------------------------------------------------------------
/packages/lottie/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@nativescript-community/ui-lottie",
3 | "version": "6.0.0",
4 | "description": "NativeScript plugin to expose AirBnB Lottie library",
5 | "main": "index",
6 | "sideEffects": false,
7 | "typings": "index.d.ts",
8 | "nativescript": {
9 | "platforms": {
10 | "android": "6.0.0",
11 | "ios": "6.0.1"
12 | }
13 | },
14 | "scripts": {
15 | "tsc": "cpy ../../src/lottie/index.d.ts ./ && tsc -d",
16 | "readme": "readme generate -c ../../tools/readme/blueprint.json",
17 | "build": "npm run tsc",
18 | "build.watch": "npm run tsc -- -w",
19 | "build.win": "npm run tsc-win",
20 | "build.all": "npm run build && npm run build.angular",
21 | "build.angular": "ng-packagr -p ../../src/lottie/angular/ng-package.json -c ../../src/lottie/angular/tsconfig.json && rm angular/.npmignore",
22 | "clean": "rimraf ./*.d.ts ./*.js ./*.js.map"
23 | },
24 | "repository": {
25 | "type": "git",
26 | "url": "https://github.com/farfromrefug/nativescript-lottie.git"
27 | },
28 | "keywords": [
29 | "NativeScript",
30 | "@nativescript-community/ui-lottie",
31 | "Lottie",
32 | "Android",
33 | "Animation",
34 | "iOS",
35 | "TypeScript",
36 | "bradmartin"
37 | ],
38 | "author": {
39 | "name": "Brad Martin",
40 | "email": "bradwaynemartin@gmail.com"
41 | },
42 | "contributors": [
43 | {
44 | "name": "Nathan Walker",
45 | "email": "walkerrunpdx@gmail.com"
46 | },
47 | {
48 | "name": "JB",
49 | "url": "https://github.com/rhanb"
50 | },
51 | {
52 | "name": "Dirk Rudolph",
53 | "url": "https://github.com/Buuhuu"
54 | },
55 | {
56 | "name": "Hamdi Wanis",
57 | "url": "https://github.com/hamdiwanis"
58 | },
59 | {
60 | "name": "itstheceo",
61 | "url": "https://github.com/itstheceo"
62 | }
63 | ],
64 | "license": "MIT",
65 | "bugs": {
66 | "url": "https://github.com/farfromrefug/nativescript-lottie/issues"
67 | },
68 | "homepage": "https://github.com/farfromrefug/nativescript-lottie",
69 | "readmeFilename": "README.md",
70 | "gitHead": "bb14c9536defaecdd768efcfc91e911282430d76"
71 | }
72 |
--------------------------------------------------------------------------------
/packages/lottie/platforms/android/include.gradle:
--------------------------------------------------------------------------------
1 |
2 | dependencies {
3 | def androidXAppCompatVersion = project.hasProperty("androidXAppCompat") ? project.androidXAppCompat : "1.3.1"
4 | implementation "androidx.appcompat:appcompat:$androidXAppCompatVersion"
5 | def lottieVersion = project.hasProperty("lottieVersion") ? project.lottieVersion : "5.2.0"
6 | implementation "com.airbnb.android:lottie:$lottieVersion"
7 | }
8 |
--------------------------------------------------------------------------------
/packages/lottie/platforms/android/java/com/nativescript/lottie/LottieAnimationView.java:
--------------------------------------------------------------------------------
1 | package com.nativescript.lottie;
2 |
3 | import androidx.core.view.ViewCompat;
4 | import android.view.View.MeasureSpec;
5 | import android.graphics.drawable.Drawable;
6 |
7 | public class LottieAnimationView extends com.airbnb.lottie.LottieAnimationView {
8 | private double scaleW = 1;
9 | private double scaleH = 1;
10 |
11 | public LottieAnimationView(android.content.Context context) {
12 | super(context);
13 | }
14 |
15 | @Override
16 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
17 |
18 | int width = MeasureSpec.getSize(widthMeasureSpec);
19 | int widthMode = MeasureSpec.getMode(widthMeasureSpec);
20 |
21 | int height = MeasureSpec.getSize(heightMeasureSpec);
22 | int heightMode = MeasureSpec.getMode(heightMeasureSpec);
23 |
24 | Drawable drawable = this.getDrawable();
25 | int measureWidth;
26 | int measureHeight;
27 | if (drawable != null) {
28 | measureWidth = drawable.getIntrinsicWidth();
29 | measureHeight = drawable.getIntrinsicHeight();
30 | } else {
31 | measureWidth = 0;
32 | measureHeight = 0;
33 | }
34 |
35 | boolean finiteWidth = widthMode != MeasureSpec.UNSPECIFIED;
36 | boolean finiteHeight = heightMode != MeasureSpec.UNSPECIFIED;
37 |
38 | if (measureWidth != 0 && measureHeight != 0 && (finiteWidth || finiteHeight)) {
39 | this.computeScaleFactor(width, height, finiteWidth, finiteHeight, measureWidth, measureHeight);
40 | int resultW = (int) Math.round(measureWidth * this.scaleW);
41 | int resultH = (int) Math.round(measureHeight * this.scaleH);
42 |
43 | measureWidth = finiteWidth ? Math.min(resultW, width) : resultW;
44 | measureHeight = finiteHeight ? Math.min(resultH, height) : resultH;
45 | }
46 |
47 | measureWidth += this.getPaddingLeft() + this.getPaddingRight();
48 | measureHeight += this.getPaddingTop() + this.getPaddingBottom();
49 |
50 | measureWidth = Math.max(measureWidth, getSuggestedMinimumWidth());
51 | measureHeight = Math.max(measureHeight, getSuggestedMinimumHeight());
52 |
53 | int widthSizeAndState = ViewCompat.resolveSizeAndState(measureWidth, widthMeasureSpec, 0);
54 | int heightSizeAndState = ViewCompat.resolveSizeAndState(measureHeight, heightMeasureSpec, 0);
55 |
56 | this.setMeasuredDimension(widthSizeAndState, heightSizeAndState);
57 | }
58 |
59 | private void computeScaleFactor(int measureWidth, int measureHeight, boolean widthIsFinite, boolean heightIsFinite, double nativeWidth, double nativeHeight) {
60 |
61 | this.scaleW = 1;
62 | this.scaleH = 1;
63 |
64 | ScaleType scale = this.getScaleType();
65 | if ((scale == ScaleType.CENTER_CROP || scale == ScaleType.FIT_CENTER || scale == ScaleType.FIT_XY) &&
66 | (widthIsFinite || heightIsFinite)) {
67 |
68 | this.scaleW = (nativeWidth > 0) ? measureWidth / nativeWidth : 0d;
69 | this.scaleH = (nativeHeight > 0) ? measureHeight / nativeHeight : 0d;
70 |
71 | if (!widthIsFinite) {
72 | this.scaleW = scaleH;
73 | } else if (!heightIsFinite) {
74 | this.scaleH = scaleW;
75 | } else {
76 | // No infinite dimensions.
77 | switch (scale) {
78 | case FIT_CENTER:
79 | this.scaleH = this.scaleW < this.scaleH ? this.scaleW : this.scaleH;
80 | this.scaleW = this.scaleH;
81 | break;
82 | case CENTER_CROP:
83 | this.scaleH = this.scaleW > this.scaleH ? this.scaleW : this.scaleH;
84 | this.scaleW = this.scaleH;
85 | break;
86 | default:
87 | break;
88 | }
89 | }
90 | }
91 | }
92 | }
--------------------------------------------------------------------------------
/packages/lottie/platforms/android/native-api-usage.json:
--------------------------------------------------------------------------------
1 | {
2 | "uses": [
3 | "com.airbnb.lottie:LottieAnimationView",
4 | "com.airbnb.lottie.model:KeyPath",
5 | "com.airbnb.lottie.value:LottieValueCallback",
6 | "com.airbnb.lottie:LottieProperty",
7 | "com.airbnb.lottie:SimpleColorFilter",
8 | "com.airbnb.lottie:RenderMode",
9 | "android.animation:Animator",
10 | "android.animation:Animator.AnimatorListener",
11 | "com.airbnb.lottie:LottieResult",
12 | "com.airbnb.lottie:LottieOnCompositionLoadedListener",
13 | "com.airbnb.lottie:LottieComposition",
14 | "com.airbnb.lottie:LottieCompositionFactory"
15 | ]
16 | }
--------------------------------------------------------------------------------
/packages/lottie/platforms/ios/Podfile:
--------------------------------------------------------------------------------
1 | pod 'lottie-ios', :git => 'https://github.com/farfromrefug/lottie-ios.git', :branch => "4.4.1"
2 | # pod 'lottie-ios', :path => '/Volumes/dev/ios/lottie-ios'
--------------------------------------------------------------------------------
/packages/lottie/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "rootDir": "../../src/lottie",
5 | "outDir": "./"
6 | },
7 | "include": ["../../src/lottie/**/*", "../../references.d.ts", "../../tools/references.d.ts", "../../src/references.d.ts"],
8 | "exclude": ["../../src/lottie/angular/**"],
9 | "references": [
10 | {
11 | //Need for tsc
12 | "path": "../../tsconfig.vue3.json"
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/pnpm-workspace.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 | - packages/*
3 | - demo-*
--------------------------------------------------------------------------------
/references.d.ts:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nativescript-community/ui-lottie/f25a85ed2993d6ce72ed19674c08cb1a54bf56f1/references.d.ts
--------------------------------------------------------------------------------
/sample-effects/HamburgerArrow.json:
--------------------------------------------------------------------------------
1 | {"assets":[],"layers":[{"ddd":0,"ind":0,"ty":3,"nm":"Rotator","ks":{"o":{"k":0},"r":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[190.7]},{"i":{"x":[0.562],"y":[1]},"o":{"x":[0.398],"y":[0]},"n":["0p562_1_0p398_0"],"t":33,"s":[190.7],"e":[176.1]},{"i":{"x":[0.684],"y":[1]},"o":{"x":[0.31],"y":[0]},"n":["0p684_1_0p31_0"],"t":40.5,"s":[176.1],"e":[181.8]},{"i":{"x":[0.684],"y":[1]},"o":{"x":[0.438],"y":[0]},"n":["0p684_1_0p438_0"],"t":55,"s":[181.8],"e":[180]},{"i":{"x":[0.733],"y":[0.733]},"o":{"x":[0.385],"y":[0.385]},"n":["0p733_0p733_0p385_0p385"],"t":71,"s":[180],"e":[180]},{"i":{"x":[0.092],"y":[1]},"o":{"x":[0.406],"y":[0]},"n":["0p092_1_0p406_0"],"t":111,"s":[180],"e":[167.9]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[167.9],"e":[363]},{"i":{"x":[0.462],"y":[1]},"o":{"x":[0.167],"y":[0]},"n":["0p462_1_0p167_0"],"t":134,"s":[363],"e":[360]},{"t":141}]},"p":{"k":[200.5,149.375,0]},"a":{"k":[60,60,0]},"s":{"k":[100,100,100]}},"ao":0,"ip":0,"op":180,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":1,"ty":4,"nm":"A1","parent":0,"ks":{"o":{"k":100},"r":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[-45]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[-45],"e":[-45]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[-45],"e":[0]},{"t":134}]},"p":{"k":[{"i":{"x":0.56,"y":1},"o":{"x":0.634,"y":0},"n":"0p56_1_0p634_0","t":19,"s":[94.5,82.875,0],"e":[96.2,57.055,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0,"y":0},"o":{"x":0.167,"y":0.167},"n":"0_0_0p167_0p167","t":33,"s":[96.2,57.055,0],"e":[96.2,57.055,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.341,"y":1},"o":{"x":0.6,"y":0},"n":"0p341_1_0p6_0","t":116,"s":[96.2,57.055,0],"e":[94.5,82.875,0],"to":[0,0,0],"ti":[0,0,0]},{"t":134}]},"a":{"k":[35,22.25,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-34,22.25],[35,22.25]],"c":false}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.4,0.16,0.7,1]},"o":{"k":100},"w":{"k":10},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1"},{"ty":"tm","s":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[26]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[26],"e":[26]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[26],"e":[0]},{"t":134}],"ix":1},"e":{"k":[{"i":{"x":[0.56],"y":[0.56]},"o":{"x":[0.634],"y":[0.634]},"n":["0p56_0p56_0p634_0p634"],"t":19,"s":[100],"e":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[100],"e":[100]},{"i":{"x":[0.341],"y":[0.341]},"o":{"x":[0.6],"y":[0.6]},"n":["0p341_0p341_0p6_0p6"],"t":116,"s":[100],"e":[100]},{"t":134}],"ix":2},"o":{"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1"}],"ip":0,"op":180,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":4,"nm":"A2","parent":0,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[60,60.625,0]},"a":{"k":[0.5,0,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-34,0],[35,0]],"c":false}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.4,0.16,0.7,1]},"o":{"k":100},"w":{"k":10},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1"}],"ip":0,"op":180,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":3,"ty":4,"nm":"A3","parent":0,"ks":{"o":{"k":100},"r":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[45]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[45],"e":[45]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[45],"e":[0]},{"t":134}]},"p":{"k":[{"i":{"x":0.56,"y":1},"o":{"x":0.634,"y":0},"n":"0p56_1_0p634_0","t":19,"s":[94.5,37.125,0],"e":[96.2,64.045,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0,"y":0},"o":{"x":0.167,"y":0.167},"n":"0_0_0p167_0p167","t":33,"s":[96.2,64.045,0],"e":[96.2,64.045,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.341,"y":1},"o":{"x":0.6,"y":0},"n":"0p341_1_0p6_0","t":116,"s":[96.2,64.045,0],"e":[94.5,37.125,0],"to":[0,0,0],"ti":[0,0,0]},{"t":134}]},"a":{"k":[35,-23.5,0]},"s":{"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ks":{"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-34,-23.5],[35,-23.5]],"c":false}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.4,0.16,0.7,1]},"o":{"k":100},"w":{"k":10},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Shape 1"},{"ty":"tm","s":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[26]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[26],"e":[26]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[26],"e":[0]},{"t":134}],"ix":1},"e":{"k":[{"i":{"x":[0.56],"y":[0.56]},"o":{"x":[0.634],"y":[0.634]},"n":["0p56_0p56_0p634_0p634"],"t":19,"s":[100],"e":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":33,"s":[100],"e":[100]},{"i":{"x":[0.341],"y":[0.341]},"o":{"x":[0.6],"y":[0.6]},"n":["0p341_0p341_0p6_0p6"],"t":116,"s":[100],"e":[100]},{"t":134}],"ix":2},"o":{"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1"}],"ip":0,"op":180,"st":0,"bm":0,"sr":1}],"v":"4.4.26","ddd":0,"ip":0,"op":180,"fr":30,"w":400,"h":300}
2 |
--------------------------------------------------------------------------------
/sample-effects/LightBulb.json:
--------------------------------------------------------------------------------
1 | {"assets":[],"v":"4.3.1","ddd":0,"layers":[{"ddd":0,"ind":0,"ty":4,"nm":"IL","parent":5,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[15,15,0]},"a":{"k":[15,15,0]},"s":{"k":[100,100,100]}},"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","closed":false,"ks":{"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[12.38,24.417],[18.715,24.417]]}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.26,0.24,0.25,1]},"o":{"k":100},"w":{"k":1},"lc":2,"lj":2,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[0,0],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 2"}],"bounds":{"l":11,"t":23,"b":25,"r":20},"ip":14.5,"op":150,"st":23.5,"bm":0,"sr":1},{"ddd":0,"ind":1,"ty":4,"nm":"F","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[19.4,19.8,0]},"a":{"k":[15,15,0]},"s":{"k":[100,100,100]}},"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","closed":false,"ks":{"k":{"i":[[0,0],[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0],[0,0]],"v":[[-0.896,-1.738],[0.896,0.279],[0.094,1.357],[-0.892,2.698],[-0.86,26.758]]}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.26,0.24,0.25,1]},"o":{"k":100},"w":{"k":1},"lc":2,"lj":2,"nm":"Stroke 1"},{"ty":"tm","s":{"k":[{"i":{"x":[0.1],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"n":["0p1_1_0p167_0p167"],"t":23.5,"s":[61.6],"e":[0]},{"t":36.5}],"ix":1},"e":{"k":[{"i":{"x":[0.1],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"n":["0p1_1_0p167_0p167"],"t":23.5,"s":[58.5],"e":[26]},{"t":36.5}],"ix":2},"o":{"k":0,"ix":3},"m":1,"ix":3,"nm":"Trim Paths 1"},{"ty":"tr","p":{"k":[16.423,12.685],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 4"}],"bounds":{"l":15,"t":10,"b":40,"r":18},"ip":23.5,"op":150,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":2,"ty":4,"nm":"H6","parent":5,"ks":{"o":{"k":100},"r":{"k":230},"p":{"k":[15.434,13.798,0]},"a":{"k":[15.434,13.798,0]},"s":{"k":[100,100,100]}},"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"k":[{"i":{"x":[0.1,0.1],"y":[1,1]},"o":{"x":[0.167,0.167],"y":[0.167,0.167]},"n":["0p1_1_0p167_0p167","0p1_1_0p167_0p167"],"t":42.5,"s":[16.462,16.462],"e":[28.562,28.562],"__fnct":[null,null]},{"t":55.5}]},"p":{"k":[0,0]},"nm":"Ellipse Path 1","closed":true},{"d":1,"ty":"el","s":{"k":[{"i":{"x":[0.1,0.1],"y":[1,1]},"o":{"x":[0.167,0.167],"y":[0.167,0.167]},"n":["0p1_1_0p167_0p167","0p1_1_0p167_0p167"],"t":42.5,"s":[16.462,16.462],"e":[28.562,28.562],"__fnct":[null,null]},{"t":55.5}]},"p":{"k":[0,0]},"nm":"Ellipse Path 1","closed":true},{"ty":"tm","s":{"k":65,"ix":1},"e":{"k":75,"ix":2},"o":{"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.26,0.24,0.25,1]},"o":{"k":100},"w":{"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":46,"s":[1],"e":[0],"__fnct":[null]},{"t":55.5}]},"lc":2,"lj":2,"d":[{"n":"d","nm":"dash","v":{"k":0}},{"n":"g","nm":"gap","v":{"k":2.5}},{"n":"o","nm":"offset","v":{"k":0}}],"nm":"Stroke 1"},{"ty":"tr","p":{"k":[15.45,13.746],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1"}],"bounds":{"l":-6,"t":-7,"b":35,"r":37},"ip":42.5,"op":62.5,"st":-27,"bm":0,"sr":1},{"ddd":0,"ind":3,"ty":4,"nm":"H5","parent":5,"ks":{"o":{"k":100},"r":{"k":138},"p":{"k":[15.434,13.798,0]},"a":{"k":[15.434,13.798,0]},"s":{"k":[100,100,100]}},"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"k":[{"i":{"x":[0.1,0.1],"y":[1,1]},"o":{"x":[0.167,0.167],"y":[0.167,0.167]},"n":["0p1_1_0p167_0p167","0p1_1_0p167_0p167"],"t":45,"s":[16.462,16.462],"e":[28.562,28.562],"__fnct":[null,null]},{"t":58}]},"p":{"k":[0,0]},"nm":"Ellipse Path 1","closed":true},{"d":1,"ty":"el","s":{"k":[{"i":{"x":[0.1,0.1],"y":[1,1]},"o":{"x":[0.167,0.167],"y":[0.167,0.167]},"n":["0p1_1_0p167_0p167","0p1_1_0p167_0p167"],"t":45,"s":[16.462,16.462],"e":[28.562,28.562],"__fnct":[null,null]},{"t":58}]},"p":{"k":[0,0]},"nm":"Ellipse Path 1","closed":true},{"ty":"tm","s":{"k":60,"ix":1},"e":{"k":80,"ix":2},"o":{"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.26,0.24,0.25,1]},"o":{"k":100},"w":{"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":48.5,"s":[1],"e":[0],"__fnct":[null]},{"t":58}]},"lc":2,"lj":2,"d":[{"n":"d","nm":"dash","v":{"k":0}},{"n":"g","nm":"gap","v":{"k":2}},{"n":"o","nm":"offset","v":{"k":0}}],"nm":"Stroke 1"},{"ty":"tr","p":{"k":[15.45,13.746],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1"}],"bounds":{"l":-6,"t":-7,"b":35,"r":37},"ip":45,"op":62.5,"st":-24.5,"bm":0,"sr":1},{"ddd":0,"ind":4,"ty":4,"nm":"H7","parent":5,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[15.434,13.798,0]},"a":{"k":[15.434,13.798,0]},"s":{"k":[100,100,100]}},"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"k":[{"i":{"x":[0.1,0.1],"y":[1,1]},"o":{"x":[0.167,0.167],"y":[0.167,0.167]},"n":["0p1_1_0p167_0p167","0p1_1_0p167_0p167"],"t":42.5,"s":[16.462,16.462],"e":[28.562,28.562],"__fnct":[null,null]},{"t":55.5}]},"p":{"k":[0,0]},"nm":"Ellipse Path 1","closed":true},{"d":1,"ty":"el","s":{"k":[{"i":{"x":[0.1,0.1],"y":[1,1]},"o":{"x":[0.167,0.167],"y":[0.167,0.167]},"n":["0p1_1_0p167_0p167","0p1_1_0p167_0p167"],"t":42.5,"s":[16.462,16.462],"e":[28.562,28.562],"__fnct":[null,null]},{"t":55.5}]},"p":{"k":[0,0]},"nm":"Ellipse Path 1","closed":true},{"ty":"tm","s":{"k":60.7,"ix":1},"e":{"k":85,"ix":2},"o":{"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.26,0.24,0.25,1]},"o":{"k":100},"w":{"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":46,"s":[1],"e":[0],"__fnct":[null]},{"t":55.5}]},"lc":2,"lj":2,"d":[{"n":"d","nm":"dash","v":{"k":0}},{"n":"g","nm":"gap","v":{"k":2}},{"n":"o","nm":"offset","v":{"k":0}}],"nm":"Stroke 1"},{"ty":"tr","p":{"k":[15.45,13.746],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1"}],"bounds":{"l":-6,"t":-7,"b":35,"r":37},"ip":42.5,"op":62.5,"st":-27,"bm":0,"sr":1},{"ddd":0,"ind":5,"ty":4,"nm":"OU","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[{"i":{"x":0,"y":0},"o":{"x":0.167,"y":0.167},"n":"0_0_0p167_0p167","t":14.5,"s":[19.834,33.477,0],"e":[19.834,33.477,0],"to":[0,0,0],"ti":[0,0,0]},{"t":29.5}]},"a":{"k":[15.434,28.677,0]},"s":{"k":[{"i":{"x":[0,0,0],"y":[1,1,0]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"n":["0_1_0p167_0p167","0_1_0p167_0p167","0_0_0p167_0p167"],"t":14.5,"s":[16,16,100],"e":[100,100,100]},{"t":29.5}]}},"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","closed":false,"ks":{"k":[{"i":{"x":0,"y":1},"o":{"x":0.167,"y":0.167},"n":"0_1_0p167_0p167","t":14.5,"s":[{"i":[[0,0],[0.263,0.089],[0.733,0.619]],"o":[[-0.275,-0.06],[-0.93,-0.312],[0,0]],"v":[[1.66,0.82],[0.853,0.596],[-1.66,-0.82]]}],"e":[{"i":[[0,0],[0.263,0.089],[0.733,0.619]],"o":[[-0.275,-0.06],[-0.93,-0.312],[0,0]],"v":[[1.66,0.82],[0.853,0.596],[-1.66,-0.82]]}]},{"t":29.5}]},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.26,0.24,0.25,1]},"o":{"k":100},"w":{"k":1},"lc":2,"lj":2,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[12.114,20.529],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1"},{"ty":"gr","it":[{"ind":0,"ty":"sh","closed":true,"ks":{"k":{"i":[[0,2.418],[4.269,0],[0,-4.27],[-1.817,-1.412],[0,-1.088],[0,0],[-0.475,-0.48],[-0.675,0],[0,0],[-0.443,0.478],[0,0.657],[0,0],[-0.875,0.712]],"o":[[0,-4.27],[-4.269,0],[0,2.479],[0.859,0.669],[0,0],[0,0.675],[0.475,0.48],[0,0],[0.652,0],[0.448,-0.481],[0,0],[0,-1.128],[1.739,-1.415]],"v":[[7.73,-3.574],[0,-11.305],[-7.73,-3.574],[-4.743,2.52],[-3.237,5.238],[-3.237,8.747],[-2.494,10.553],[-0.694,11.305],[0.86,11.305],[2.582,10.553],[3.28,8.779],[3.28,5.217],[4.878,2.412]]}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.26,0.24,0.25,1]},"o":{"k":100},"w":{"k":1},"lc":2,"lj":2,"nm":"Stroke 2"},{"ty":"st","fillEnabled":true,"c":{"k":[0.26,0.24,0.25,1]},"o":{"k":100},"w":{"k":1},"lc":2,"lj":2,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[15.434,17.373],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 5"}],"bounds":{"l":6,"t":4,"b":31,"r":25},"ip":14.5,"op":150,"st":0,"bm":0,"sr":1},{"ddd":0,"ind":6,"ty":4,"nm":"H3","parent":5,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[15.434,13.798,0]},"a":{"k":[15.434,13.798,0]},"s":{"k":[{"i":{"x":[0.19,0.19,0.19],"y":[1,1,0.19]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"n":["0p19_1_0p167_0p167","0p19_1_0p167_0p167","0p19_0p19_0p167_0p167"],"t":52,"s":[71.2,71.2,100],"e":[100,100,100]},{"t":78}]}},"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","closed":false,"ks":{"k":{"i":[[0,0],[-3.194,4.512]],"o":[[-4.016,-3.803],[0,0]],"v":[[2.327,7.337],[0.867,-7.337]]}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.26,0.24,0.25,1]},"o":{"k":100},"w":{"k":1},"lc":2,"lj":2,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[5.377,14.639],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 6"}],"bounds":{"l":3,"t":6,"b":23,"r":9},"ip":51.5,"op":150,"st":34,"bm":0,"sr":1},{"ddd":0,"ind":7,"ty":4,"nm":"H2","parent":5,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[15,15,0]},"a":{"k":[15,15,0]},"s":{"k":[{"i":{"x":[0.19,0.19,0.19],"y":[1,1,0.19]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"n":["0p19_1_0p167_0p167","0p19_1_0p167_0p167","0p19_0p19_0p167_0p167"],"t":48.5,"s":[73,73,100],"e":[100,100,100]},{"t":65.5}]}},"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","closed":false,"ks":{"k":{"i":[[0,0],[-3.358,-5.293],[-0.145,-1.74]],"o":[[5.221,-3.587],[0.936,1.475],[0,0]],"v":[[-8.792,-2.382],[7.141,1.064],[8.792,5.969]]}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.26,0.24,0.25,1]},"o":{"k":100},"w":{"k":1},"lc":2,"lj":2,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[17.856,6.903],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 7"}],"bounds":{"l":8,"t":2,"b":14,"r":28},"ip":48,"op":150,"st":30.5,"bm":0,"sr":1},{"ddd":0,"ind":8,"ty":4,"nm":"H1","parent":5,"ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[15.434,13.798,0]},"a":{"k":[15.434,13.798,0]},"s":{"k":[{"i":{"x":[0.19,0.19,0.19],"y":[1,1,0.19]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"n":["0p19_1_0p167_0p167","0p19_1_0p167_0p167","0p19_0p19_0p167_0p167"],"t":59,"s":[71.6,71.6,100],"e":[100,100,100]},{"t":84}]}},"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","closed":false,"ks":{"k":{"i":[[0,0],[1.417,-1.416]],"o":[[-0.502,1.939],[0,0]],"v":[[1.471,-2.577],[-1.471,2.577]]}},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[0.26,0.24,0.25,1]},"o":{"k":100},"w":{"k":1},"lc":2,"lj":2,"nm":"Stroke 1"},{"ty":"tr","p":{"k":[24.859,19.181],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 8"}],"bounds":{"l":22,"t":16,"b":23,"r":27},"ip":58.5,"op":150,"st":41,"bm":0,"sr":1},{"ddd":0,"ind":9,"ty":4,"nm":"BG","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[{"i":{"x":0,"y":0},"o":{"x":0.167,"y":0.167},"n":"0_0_0p167_0p167","t":25,"s":[19.4,19.8,0],"e":[19.4,19.8,0],"to":[0,0,0],"ti":[0,0,0]},{"t":29}]},"a":{"k":[15,15,0]},"s":{"k":[100,100,100]}},"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","closed":true,"ks":{"k":[{"i":{"x":0,"y":1},"o":{"x":0.167,"y":0.167},"n":"0_1_0p167_0p167","t":25,"s":[{"i":[[0,-0.831],[1.196,0],[0,0.831],[-1.196,0]],"o":[[0,0.831],[-1.196,0],[0,-0.831],[1.196,0]],"v":[[2.166,8.157],[0,9.662],[-2.166,8.157],[0,6.652]]}],"e":[{"i":[[0,-3.265],[3.265,0],[0,3.265],[-3.264,0]],"o":[[0,3.265],[-3.264,0],[0,-3.265],[3.265,0]],"v":[[5.911,0],[-0.001,5.912],[-5.911,0],[-0.001,-5.912]]}]},{"t":29}]},"nm":"Path 1"},{"ty":"fl","fillEnabled":true,"c":{"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":37.5,"s":[0.8,0.8,0.8,1],"e":[1,0.68,0,1]},{"t":43.5}]},"o":{"k":100},"nm":"Fill 1"},{"ty":"tr","p":{"k":[15.434,13.798],"ix":2},"a":{"k":[0,0],"ix":1},"s":{"k":[100,100],"ix":3},"r":{"k":0,"ix":6},"o":{"k":100,"ix":7},"sk":{"k":0,"ix":4},"sa":{"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 9"}],"bounds":{"l":9,"t":7,"b":24,"r":22},"ip":25,"op":150,"st":-2,"bm":0,"sr":1}],"ip":0,"op":150,"fr":30,"w":40,"h":40}
2 |
--------------------------------------------------------------------------------
/screens/android_assets.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nativescript-community/ui-lottie/f25a85ed2993d6ce72ed19674c08cb1a54bf56f1/screens/android_assets.png
--------------------------------------------------------------------------------
/screens/ios_assets.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nativescript-community/ui-lottie/f25a85ed2993d6ce72ed19674c08cb1a54bf56f1/screens/ios_assets.png
--------------------------------------------------------------------------------
/screens/lottieDemo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nativescript-community/ui-lottie/f25a85ed2993d6ce72ed19674c08cb1a54bf56f1/screens/lottieDemo.gif
--------------------------------------------------------------------------------
/src/lottie/angular/index.ts:
--------------------------------------------------------------------------------
1 | import { Directive, NgModule } from '@angular/core';
2 | import { registerElement } from '@nativescript/angular';
3 | // @ts-ignore
4 | import { LottieView } from '@nativescript-community/ui-lottie';
5 |
6 | @Directive({ selector: 'LottieView' })
7 | export class LottieViewDirective {}
8 |
9 | @NgModule({
10 | declarations: [LottieViewDirective],
11 | exports: [LottieViewDirective]
12 | })
13 | export class NativeScriptLottieModule {}
14 |
15 | registerElement('LottieView', () => LottieView);
16 |
--------------------------------------------------------------------------------
/src/lottie/angular/ng-package.json:
--------------------------------------------------------------------------------
1 | {
2 | "dest": "../../../packages/lottie/angular",
3 | "lib": {
4 | "entryFile": "index.ts"
5 | },
6 | "allowedNonPeerDependencies": [
7 | "."
8 | ]
9 | }
--------------------------------------------------------------------------------
/src/lottie/angular/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@nativescript-community/ui-lottie-angular",
3 | "main": "index.js"
4 | }
--------------------------------------------------------------------------------
/src/lottie/angular/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../../tsconfig.json",
3 | "compilerOptions": {
4 | "rootDir": "./",
5 | "plugins": [],
6 | "paths": {
7 | "@nativescript-community/ui-lottie": ["packages/lottie"]
8 | }
9 | },
10 | "include": ["./**/*.ts"],
11 | "exclude": ["../node_modules"]
12 | }
--------------------------------------------------------------------------------
/src/lottie/index.android.ts:
--------------------------------------------------------------------------------
1 | /**********************************************************************************
2 | * (c) 2017, Brad Martin.
3 | * Licensed under the MIT license.
4 | *
5 | * Version 1.0.0 bradwaynemartin@gmail.com
6 | **********************************************************************************/
7 |
8 | import { Color, File, Utils } from '@nativescript/core';
9 | import { LottieViewBase, autoPlayProperty, keyPathColorsProperty, loopProperty, progressProperty, renderModeProperty, srcProperty, stretchProperty } from './index.common';
10 | import { clamp } from './utils';
11 |
12 | let LottieProperty: typeof com.airbnb.lottie.LottieProperty;
13 | let LottieKeyPath: typeof com.airbnb.lottie.model.KeyPath;
14 | let LottieValueCallback: typeof com.airbnb.lottie.value.LottieValueCallback;
15 | let LottieCompositionFactory: typeof com.airbnb.lottie.LottieCompositionFactory;
16 |
17 | const cache = new Map();
18 | async function loadLottieJSON(iconSrc) {
19 | if (!cache.has(iconSrc)) {
20 | const file = File.fromPath(iconSrc);
21 | const r = await file.readText();
22 | cache.set(iconSrc, r);
23 | return r;
24 | }
25 | return cache.get(iconSrc);
26 | }
27 | function loadLottieJSONSync(iconSrc) {
28 | if (!cache.has(iconSrc)) {
29 | const file = File.fromPath(iconSrc);
30 | const r = file.readTextSync();
31 | cache.set(iconSrc, r);
32 | return r;
33 | }
34 | return cache.get(iconSrc);
35 | }
36 |
37 | export const RenderMode = {
38 | get AUTOMATIC() {
39 | return com.airbnb.lottie.RenderMode.AUTOMATIC;
40 | },
41 | get HARDWARE() {
42 | return com.airbnb.lottie.RenderMode.HARDWARE;
43 | },
44 | get SOFTWARE() {
45 | return com.airbnb.lottie.RenderMode.SOFTWARE;
46 | }
47 | };
48 |
49 | export class LottieView extends LottieViewBase {
50 | nativeViewProtected: com.airbnb.lottie.LottieAnimationView;
51 |
52 | public createNativeView() {
53 | return new com.nativescript.lottie.LottieAnimationView(this._context);
54 | }
55 |
56 | animatorListener: android.animation.Animator.AnimatorListener;
57 | loadedListener: com.airbnb.lottie.LottieOnCompositionLoadedListener;
58 | _completionBlock;
59 | //@ts-ignore
60 | get completionBlock() {
61 | return this._completionBlock;
62 | }
63 | set completionBlock(block) {
64 | this._completionBlock = block;
65 | if (block) {
66 | if (!this.animatorListener) {
67 | const that = new WeakRef(this);
68 | this.animatorListener = new android.animation.Animator.AnimatorListener({
69 | onAnimationCancel: (_animator) => {
70 | const owner = that?.get();
71 | if (owner?._completionBlock) {
72 | owner._completionBlock(false);
73 | }
74 | },
75 | onAnimationEnd: (_animator) => {
76 | const owner = that?.get();
77 | if (owner?._completionBlock) {
78 | owner._completionBlock(true);
79 | }
80 | },
81 | onAnimationRepeat: (_animator) => {
82 | // noop
83 | },
84 | onAnimationStart: (_animator) => {
85 | // noop
86 | }
87 | });
88 | if (this.nativeViewProtected) {
89 | this.nativeViewProtected.addAnimatorListener(this.animatorListener);
90 | }
91 | }
92 | } else if (this.animatorListener) {
93 | if (this.nativeViewProtected) {
94 | this.nativeViewProtected.removeAnimatorListener(this.animatorListener);
95 | }
96 | this.animatorListener = null;
97 | }
98 | }
99 | public initNativeView(): void {
100 | if (this.animatorListener) {
101 | this.nativeViewProtected.addAnimatorListener(this.animatorListener);
102 | }
103 | if (!this.loadedListener) {
104 | const that = new WeakRef(this);
105 | this.loadedListener = new com.airbnb.lottie.LottieOnCompositionLoadedListener({
106 | onCompositionLoaded: (composition) => {
107 | const owner = that?.get();
108 | if (owner) {
109 | // delay just a bit so that it get received in sync load
110 | setTimeout(() => {
111 | this.notify({ eventName: 'compositionLoaded', composition });
112 | }, 0);
113 | }
114 | }
115 | });
116 | }
117 | this.nativeViewProtected.addLottieOnCompositionLoadedListener(this.loadedListener);
118 | }
119 |
120 | public disposeNativeView(): void {
121 | if (this.animatorListener) {
122 | this.nativeViewProtected.removeAnimatorListener(this.animatorListener);
123 | }
124 | if (this.loadedListener) {
125 | this.nativeViewProtected.removeLottieOnCompositionLoadedListener(this.loadedListener);
126 | }
127 | super.disposeNativeView();
128 | }
129 |
130 | public setColor(value: Color | string, keyPath: string[]): void {
131 | const nativeView = this.nativeViewProtected;
132 | if (nativeView && value && keyPath && keyPath.length) {
133 | if (keyPath[keyPath.length - 1].toLowerCase() === 'color') {
134 | keyPath = [...keyPath];
135 | keyPath.pop(); // android specifies the property as an enum parameter.
136 | if (keyPath.length === 0) {
137 | return;
138 | }
139 | }
140 | const nativeKeyPath: any[] = Array.create(java.lang.String, keyPath.length);
141 | for (let index = 0; index < keyPath.length; index++) {
142 | nativeKeyPath[index] = keyPath[index];
143 | }
144 | if (!LottieProperty) {
145 | LottieProperty = com.airbnb.lottie.LottieProperty;
146 | }
147 | if (!LottieValueCallback) {
148 | LottieValueCallback = com.airbnb.lottie.value.LottieValueCallback;
149 | }
150 |
151 | if (!LottieKeyPath) {
152 | LottieKeyPath = com.airbnb.lottie.model.KeyPath;
153 | }
154 | // by using color filter we change all colors (STROKE_COLOR and COLOR)
155 | const color = value instanceof Color ? value : new Color(value);
156 | // const colorFilter = new android.graphics.PorterDuffColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_ATOP) ;
157 | const colorFilter = new com.airbnb.lottie.SimpleColorFilter(color.android);
158 | nativeView.addValueCallback(new LottieKeyPath(nativeKeyPath as any), LottieProperty.COLOR_FILTER, new LottieValueCallback(colorFilter));
159 | // nativeView.addValueCallback(
160 | // new LottieKeyPath(nativeKeyPath as any),
161 | // LottieProperty.COLOR,
162 | // new LottieValueCallback(java.lang.Integer.valueOf(value.android))
163 | // );
164 | }
165 | }
166 |
167 | public setOpacity(value: number, keyPath: string[]): void {
168 | if (this.nativeViewProtected && value && keyPath && keyPath.length) {
169 | if (keyPath[keyPath.length - 1].toLowerCase() === 'opacity') {
170 | keyPath.pop();
171 | if (keyPath.length === 0) {
172 | return;
173 | }
174 | }
175 | const nativeKeyPath: java.lang.String[] = Array.create(java.lang.String, keyPath.length);
176 | keyPath.forEach((key, index) => {
177 | nativeKeyPath[index] = new java.lang.String(key);
178 | });
179 | value = clamp(value);
180 | if (!LottieProperty) {
181 | LottieProperty = com.airbnb.lottie.LottieProperty;
182 | }
183 | if (!LottieValueCallback) {
184 | LottieValueCallback = com.airbnb.lottie.value.LottieValueCallback;
185 | }
186 |
187 | if (!LottieKeyPath) {
188 | LottieKeyPath = com.airbnb.lottie.model.KeyPath;
189 | }
190 | this.nativeViewProtected.addValueCallback(new LottieKeyPath(nativeKeyPath as any), LottieProperty.OPACITY, new LottieValueCallback(new java.lang.Integer(value * 100)));
191 | }
192 | }
193 |
194 | public playAnimation(): void {
195 | if (this.nativeViewProtected) {
196 | this.nativeViewProtected.setMinAndMaxProgress(0, 1);
197 | this.nativeViewProtected.playAnimation();
198 | }
199 | }
200 |
201 | public playAnimationFromProgressToProgress(startProgress: number, endProgress: number): void {
202 | if (this.nativeViewProtected) {
203 | startProgress = startProgress ? clamp(startProgress) : 0;
204 | endProgress = endProgress ? clamp(endProgress) : 1;
205 | this.nativeViewProtected.setMinAndMaxProgress(startProgress, endProgress);
206 | this.nativeViewProtected.playAnimation();
207 | }
208 | }
209 |
210 | public isAnimating(): boolean {
211 | return this.nativeViewProtected ? this.nativeViewProtected.isAnimating() : false;
212 | }
213 |
214 | public get speed(): number | undefined {
215 | return this.nativeViewProtected ? this.nativeViewProtected.getSpeed() : undefined;
216 | }
217 |
218 | public set speed(value: number) {
219 | if (this.nativeViewProtected && value) {
220 | this.nativeViewProtected.setSpeed(value);
221 | }
222 | }
223 |
224 | public get duration(): number | undefined {
225 | return this.nativeViewProtected ? this.nativeViewProtected.getDuration() : undefined;
226 | }
227 |
228 | public cancelAnimation(): void {
229 | if (this.nativeViewProtected) {
230 | this.nativeViewProtected.cancelAnimation();
231 | }
232 | }
233 |
234 | [srcProperty.setNative](src: string) {
235 | try {
236 | if (LottieCompositionFactory) {
237 | LottieCompositionFactory = com.airbnb.lottie.LottieCompositionFactory;
238 | }
239 | const view = this.nativeViewProtected;
240 | let result: com.airbnb.lottie.LottieResult;
241 | if (!src) {
242 | // lottie does not support "clearing the animation"
243 | // view.setAnimation(null);
244 | } else if (src[0] === '{') {
245 | if (this.async) {
246 | view.setAnimationFromJson(src, null);
247 | } else {
248 | result = LottieCompositionFactory.fromJsonStringSync(this._context, src);
249 | }
250 | } else if (src.startsWith(Utils.RESOURCE_PREFIX)) {
251 | const resName = src.replace(Utils.RESOURCE_PREFIX, '');
252 | if (this.async) {
253 | view.setAnimation(resName);
254 | } else {
255 | result = com.airbnb.lottie.LottieCompositionFactory.fromAssetSync(this._context, resName);
256 | }
257 | } else {
258 | if (!/.(json|zip|lottie)$/.test(src)) {
259 | src += '.json';
260 | }
261 | if (src[0] === '~') {
262 | if (this.async) {
263 | view.setAnimation('app/' + src.substring(2));
264 | } else {
265 | result = com.airbnb.lottie.LottieCompositionFactory.fromAssetSync(this._context, 'app/' + src.substring(2));
266 | }
267 | } else if (!src.startsWith('file:/') && src[0] !== '/') {
268 | if (this.async) {
269 | view.setAnimation('app/' + src);
270 | } else {
271 | result = com.airbnb.lottie.LottieCompositionFactory.fromAssetSync(this._context, src);
272 | }
273 | } else {
274 | if (this.async) {
275 | loadLottieJSON(src).then((result) => {
276 | if (this.nativeViewProtected) {
277 | this.nativeViewProtected.setAnimationFromJson(result, null);
278 | }
279 | });
280 | } else {
281 | result = LottieCompositionFactory.fromJsonStringSync(this._context, loadLottieJSONSync(src));
282 | }
283 | }
284 | }
285 | if (result) {
286 | if (result.getException()) {
287 | console.error(result.getException());
288 | // view.setComposition(null);
289 | } else {
290 | view.setComposition(result.getValue());
291 |
292 | //in sync loading we need to fire it ourselves
293 | // if we dont differ it from now it wont be received
294 | // setTimeout(() => {
295 | // this.notify({ eventName: 'compositionLoaded', composition: result.getValue() });
296 | // }, 0);
297 | }
298 | }
299 | if (this.autoPlay) {
300 | this.playAnimation();
301 | }
302 | } catch (error) {
303 | console.error(error);
304 | }
305 | }
306 |
307 | [loopProperty.setNative](loop: boolean) {
308 | this.nativeViewProtected.setRepeatCount(loop ? -1 /* android.animation.ValueAnimator.INFINITE */ : 0);
309 | }
310 |
311 | [progressProperty.setNative](value: number) {
312 | this.nativeViewProtected.setProgress(value);
313 | }
314 | [renderModeProperty.setNative](renderMode) {
315 | this.nativeViewProtected.setRenderMode(renderMode);
316 | }
317 | [keyPathColorsProperty.setNative](value) {
318 | Object.keys(value).forEach((k) => this.setColor(value[k], k.split('|')));
319 | }
320 |
321 | [autoPlayProperty.setNative](autoPlay: boolean) {
322 | if (autoPlay) {
323 | if (!this.isAnimating()) {
324 | this.playAnimation();
325 | }
326 | } else {
327 | // disable check for now as isAnimating always returns false
328 | // if (this.isAnimating()) {
329 | this.cancelAnimation();
330 | if (this.progress) {
331 | this.nativeViewProtected.setProgress(this.progress);
332 | }
333 | // }
334 | }
335 | }
336 |
337 | [stretchProperty.getDefault](): 'aspectFit' {
338 | return 'aspectFit';
339 | }
340 | [stretchProperty.setNative](value: 'none' | 'aspectFill' | 'aspectFit' | 'fill') {
341 | switch (value) {
342 | case 'aspectFit':
343 | this.nativeViewProtected.setScaleType(android.widget.ImageView.ScaleType.FIT_CENTER);
344 | break;
345 | case 'aspectFill':
346 | this.nativeViewProtected.setScaleType(android.widget.ImageView.ScaleType.CENTER_CROP);
347 | break;
348 | case 'fill':
349 | this.nativeViewProtected.setScaleType(android.widget.ImageView.ScaleType.FIT_XY);
350 | break;
351 | case 'none':
352 | default:
353 | this.nativeViewProtected.setScaleType(android.widget.ImageView.ScaleType.MATRIX);
354 | break;
355 | }
356 | }
357 | }
358 |
--------------------------------------------------------------------------------
/src/lottie/index.common.ts:
--------------------------------------------------------------------------------
1 | /**********************************************************************************
2 | * (c) 2017, Nathan Walker.
3 | * Licensed under the MIT license.
4 | *
5 | * Version 1.0.0 walkerrunpdx@gmail.com
6 | **********************************************************************************/
7 |
8 | import { CoreTypes, Property, View, booleanConverter } from '@nativescript/core';
9 | import { KeyPathColors } from '.';
10 |
11 | export class LottieViewBase extends View {
12 | public stretch: CoreTypes.ImageStretchType;
13 | public async: boolean;
14 | public src: string;
15 | public loop: boolean;
16 | public autoPlay: boolean;
17 | public progress: number;
18 | public keyPathColors: KeyPathColors;
19 | public completionBlock: (animationFinished: boolean) => void;
20 | }
21 |
22 | export const srcProperty = new Property({
23 | name: 'src'
24 | });
25 | srcProperty.register(LottieViewBase);
26 |
27 | export const asyncProperty = new Property({
28 | name: 'async',
29 | defaultValue: false,
30 | valueConverter: booleanConverter
31 | });
32 | asyncProperty.register(LottieViewBase);
33 | export const loopProperty = new Property({
34 | name: 'loop',
35 | defaultValue: false,
36 | valueConverter: booleanConverter
37 | });
38 | loopProperty.register(LottieViewBase);
39 |
40 | export const autoPlayProperty = new Property({
41 | name: 'autoPlay',
42 | defaultValue: false,
43 | valueConverter: booleanConverter
44 | });
45 | autoPlayProperty.register(LottieViewBase);
46 |
47 | export const renderModeProperty = new Property({
48 | name: 'renderMode'
49 | });
50 | renderModeProperty.register(LottieViewBase);
51 |
52 | export const progressProperty = new Property({
53 | name: 'progress'
54 | });
55 | progressProperty.register(LottieViewBase);
56 |
57 | export const stretchProperty = new Property({
58 | name: 'stretch',
59 | defaultValue: 'aspectFit',
60 | affectsLayout: global.isIOS
61 | });
62 | stretchProperty.register(LottieViewBase);
63 |
64 | export const keyPathColorsProperty = new Property({
65 | name: 'keyPathColors'
66 | });
67 | keyPathColorsProperty.register(LottieViewBase);
68 |
--------------------------------------------------------------------------------
/src/lottie/index.d.ts:
--------------------------------------------------------------------------------
1 | import { Color, View } from '@nativescript/core';
2 |
3 | export enum RenderMode {
4 | AUTOMATIC,
5 | HARDWARE,
6 | SOFTWARE
7 | }
8 |
9 | export interface KeyPathColors {
10 | [k: string]: Color | string;
11 | }
12 |
13 | export class LottieView extends View {
14 | /**
15 | * LottieAnimationView
16 | */
17 | readonly android: any;
18 |
19 | /**
20 | * AnimationView
21 | */
22 | readonly ios: any;
23 |
24 | constructor();
25 |
26 | /**
27 | * Flag determining whether the animation should start playing as soon as the view is ready.
28 | */
29 | autoPlay: boolean;
30 |
31 | /**
32 | * Block to be executed upon completion of the animation.
33 | * The animation is considered complete when it finishes playing and is no longer looping.
34 | */
35 | completionBlock: (animationFinished: boolean) => void;
36 |
37 | /**
38 | * (iOS only) The current UIViewContentMode.
39 | */
40 | contentMode: any;
41 |
42 | /**
43 | * The duration of the animation.
44 | */
45 | readonly duration: number | undefined;
46 |
47 | /**
48 | * Flag determining whether the animation should loop or not.
49 | */
50 | loop: boolean;
51 |
52 | /**
53 | * The current progress of the animation.
54 | */
55 | progress: number | undefined;
56 |
57 | /**
58 | * The current speed of the animation.
59 | */
60 | speed: number | undefined;
61 |
62 | /**
63 | * The current source of the animation.
64 | */
65 | src: string | undefined;
66 |
67 | /**
68 | * (Android) Cancels the animation.
69 | *
70 | * (iOS) Pauses the animation.
71 | */
72 | cancelAnimation(): void;
73 |
74 | /**
75 | * Returns true if the view is currently animating.
76 | */
77 | isAnimating(): boolean;
78 |
79 | /**
80 | * Sets the provided color value on each property that matches the specified keyPath.
81 | */
82 | setColor(value: Color, keyPath: string[]): void;
83 |
84 | /**
85 | * Sets the provided opacity value on each property that matches the specified keyPath.
86 | */
87 | setOpacity(value: number, keyPath: string[]): void;
88 |
89 | /**
90 | * Plays the animation from the beginning.
91 | */
92 | playAnimation(): void;
93 |
94 | /**
95 | * Plays the animation from the specified start and end progress values (between 0 and 1).
96 | */
97 | playAnimationFromProgressToProgress(startProgress: number, endProgress: number): void;
98 | }
99 |
--------------------------------------------------------------------------------
/src/lottie/index.ios.ts:
--------------------------------------------------------------------------------
1 | /**********************************************************************************
2 | * (c) 2017, Nathan Walker.
3 | * Licensed under the MIT license.
4 | *
5 | * Version 1.0.0 walkerrunpdx@gmail.com
6 | **********************************************************************************/
7 |
8 | import { Color, Utils, View, knownFolders, path } from '@nativescript/core';
9 | import { LottieViewBase, autoPlayProperty, keyPathColorsProperty, loopProperty, progressProperty, srcProperty, stretchProperty } from './index.common';
10 | import { clamp } from './utils';
11 |
12 | const appPath = knownFolders.currentApp().path;
13 |
14 | // this remove assert for lottie allowing sync .lottie files loading on main thread
15 | CompatibleLottieLogger.overrideLottieLogger();
16 |
17 | export class LottieView extends LottieViewBase {
18 | nativeViewProtected: CompatibleAnimationView;
19 | private _imageSourceAffectsLayout = true;
20 |
21 | public createNativeView() {
22 | return CompatibleAnimationView.new();
23 | }
24 |
25 | public initNativeView(): void {
26 | super.initNativeView();
27 | this.nativeViewProtected.translatesAutoresizingMaskIntoConstraints = true;
28 | }
29 |
30 | public onLoaded() {
31 | super.onLoaded();
32 | if (this.autoPlay && !this.isAnimating()) {
33 | this.playAnimation();
34 | }
35 | }
36 |
37 | [keyPathColorsProperty.setNative](value) {
38 | Object.keys(value).forEach((k) => this.setColor(value[k], k.split('|')));
39 | }
40 |
41 | [srcProperty.setNative](src: string) {
42 | if (!src) {
43 | this.nativeViewProtected.compatibleAnimation = null;
44 | } else if (src[0] === '{') {
45 | this.nativeViewProtected.compatibleAnimation = CompatibleAnimation.alloc().initWithJson(src);
46 | } else if (src.startsWith(Utils.RESOURCE_PREFIX)) {
47 | const resName = src.replace(Utils.RESOURCE_PREFIX, '');
48 |
49 | this.nativeViewProtected.compatibleAnimation = CompatibleAnimation.alloc().initWithNameBundle(resName.replace('.json', '').replace('.lottie', ''), NSBundle.mainBundle);
50 | } else {
51 | if (src[0] === '~') {
52 | src = `${path.join(appPath, src.substring(2))}`;
53 | }
54 | if (!/.(json|zip|lottie)$/.test(src)) {
55 | src += '.json';
56 | }
57 | if (!src.startsWith('file:/') && src[0] !== '/') {
58 | // seen as res
59 | this.nativeViewProtected.compatibleAnimation = CompatibleAnimation.alloc().initWithNameSubdirectoryBundle(src.replace('.json', '').replace('.lottie', ''), null, NSBundle.mainBundle);
60 | } else {
61 | this.nativeViewProtected.compatibleAnimation = CompatibleAnimation.alloc().initWithFilepath(src);
62 | }
63 | }
64 | if (this.keyPathColors) {
65 | this[keyPathColorsProperty.setNative](this.keyPathColors);
66 | }
67 | if (this._imageSourceAffectsLayout) {
68 | this.requestLayout();
69 | }
70 |
71 | if (this.autoPlay && !this.isAnimating()) {
72 | this.playAnimation();
73 | }
74 | }
75 |
76 | [loopProperty.setNative](loop: boolean) {
77 | this.nativeViewProtected.loopAnimationCount = loop ? -1 : 0;
78 | }
79 |
80 | [autoPlayProperty.setNative](autoPlay: boolean) {
81 | if (autoPlay) {
82 | if (!this.isAnimating()) {
83 | this.playAnimation();
84 | }
85 | } else {
86 | if (this.isAnimating()) {
87 | this.cancelAnimation();
88 | }
89 | }
90 | }
91 |
92 | public setColor(value: Color, keyPath: string[]): void {
93 | if (this.nativeView && value && keyPath && keyPath.length) {
94 | if (keyPath[keyPath.length - 1].toLowerCase() !== 'color') {
95 | keyPath = [...keyPath];
96 | keyPath.push('Color'); // ios expects the property as the last item in the keyPath
97 | }
98 |
99 | const color = value instanceof Color ? value : new Color(value);
100 | this.nativeViewProtected.setColorValueForKeypath(color.ios, CompatibleAnimationKeypath.alloc().initWithKeypath(keyPath.join('.')));
101 | }
102 | }
103 |
104 | public setOpacity(value: number, keyPath: string[]): void {
105 | if (this.nativeView && value && keyPath && keyPath.length) {
106 | if (keyPath[keyPath.length - 1].toLowerCase() !== 'opacity') {
107 | keyPath.push('Opacity'); // ios expects the property as the last item in the keyPath
108 | }
109 |
110 | this.nativeViewProtected.setFloatValueForKeypath(value, CompatibleAnimationKeypath.alloc().initWithKeypath(keyPath.join('.')));
111 | }
112 | // TODO: not working
113 | // if (this.nativeView && value && keyPath && keyPath.length) {
114 | // if (keyPath[keyPath.length - 1].toLowerCase() !== 'opacity') {
115 | // keyPath.push('Opacity'); // ios expects the property as the last item in the keyPath
116 | // }
117 | // value = clamp(value);
118 | // this.nativeViewProtected.getValue(
119 | // LOTNumberValueCallback.withFloatValue(value),
120 | // AnimationKeypath.keypathWithString(keyPath.join('.'))
121 | // );
122 | // }
123 | }
124 |
125 | public playAnimation(): void {
126 | setTimeout(() => {
127 | if (this.nativeViewProtected) {
128 | if (this.completionBlock) {
129 | this.nativeViewProtected.playWithCompletion((animationFinished: boolean) => {
130 | if (this.completionBlock) {
131 | this.completionBlock(animationFinished);
132 | }
133 | });
134 | } else {
135 | this.nativeViewProtected.play();
136 | }
137 | }
138 | }, 0);
139 | }
140 |
141 | public playAnimationFromProgressToProgress(startProgress: number, endProgress: number): void {
142 | if (this.nativeViewProtected) {
143 | startProgress = startProgress ? clamp(startProgress) : 0;
144 | endProgress = endProgress ? clamp(endProgress) : 1;
145 | if (this.completionBlock) {
146 | this.nativeViewProtected.playFromProgressToProgressCompletion(startProgress, endProgress, this.completionBlock);
147 | } else {
148 | this.nativeViewProtected.playFromProgressToProgressCompletion(startProgress, endProgress, null);
149 | }
150 | }
151 | }
152 |
153 | public cancelAnimation(): void {
154 | if (this.nativeViewProtected) {
155 | this.nativeViewProtected.pause();
156 | }
157 | }
158 |
159 | public isAnimating(): boolean {
160 | return this.nativeView ? this.nativeViewProtected.isAnimationPlaying : false;
161 | }
162 |
163 | [progressProperty.setNative](value: number) {
164 | this.nativeViewProtected.currentProgress = value;
165 | }
166 |
167 | public set speed(value: number) {
168 | if (this.nativeView && value) {
169 | this.nativeViewProtected.animationSpeed = value;
170 | }
171 | }
172 |
173 | public get speed(): number | undefined {
174 | return this.nativeView ? this.nativeViewProtected.animationSpeed : undefined;
175 | }
176 |
177 | public get duration(): number | undefined {
178 | return this.nativeView && this.nativeViewProtected.animationDuration;
179 | }
180 |
181 | public set contentMode(mode: any) {
182 | // this._contentMode = mode;
183 | if (this.nativeViewProtected) {
184 | this.nativeViewProtected.contentMode = mode;
185 | }
186 | }
187 |
188 | public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
189 | const intrinsicContentSize = this.nativeViewProtected.intrinsicContentSize;
190 | // We don't call super because we measure native view with specific size.
191 | const width = Utils.layout.getMeasureSpecSize(widthMeasureSpec);
192 | const widthMode = Utils.layout.getMeasureSpecMode(widthMeasureSpec);
193 |
194 | const height = Utils.layout.getMeasureSpecSize(heightMeasureSpec);
195 | const heightMode = Utils.layout.getMeasureSpecMode(heightMeasureSpec);
196 |
197 | const nativeWidth = intrinsicContentSize ? Utils.layout.toDevicePixels(intrinsicContentSize.width) : 0;
198 | const nativeHeight = intrinsicContentSize ? Utils.layout.toDevicePixels(intrinsicContentSize.height) : 0;
199 |
200 | let measureWidth = Math.max(nativeWidth, this.effectiveMinWidth);
201 | let measureHeight = Math.max(nativeHeight, this.effectiveMinHeight);
202 |
203 | const finiteWidth: boolean = widthMode !== Utils.layout.UNSPECIFIED;
204 | const finiteHeight: boolean = heightMode !== Utils.layout.UNSPECIFIED;
205 |
206 | this._imageSourceAffectsLayout = widthMode !== Utils.layout.EXACTLY || heightMode !== Utils.layout.EXACTLY;
207 |
208 | if (nativeWidth !== 0 && nativeHeight !== 0 && (finiteWidth || finiteHeight)) {
209 | const scale = LottieView.computeScaleFactor(width, height, finiteWidth, finiteHeight, nativeWidth, nativeHeight, this.stretch);
210 | const resultW = Math.round(nativeWidth * scale.width);
211 | const resultH = Math.round(nativeHeight * scale.height);
212 |
213 | measureWidth = finiteWidth ? Math.min(resultW, width) : resultW;
214 | measureHeight = finiteHeight ? Math.min(resultH, height) : resultH;
215 | }
216 |
217 | const widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
218 | const heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
219 |
220 | this.setMeasuredDimension(widthAndState, heightAndState);
221 | }
222 |
223 | private static computeScaleFactor(
224 | measureWidth: number,
225 | measureHeight: number,
226 | widthIsFinite: boolean,
227 | heightIsFinite: boolean,
228 | nativeWidth: number,
229 | nativeHeight: number,
230 | imageStretch: string
231 | ): { width: number; height: number } {
232 | let scaleW = 1;
233 | let scaleH = 1;
234 |
235 | if ((imageStretch === 'aspectFill' || imageStretch === 'aspectFit' || imageStretch === 'fill') && (widthIsFinite || heightIsFinite)) {
236 | scaleW = nativeWidth > 0 ? measureWidth / nativeWidth : 0;
237 | scaleH = nativeHeight > 0 ? measureHeight / nativeHeight : 0;
238 |
239 | if (!widthIsFinite) {
240 | scaleW = scaleH;
241 | } else if (!heightIsFinite) {
242 | scaleH = scaleW;
243 | } else {
244 | // No infinite dimensions.
245 | switch (imageStretch) {
246 | case 'aspectFit':
247 | scaleH = scaleW < scaleH ? scaleW : scaleH;
248 | scaleW = scaleH;
249 | break;
250 | case 'aspectFill':
251 | scaleH = scaleW > scaleH ? scaleW : scaleH;
252 | scaleW = scaleH;
253 | break;
254 | }
255 | }
256 | }
257 |
258 | return { width: scaleW, height: scaleH };
259 | }
260 |
261 | [stretchProperty.setNative](value: 'none' | 'aspectFill' | 'aspectFit' | 'fill') {
262 | switch (value) {
263 | case 'aspectFit':
264 | this.nativeViewProtected.contentMode = UIViewContentMode.ScaleAspectFit;
265 | break;
266 |
267 | case 'aspectFill':
268 | this.nativeViewProtected.contentMode = UIViewContentMode.ScaleAspectFill;
269 | break;
270 |
271 | case 'fill':
272 | this.nativeViewProtected.contentMode = UIViewContentMode.ScaleToFill;
273 | break;
274 |
275 | case 'none':
276 | default:
277 | this.nativeViewProtected.contentMode = UIViewContentMode.TopLeft;
278 | break;
279 | }
280 | }
281 | }
282 |
--------------------------------------------------------------------------------
/src/lottie/typings/android.nativescript.d.ts:
--------------------------------------------------------------------------------
1 |
2 | declare module com {
3 | export module nativescript {
4 | export module lottie {
5 | export class LottieAnimationView extends com.airbnb.lottie.LottieAnimationView {
6 | public static class: java.lang.Class;
7 | public constructor(param0: globalAndroid.content.Context);
8 | public onMeasure(param0: number, param1: number): void;
9 | }
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/src/lottie/typings/dotlottie.ios.d.ts:
--------------------------------------------------------------------------------
1 |
2 | declare class DotLottie extends NSObject {
3 |
4 | static alloc(): DotLottie; // inherited from NSObject
5 |
6 | static new(): DotLottie; // inherited from NSObject
7 |
8 | static objcLoadWithNameShouldCacheCompletion(name: string, shouldCache: boolean, completion: (p1: Animation) => void): void;
9 | static objcLoadFromShouldCacheCompletion(url: NSURL, shouldCache: boolean, completion: (p1: Animation) => void): void;
10 | }
11 |
12 | declare let dotLottieVersionNumber: number;
13 |
14 | declare let dotLottieVersionString: interop.Reference;
15 |
--------------------------------------------------------------------------------
/src/lottie/typings/ios.d.ts:
--------------------------------------------------------------------------------
1 | /* eslint-disable @typescript-eslint/unified-signatures */
2 | declare class AnimatedButton extends AnimatedControl {
3 | static alloc(): AnimatedButton; // inherited from NSObject
4 |
5 | static appearance(): AnimatedButton; // inherited from UIAppearance
6 |
7 | static appearanceForTraitCollection(trait: UITraitCollection): AnimatedButton; // inherited from UIAppearance
8 |
9 | static appearanceForTraitCollectionWhenContainedIn(trait: UITraitCollection, ContainerClass: typeof NSObject): AnimatedButton; // inherited from UIAppearance
10 |
11 | static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(
12 | trait: UITraitCollection,
13 | containerTypes: NSArray | typeof NSObject[]
14 | ): AnimatedButton; // inherited from UIAppearance
15 |
16 | static appearanceWhenContainedIn(ContainerClass: typeof NSObject): AnimatedButton; // inherited from UIAppearance
17 |
18 | static appearanceWhenContainedInInstancesOfClasses(
19 | containerTypes: NSArray | typeof NSObject[]
20 | ): AnimatedButton; // inherited from UIAppearance
21 |
22 | static new(): AnimatedButton; // inherited from NSObject
23 | }
24 |
25 | declare class AnimatedControl extends UIControl {
26 | static alloc(): AnimatedControl; // inherited from NSObject
27 |
28 | static appearance(): AnimatedControl; // inherited from UIAppearance
29 |
30 | static appearanceForTraitCollection(trait: UITraitCollection): AnimatedControl; // inherited from UIAppearance
31 |
32 | static appearanceForTraitCollectionWhenContainedIn(
33 | trait: UITraitCollection,
34 | ContainerClass: typeof NSObject
35 | ): AnimatedControl; // inherited from UIAppearance
36 |
37 | static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(
38 | trait: UITraitCollection,
39 | containerTypes: NSArray | typeof NSObject[]
40 | ): AnimatedControl; // inherited from UIAppearance
41 |
42 | static appearanceWhenContainedIn(ContainerClass: typeof NSObject): AnimatedControl; // inherited from UIAppearance
43 |
44 | static appearanceWhenContainedInInstancesOfClasses(
45 | containerTypes: NSArray | typeof NSObject[]
46 | ): AnimatedControl; // inherited from UIAppearance
47 |
48 | static new(): AnimatedControl; // inherited from NSObject
49 | }
50 |
51 | declare class AnimatedSwitch extends AnimatedControl {
52 | static alloc(): AnimatedSwitch; // inherited from NSObject
53 |
54 | static appearance(): AnimatedSwitch; // inherited from UIAppearance
55 |
56 | static appearanceForTraitCollection(trait: UITraitCollection): AnimatedSwitch; // inherited from UIAppearance
57 |
58 | static appearanceForTraitCollectionWhenContainedIn(trait: UITraitCollection, ContainerClass: typeof NSObject): AnimatedSwitch; // inherited from UIAppearance
59 |
60 | static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(
61 | trait: UITraitCollection,
62 | containerTypes: NSArray | typeof NSObject[]
63 | ): AnimatedSwitch; // inherited from UIAppearance
64 |
65 | static appearanceWhenContainedIn(ContainerClass: typeof NSObject): AnimatedSwitch; // inherited from UIAppearance
66 |
67 | static appearanceWhenContainedInInstancesOfClasses(
68 | containerTypes: NSArray | typeof NSObject[]
69 | ): AnimatedSwitch; // inherited from UIAppearance
70 |
71 | static new(): AnimatedSwitch; // inherited from NSObject
72 | }
73 |
74 | declare class AnimationSubview extends UIView {
75 | static alloc(): AnimationSubview; // inherited from NSObject
76 |
77 | static appearance(): AnimationSubview; // inherited from UIAppearance
78 |
79 | static appearanceForTraitCollection(trait: UITraitCollection): AnimationSubview; // inherited from UIAppearance
80 |
81 | static appearanceForTraitCollectionWhenContainedIn(
82 | trait: UITraitCollection,
83 | ContainerClass: typeof NSObject
84 | ): AnimationSubview; // inherited from UIAppearance
85 |
86 | static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(
87 | trait: UITraitCollection,
88 | containerTypes: NSArray | typeof NSObject[]
89 | ): AnimationSubview; // inherited from UIAppearance
90 |
91 | static appearanceWhenContainedIn(ContainerClass: typeof NSObject): AnimationSubview; // inherited from UIAppearance
92 |
93 | static appearanceWhenContainedInInstancesOfClasses(
94 | containerTypes: NSArray | typeof NSObject[]
95 | ): AnimationSubview; // inherited from UIAppearance
96 |
97 | static new(): AnimationSubview; // inherited from NSObject
98 | }
99 |
100 | declare class CompatibleAnimation extends NSObject {
101 | static alloc(): CompatibleAnimation; // inherited from NSObject
102 |
103 | static new(): CompatibleAnimation; // inherited from NSObject
104 |
105 | constructor(o: { filepath: string });
106 |
107 | constructor(o: { json: string });
108 |
109 | constructor(o: { name: string; bundle: NSBundle });
110 |
111 | constructor(o: { name: string; subdirectory: string; bundle: NSBundle });
112 |
113 | initWithFilepath(filepath: string): this;
114 |
115 | initWithJson(json: string): this;
116 |
117 | initWithNameBundle(name: string, bundle: NSBundle): this;
118 |
119 | initWithNameSubdirectoryBundle(name: string, subdirectory: string, bundle: NSBundle): this;
120 | }
121 |
122 | declare class CompatibleAnimationKeypath extends NSObject {
123 | static alloc(): CompatibleAnimationKeypath; // inherited from NSObject
124 |
125 | static new(): CompatibleAnimationKeypath; // inherited from NSObject
126 |
127 | constructor(o: { keypath: string });
128 |
129 | constructor(o: { keys: NSArray | string[] });
130 |
131 | initWithKeypath(keypath: string): this;
132 |
133 | initWithKeys(keys: NSArray | string[]): this;
134 | }
135 |
136 | declare class CompatibleAnimationView extends UIView {
137 | static alloc(): CompatibleAnimationView; // inherited from NSObject
138 |
139 | static appearance(): CompatibleAnimationView; // inherited from UIAppearance
140 |
141 | static appearanceForTraitCollection(trait: UITraitCollection): CompatibleAnimationView; // inherited from UIAppearance
142 |
143 | static appearanceForTraitCollectionWhenContainedIn(
144 | trait: UITraitCollection,
145 | ContainerClass: typeof NSObject
146 | ): CompatibleAnimationView; // inherited from UIAppearance
147 |
148 | static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(
149 | trait: UITraitCollection,
150 | containerTypes: NSArray | typeof NSObject[]
151 | ): CompatibleAnimationView; // inherited from UIAppearance
152 |
153 | static appearanceWhenContainedIn(ContainerClass: typeof NSObject): CompatibleAnimationView; // inherited from UIAppearance
154 |
155 | static appearanceWhenContainedInInstancesOfClasses(
156 | containerTypes: NSArray | typeof NSObject[]
157 | ): CompatibleAnimationView; // inherited from UIAppearance
158 |
159 | static new(): CompatibleAnimationView; // inherited from NSObject
160 |
161 | animation: LottieAnimation;
162 |
163 | readonly animationDuration: number;
164 |
165 | animationSpeed: number;
166 |
167 | backgroundMode: CompatibleBackgroundBehavior;
168 |
169 | compatibleAnimation: CompatibleAnimation;
170 |
171 | compatibleDictionaryTextProvider: CompatibleDictionaryTextProvider;
172 |
173 | currentFrame: number;
174 |
175 | currentProgress: number;
176 |
177 | currentTime: number;
178 |
179 | readonly duration: number;
180 |
181 | readonly isAnimationPlaying: boolean;
182 |
183 | loopAnimationCount: number;
184 |
185 | readonly realtimeAnimationFrame: number;
186 |
187 | readonly realtimeAnimationProgress: number;
188 |
189 | respectAnimationFrameRate: boolean;
190 |
191 | shouldRasterizeWhenIdle: boolean;
192 |
193 | constructor(o: { compatibleAnimation: CompatibleAnimation });
194 |
195 | constructor(o: {
196 | compatibleAnimation: CompatibleAnimation;
197 | compatibleRenderingEngineOption: CompatibleRenderingEngineOption;
198 | });
199 |
200 | constructor(o: { data: NSData });
201 |
202 | constructor(o: { data: NSData; compatibleRenderingEngineOption: CompatibleRenderingEngineOption });
203 |
204 | constructor(o: { url: NSURL });
205 |
206 | constructor(o: { url: NSURL; compatibleRenderingEngineOption: CompatibleRenderingEngineOption });
207 |
208 | addSubviewForLayerAt(subview: AnimationSubview, keypath: CompatibleAnimationKeypath): void;
209 |
210 | convertWithPointToLayerAt(point: CGPoint, keypath: CompatibleAnimationKeypath): CGPoint;
211 |
212 | convertWithRectToLayerAt(rect: CGRect, keypath: CompatibleAnimationKeypath): CGRect;
213 |
214 | durationFrameTimeForMarker(named: string): number;
215 |
216 | forceDisplayUpdate(): void;
217 |
218 | frameTimeForMarker(named: string): number;
219 |
220 | getColorValueForAtFrame(keypath: CompatibleAnimationKeypath, atFrame: number): UIColor;
221 |
222 | getFloatValueForAtFrame(keypath: CompatibleAnimationKeypath, atFrame: number): number;
223 |
224 | getValueForAtFrame(keypath: CompatibleAnimationKeypath, atFrame: number): any;
225 |
226 | initWithCompatibleAnimation(compatibleAnimation: CompatibleAnimation): this;
227 |
228 | initWithCompatibleAnimationCompatibleRenderingEngineOption(
229 | compatibleAnimation: CompatibleAnimation,
230 | compatibleRenderingEngineOption: CompatibleRenderingEngineOption
231 | ): this;
232 |
233 | initWithData(data: NSData): this;
234 |
235 | initWithDataCompatibleRenderingEngineOption(
236 | data: NSData,
237 | compatibleRenderingEngineOption: CompatibleRenderingEngineOption
238 | ): this;
239 |
240 | initWithUrl(url: NSURL): this;
241 |
242 | initWithUrlCompatibleRenderingEngineOption(
243 | url: NSURL,
244 | compatibleRenderingEngineOption: CompatibleRenderingEngineOption
245 | ): this;
246 |
247 | logHierarchyKeypaths(): void;
248 |
249 | pause(): void;
250 |
251 | play(): void;
252 |
253 | playFromFrameToFrameCompletion(fromFrame: number, toFrame: number, completion: (p1: boolean) => void): void;
254 |
255 | playFromMarkerToMarkerCompletion(fromMarker: string, toMarker: string, completion: (p1: boolean) => void): void;
256 |
257 | playFromProgressToProgressCompletion(fromProgress: number, toProgress: number, completion: (p1: boolean) => void): void;
258 |
259 | playWithCompletion(completion: (p1: boolean) => void): void;
260 |
261 | playWithMarkerCompletion(marker: string, completion: (p1: boolean) => void): void;
262 |
263 | progressTimeForMarker(named: string): number;
264 |
265 | reloadImages(): void;
266 |
267 | setColorValueForKeypath(color: UIColor, keypath: CompatibleAnimationKeypath): void;
268 |
269 | setFloatValueForKeypath(value: number, keypath: CompatibleAnimationKeypath): void;
270 |
271 | stop(): void;
272 | }
273 |
274 | declare const enum CompatibleBackgroundBehavior {
275 | Stop = 0,
276 |
277 | Pause = 1,
278 |
279 | PauseAndRestore = 2,
280 |
281 | ForceFinish = 3,
282 |
283 | ContinuePlaying = 4
284 | }
285 |
286 | declare class CompatibleDictionaryTextProvider extends NSObject {
287 | static alloc(): CompatibleDictionaryTextProvider; // inherited from NSObject
288 |
289 | static new(): CompatibleDictionaryTextProvider; // inherited from NSObject
290 |
291 | constructor(o: { values: NSDictionary });
292 |
293 | initWithValues(values: NSDictionary): this;
294 | }
295 |
296 | declare class CompatibleLottieLogger extends NSObject {
297 | static alloc(): CompatibleLottieLogger; // inherited from NSObject
298 |
299 | static new(): CompatibleLottieLogger; // inherited from NSObject
300 |
301 | static overrideLottieLogger(): void;
302 | }
303 |
304 | declare const enum CompatibleRenderingEngineOption {
305 | Shared = 0,
306 |
307 | DefaultEngine = 1,
308 |
309 | Automatic = 2,
310 |
311 | MainThread = 3,
312 |
313 | CoreAnimation = 4
314 | }
315 |
316 | declare class LottieAnimation extends NSObject {
317 | static alloc(): LottieAnimation; // inherited from NSObject
318 |
319 | static new(): LottieAnimation; // inherited from NSObject
320 | }
321 |
322 | declare class LottieAnimationLayer extends CALayer {
323 | static alloc(): LottieAnimationLayer; // inherited from NSObject
324 |
325 | static layer(): LottieAnimationLayer; // inherited from CALayer
326 |
327 | static new(): LottieAnimationLayer; // inherited from NSObject
328 | }
329 |
330 | declare class LottieAnimationView extends LottieAnimationViewBase {
331 | static alloc(): LottieAnimationView; // inherited from NSObject
332 |
333 | static appearance(): LottieAnimationView; // inherited from UIAppearance
334 |
335 | static appearanceForTraitCollection(trait: UITraitCollection): LottieAnimationView; // inherited from UIAppearance
336 |
337 | static appearanceForTraitCollectionWhenContainedIn(
338 | trait: UITraitCollection,
339 | ContainerClass: typeof NSObject
340 | ): LottieAnimationView; // inherited from UIAppearance
341 |
342 | static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(
343 | trait: UITraitCollection,
344 | containerTypes: NSArray | typeof NSObject[]
345 | ): LottieAnimationView; // inherited from UIAppearance
346 |
347 | static appearanceWhenContainedIn(ContainerClass: typeof NSObject): LottieAnimationView; // inherited from UIAppearance
348 |
349 | static appearanceWhenContainedInInstancesOfClasses(
350 | containerTypes: NSArray | typeof NSObject[]
351 | ): LottieAnimationView; // inherited from UIAppearance
352 |
353 | static new(): LottieAnimationView; // inherited from NSObject
354 | }
355 |
356 | declare class LottieAnimationViewBase extends UIView {
357 | static alloc(): LottieAnimationViewBase; // inherited from NSObject
358 |
359 | static appearance(): LottieAnimationViewBase; // inherited from UIAppearance
360 |
361 | static appearanceForTraitCollection(trait: UITraitCollection): LottieAnimationViewBase; // inherited from UIAppearance
362 |
363 | static appearanceForTraitCollectionWhenContainedIn(
364 | trait: UITraitCollection,
365 | ContainerClass: typeof NSObject
366 | ): LottieAnimationViewBase; // inherited from UIAppearance
367 |
368 | static appearanceForTraitCollectionWhenContainedInInstancesOfClasses(
369 | trait: UITraitCollection,
370 | containerTypes: NSArray | typeof NSObject[]
371 | ): LottieAnimationViewBase; // inherited from UIAppearance
372 |
373 | static appearanceWhenContainedIn(ContainerClass: typeof NSObject): LottieAnimationViewBase; // inherited from UIAppearance
374 |
375 | static appearanceWhenContainedInInstancesOfClasses(
376 | containerTypes: NSArray | typeof NSObject[]
377 | ): LottieAnimationViewBase; // inherited from UIAppearance
378 |
379 | static new(): LottieAnimationViewBase; // inherited from NSObject
380 | }
381 |
382 | declare let LottieVersionNumber: number;
383 |
384 | declare let LottieVersionString: interop.Reference;
385 |
--------------------------------------------------------------------------------
/src/lottie/utils.ts:
--------------------------------------------------------------------------------
1 | export function clamp(val: number, min: number = 0, max: number = 1) {
2 | return val > max ? max : val < min ? min : val;
3 | }
4 |
--------------------------------------------------------------------------------
/src/lottie/vue/index.ts:
--------------------------------------------------------------------------------
1 | import { LottieView } from '..';
2 | let installed = false;
3 | export default {
4 | install(Vue) {
5 | if (!installed) {
6 | installed = true;
7 | Vue.registerElement('LottieView', () => LottieView, {});
8 | }
9 | }
10 | };
11 |
--------------------------------------------------------------------------------
/svelte.config.js:
--------------------------------------------------------------------------------
1 | const sveltePreprocess = require('svelte-preprocess');
2 | // const svelteNativePreprocessor = require('svelte-native-preprocessor');
3 |
4 | module.exports = {
5 | compilerOptions: {
6 | namespace: 'foreign'
7 | },
8 | preprocess: [
9 | sveltePreprocess({
10 | typescript: {
11 | compilerOptions: {
12 | target: 'es2020'
13 | }
14 | }
15 | })
16 | // svelteNativePreprocessor()
17 | ]
18 | };
19 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tools/tsconfig",
3 | "compilerOptions": {
4 | "paths": {
5 | "@nativescript-community/ui-lottie": ["src/lottie/index"],
6 | "@nativescript-community/ui-lottie/*": ["src/lottie/*"]
7 | }
8 | },
9 | "references": [
10 | {
11 | //Need for IDE
12 | "path": "./tsconfig.vue3.json"
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/tsconfig.vue3.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "composite": true,
5 | "paths": {
6 | "nativescript-vue": ["./node_modules/nativescript-vue3"]
7 | }
8 | },
9 | "include": [
10 | "./demo-snippets/vue3"
11 | ]
12 | }
--------------------------------------------------------------------------------