mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-18 08:20:13 +01:00
on window resize re calculate width to collapse sidebar
This commit is contained in:
parent
80c1e0a79c
commit
081a94eab2
2 changed files with 26 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import {Component, ElementRef} from 'angular2/core';
|
import {Component, ElementRef, HostListener} from 'angular2/core';
|
||||||
|
|
||||||
|
import {layoutSizes} from '../theme.constants';
|
||||||
import {SidebarService} from './sidebar.service';
|
import {SidebarService} from './sidebar.service';
|
||||||
import {Router} from 'angular2/router';
|
import {Router} from 'angular2/router';
|
||||||
|
|
||||||
|
|
@ -23,6 +24,8 @@ export class Sidebar {
|
||||||
hoverElemHeight: number;
|
hoverElemHeight: number;
|
||||||
hoverElemTop: number;
|
hoverElemTop: number;
|
||||||
|
|
||||||
|
isMenuShouldCollapsed: boolean = false;
|
||||||
|
|
||||||
constructor(el: ElementRef, router: Router, private _sidebarService: SidebarService) {
|
constructor(el: ElementRef, router: Router, private _sidebarService: SidebarService) {
|
||||||
this.elementRef = el;
|
this.elementRef = el;
|
||||||
this.router = router;
|
this.router = router;
|
||||||
|
|
@ -39,6 +42,23 @@ export class Sidebar {
|
||||||
this.menuHeight = this.elementRef.nativeElement.childNodes[0].clientHeight - 84;
|
this.menuHeight = this.elementRef.nativeElement.childNodes[0].clientHeight - 84;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@HostListener('window:resize', ['$event'])
|
||||||
|
onWindowResize($event) {
|
||||||
|
|
||||||
|
var isMenuShouldCollapsed = $event.target.innerWidth <= layoutSizes.resWidthCollapseSidebar;
|
||||||
|
var scopeApplied = false;
|
||||||
|
|
||||||
|
if (this.isMenuShouldCollapsed !== isMenuShouldCollapsed) {
|
||||||
|
this.menuHeight = this.elementRef.nativeElement.childNodes[0].clientHeight - 84;
|
||||||
|
this.isMenuCollapsed = isMenuShouldCollapsed;
|
||||||
|
scopeApplied = true;
|
||||||
|
}
|
||||||
|
if (!scopeApplied) {
|
||||||
|
this.menuHeight = this.elementRef.nativeElement.childNodes[0].clientHeight - 84;
|
||||||
|
}
|
||||||
|
this.isMenuShouldCollapsed = isMenuShouldCollapsed;
|
||||||
|
}
|
||||||
|
|
||||||
menuExpand () {
|
menuExpand () {
|
||||||
this.isMenuCollapsed = false;
|
this.isMenuCollapsed = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
export const IMAGES_ROOT = 'assets/img/';
|
export const IMAGES_ROOT = 'assets/img/';
|
||||||
|
|
||||||
|
export const layoutSizes = {
|
||||||
|
resWidthCollapseSidebar: 1200,
|
||||||
|
resWidthHideSidebar: 500
|
||||||
|
};
|
||||||
|
|
||||||
export const layoutPaths = {
|
export const layoutPaths = {
|
||||||
images: {
|
images: {
|
||||||
root: IMAGES_ROOT,
|
root: IMAGES_ROOT,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue