m1ga / ti.animation

Airbnb Lottie + Rive animation module for Titanium SDK
Other
106 stars 20 forks source link

Allow to pass JSON instead of path #31

Open m1ga opened 7 years ago

m1ga commented 7 years ago

Add the option to pass a JSON as parameter

m1ga commented 7 years ago

Test: https://github.com/m1ga/ti.animation/releases/tag/1.3.0.beta

var testanimation = TiAnimation.createLottieView({
    loop: true,
    json: '{"v":"4.5.9","fr":29.9700012207031,"ip":0,"op":105.000004276738,"w":800,"h":600,"ddd":0,"assets":[],"layers":[{"ddd":0,"ind":0,"ty":4,"nm":"Icon","ks":{"o":{"a":0,"k":100},"r":{"a":0,"k":0},"p":{"a":0,"k":[519.707,417.846,0]},"a":{"a":0,"k":[0,0,0]},"s":{"a":0,"k":[100,100,100]}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[68,8]},"p":{"a":0,"k":[0,-15]},"r":{"a":0,"k":0},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect"},{"ty":"fl","c":{"a":0,"k":[0.108,0.108,0.108,1]},"o":{"a":0,"k":100},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"a":0,"k":[-119.707,-117.727],"ix":2},"a":{"a":0,"k":[0,-14.881],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":24,"s":[100],"e":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":25,"s":[0],"e":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":80,"s":[0],"e":[100]},{"t":81.0000032991976}],"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 3","np":3,"mn":"ADBE Vector Group"},{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[68,8]},"p":{"a":1,"k":[{"i":{"x":0,"y":1},"o":{"x":0.167,"y":0.167},"n":"0_1_0p167_0p167","t":15,"s":[0,10],"e":[0,-15],"to":[0,-4.16666650772095],"ti":[0,4.16666650772095]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":25,"s":[0,-15],"e":[0,-15],"to":[0,0],"ti":[0,0]},{"i":{"x":0,"y":1},"o":{"x":0.167,"y":0.167},"n":"0_1_0p167_0p167","t":80,"s":[0,-15],"e":[0,10],"to":[0,4.16666650772095],"ti":[0,-4.16666650772095]},{"t":90.0000036657751}]},"r":{"a":0,"k":0},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect"},{"ty":"fl","c":{"a":0,"k":[0.106,0.106,0.106,1]},"o":{"a":0,"k":100},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"a":0,"k":[-119.707,-117.727],"ix":2},"a":{"a":0,"k":[0,-14.881],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"n":["0_1_0p167_0p167"],"t":24,"s":[0],"e":[45]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":34,"s":[45],"e":[45]},{"i":{"x":[0],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"n":["0_1_0p167_0p167"],"t":73,"s":[45],"e":[0]},{"t":81.0000032991976}],"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 2","np":3,"mn":"ADBE Vector Group"},{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[68,8]},"p":{"a":1,"k":[{"i":{"x":0,"y":1},"o":{"x":0.167,"y":0.167},"n":"0_1_0p167_0p167","t":15,"s":[0,-10],"e":[0,15],"to":[0,4.16666650772095],"ti":[0,-4.16666650772095]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"n":"0p833_0p833_0p167_0p167","t":25,"s":[0,15],"e":[0,15],"to":[0,0],"ti":[0,0]},{"i":{"x":0,"y":1},"o":{"x":0.167,"y":0.167},"n":"0_1_0p167_0p167","t":80,"s":[0,15],"e":[0,-10],"to":[0,-4.16666650772095],"ti":[0,4.16666650772095]},{"t":90.0000036657751}]},"r":{"a":0,"k":0},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect"},{"ty":"fl","c":{"a":0,"k":[0.105,0.105,0.105,1]},"o":{"a":0,"k":100},"r":1,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill"},{"ty":"tr","p":{"a":0,"k":[-119.707,-117.724],"ix":2},"a":{"a":0,"k":[0,15.122],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":1,"k":[{"i":{"x":[0],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"n":["0_1_0p167_0p167"],"t":24,"s":[0],"e":[-45]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"n":["0p833_0p833_0p167_0p167"],"t":34,"s":[-45],"e":[-45]},{"i":{"x":[0],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"n":["0_1_0p167_0p167"],"t":73,"s":[-45],"e":[0]},{"t":81.0000032991976}],"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":3,"mn":"ADBE Vector Group"}],"ip":0,"op":300.00001221925,"st":0,"bm":0,"sr":1}]}',
    autoStart: true,
    top: 250,
    height: 50,
    width: 50
});
Topener commented 7 years ago

Nice! IS this for both platforms?

m1ga commented 7 years ago

Not yet, but it will/should be :)

hansemannn commented 7 years ago

@m1ga Will add it, maybe later this weekend. Shouldn't be a big change, so everyone please feel free to go ahead!

jerry42 commented 5 years ago

Hi guys ! Is there any update about this ?