nativeScript-periscopehearts
Periscope 心形动画的 NativeScript 插件。 (仅适用于 Android)
npm i --save nativescript-periscopehearts

npm npm

NativeScript-PeriscopeHearts :two_hearts

NativeScript 插件用于 Periscope 的心形动画(目前仅适用于 Android)。使用的开源库: tyrantgit/HeartLayout

示例

Sample Hearts

安装

从您的命令提示符/终端进入您的应用程序的根目录并执行

npm install nativescript-periscopehearts

用法

XML

<Page class="coverImage" xmlns="http://schemas.nativescript.org/tns.xsd"
xmlns:PeriscopeHearts="nativescript-periscopehearts" loaded="pageLoaded">
<Page.actionBar>
<ActionBar title="NativeScript-PeriscopeHearts" color="#fff" backgroundColor="#03A9F4" />
</Page.actionBar>
<ScrollView>
<StackLayout>
<button text="Add Heart" tap="newHeart" />

<!-- This is our Heart "container" -->
<PeriscopeHearts:PeriscopeHearts class="heartLayout" id="heartLayout" height="400" />

</StackLayout>
</ScrollView>
</Page>

JS

// Array of hex color strings
var colorArray = [
{ hex: "#3489db" },
{ hex: '#FF4081' },
{ hex: '#229911' },
{ hex: '#fff000' }
];

function newHeart(args) {
var heartLayout = frame.topmost().currentPage.getViewById("heartLayout");

// Just getting a random hex string from the colorArray values
var rand = colorArray[Math.floor(Math.random() * colorArray.length)];

// Call addHeart() on the PeriscopeHearts UI element to pop in a new heart
heartLayout.addHeart(rand.hex);
}
exports.newHeart = newHeart;

API

addHeart (color) - 必需

添加一个心形到视图中的函数。