Merge branch 'master' into develop/sidebar

This commit is contained in:
nixa 2016-04-28 18:00:47 +03:00
commit 5817744a37
4 changed files with 34 additions and 3 deletions

View file

@ -0,0 +1 @@
export * from './scrollPosition.directive';

View file

@ -0,0 +1,23 @@
import {Directive, Input, Output, EventEmitter, HostListener, ElementRef} from 'angular2/core';
@Directive({
selector: '[scrollPosition]'
})
export class ScrollPosition {
@Input() maxHeight: Number;
@Output() scrollChange:EventEmitter<Boolean> = new EventEmitter<Boolean>();
private _isScrolled: Boolean;
ngOnInit() {
this.onWindowScroll();
}
@HostListener('window:scroll')
onWindowScroll() : void {
let isScrolled = window.scrollY > this.maxHeight;
if (isScrolled !== this._isScrolled) {
this._isScrolled = isScrolled;
this.scrollChange.emit(isScrolled);
}
}
}

View file

@ -2,12 +2,19 @@ import {Component, ViewEncapsulation} from 'angular2/core';
import {MsgCenter} from '../msgCenter';
import {ProfilePicturePipe} from '../pipes/image/profile-picture.pipe';
import {ScrollPosition} from '../directives/scrollPosition.directive';
@Component({
selector: 'page-top',
styles: [ require('./pageTop.scss') ],
template: require('./pageTop.html'),
directives: [MsgCenter],
directives: [MsgCenter, ScrollPosition],
pipes: [ProfilePicturePipe]
})
export class PageTop {}
export class PageTop {
isScrolled: Boolean = false;
scrolledChanged(isScrolled) {
this.isScrolled = isScrolled;
}
}

View file

@ -1,4 +1,4 @@
<div class="page-top clearfix" scroll-position="scrolled" max-height="50" ng-class="{'scrolled': scrolled}">
<div class="page-top clearfix" scrollPosition maxHeight="50" (scrollChange)="scrolledChanged($event)" [ngClass]="{scrolled: isScrolled}">
<a href="#/dashboard" class="al-logo clearfix"><span>Blur</span>Admin</a>
<a href class="collapse-menu-link ion-navicon" ng-click="isMenuCollapsed=!isMenuCollapsed"></a>