nativescript-keyframes
Version:
Easily use the Facebook Keyframes library in your NativeScript app.
52 lines • 1.92 kB
JavaScript
;
var image_1 = require("ui/image");
var fs = require("file-system");
var appPath = fs.knownFolders.currentApp().path;
var KeyframesView = (function (_super) {
__extends(KeyframesView, _super);
function KeyframesView() {
_super.call(this);
}
KeyframesView.prototype.onLoaded = function () {
var src = appPath + (this._source.indexOf("/") === 0 ? "" : "/") + this._source;
if (!fs.File.exists(src)) {
console.log("Keyframe source not found at " + src + "; showing an empty image");
return;
}
var data = NSData.dataWithContentsOfFile(src);
var vectorDictionary = NSJSONSerialization.JSONObjectWithDataOptionsError(data, kNilOptions, null);
var kfVector = KFVectorFromDictionary(vectorDictionary);
var kfVectorLayer = KFVectorLayer.layer();
kfVectorLayer.frame = CGRectMake(0, 0, this._ios.layer.frame.size.width, this._ios.layer.frame.size.height);
kfVectorLayer.faceModel = kfVector;
this.ios.layer.addSublayer(kfVectorLayer);
kfVectorLayer.startAnimation();
};
Object.defineProperty(KeyframesView.prototype, "ios", {
get: function () {
return this._ios;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KeyframesView.prototype, "_nativeView", {
get: function () {
if (!this._ios) {
this._ios = KFVectorLayer.layer();
}
return this._ios;
},
enumerable: true,
configurable: true
});
Object.defineProperty(KeyframesView.prototype, "source", {
set: function (value) {
this._source = value;
},
enumerable: true,
configurable: true
});
return KeyframesView;
}(image_1.Image));
exports.KeyframesView = KeyframesView;
//# sourceMappingURL=keyframes.ios.js.map