mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 19:57:22 +08:00
70 lines
1.4 KiB
TypeScript
70 lines
1.4 KiB
TypeScript
import {Directive, ElementRef} from 'angular2/angular2';
|
|
import {FormBuilder, Validators, ControlGroup} from 'angular2/forms';
|
|
|
|
import {App, NavController, IonicView} from 'ionic/ionic';
|
|
|
|
|
|
@IonicView({
|
|
templateUrl: 'pages/app.html'
|
|
})
|
|
class AppPage {
|
|
constructor(nav: NavController) {
|
|
this.nav = nav;
|
|
}
|
|
doLogin() {
|
|
}
|
|
}
|
|
|
|
@Directive({
|
|
selector: '[parallax]',
|
|
properties: [
|
|
'parallax'
|
|
]
|
|
})
|
|
export class ParallaxEffect {
|
|
constructor(
|
|
elementRef: ElementRef
|
|
) {
|
|
this.ele = elementRef.nativeElement;
|
|
|
|
setTimeout(() => {
|
|
Object.observe(this, (changes) => {
|
|
changes.forEach((change) => {
|
|
if(change.name == 'parallax') {
|
|
this.parallaxItems();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
parallaxItems() {
|
|
let list = this.ele;
|
|
console.log('Moving items', this.parallax);
|
|
var x = Math.max(0, (1 - this.parallax) * 20);
|
|
var y = 0;//Math.max(0, (1 - this.parallax) * 10);
|
|
var scale = Math.min(1, (0.9 + 0.1 * this.parallax));
|
|
list.style['opacity'] = Math.min(this.parallax, 1);
|
|
list.style['transform'] = 'translate3d(' + x + 'px, ' + y + 'px, 0) scale(' + scale + ')';
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Main app entry point
|
|
*/
|
|
@App({
|
|
directives: [ParallaxEffect],
|
|
templateUrl: 'main.html'
|
|
})
|
|
class IonicApp {
|
|
constructor() {
|
|
this.rootView = AppPage
|
|
|
|
this.menuOpenAmount = 0;
|
|
}
|
|
|
|
onMenuOpening(amt) {
|
|
this.menuOpenAmount = amt;
|
|
}
|
|
}
|