Skip to content

Instantly share code, notes, and snippets.

@vakrilov
Created July 13, 2016 15:18
Show Gist options
  • Save vakrilov/dd8698443167c3e90cd379faf38e3fc2 to your computer and use it in GitHub Desktop.
Save vakrilov/dd8698443167c3e90cd379faf38e3fc2 to your computer and use it in GitHub Desktop.
NG.org snippets - Typescript
@keyframes fly {
0% { transform: translate(0, 0), rotate(0); }
15% { transform: translate(60, 0), rotate(10); }
35% { transform: translate(-300, 0), rotate(50); }
36% { transform: translate(-300, -60), rotate(-30), scale(-0.7, 0.7); }
60% { transform: translate(300, -60), rotate(-30), scale(-0.7, 0.7); }
61% { transform: translate(300, 0), rotate(50), scale(1,1); }
100% { transform: translate(0, 0), rotate(0); }
}
@keyframes show {
from {opacity: 0;}
to {opacity: 1;}
}
.go-fly {
animation-name: fly;
animation-duration: 3s;
}
.show {
animation-name: show;
animation-duration: 1s;
animation-delay: 3s;
}
label {
opacity: 0;
vertical-align: center;
text-align: center;
color: #3C5AFD;
font-size: 24;
margin-bottom: 160;
}
const messages = [
"Hi there",
"Wazzup",
"Ready to start?",
"Show me the code"
];
let msg: Label;
let alien: View;
export function navigatingTo(args: EventData) {
const page = <Page>args.object;
msg = <Label>page.getViewById("message");
alien = page.getViewById("alien");
}
export function onTap(args: EventData) {
alien.className = "";
msg.className = "";
msg.text = messages[Math.floor(Math.random() * messages.length)];
alien.className = "go-fly";
msg.className = "show";
}
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" actionBarHidden="true">
<GridLayout>
<Label id="message" text="Tap me" class="show"/>
<Image src="res://alien" id="alien" tap="onTap" height="80"/>
</GridLayout>
</Page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment