本文整理汇总了TypeScript中@angular/material.MatSidenav类的典型用法代码示例。如果您正苦于以下问题:TypeScript MatSidenav类的具体用法?TypeScript MatSidenav怎么用?TypeScript MatSidenav使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MatSidenav类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: ngOnInit
// -----------------------------------------------------------------------------------------------------
// @ Lifecycle hooks
// -----------------------------------------------------------------------------------------------------
/**
* On init
*/
ngOnInit(): void
{
// Register the sidenav to the service
this._fuseMatSidenavHelperService.setSidenav(this.fuseMatSidenavHelper, this._matSidenav);
if ( this._observableMedia.isActive(this.matIsLockedOpen) )
{
this.isLockedOpen = true;
this._matSidenav.mode = 'side';
this._matSidenav.toggle(true);
}
else
{
this.isLockedOpen = false;
this._matSidenav.mode = 'over';
this._matSidenav.toggle(false);
}
this._fuseMatchMediaService.onMediaChange
.pipe(takeUntil(this._unsubscribeAll))
.subscribe(() => {
if ( this._observableMedia.isActive(this.matIsLockedOpen) )
{
this.isLockedOpen = true;
this._matSidenav.mode = 'side';
this._matSidenav.toggle(true);
}
else
{
this.isLockedOpen = false;
this._matSidenav.mode = 'over';
this._matSidenav.toggle(false);
}
});
}
开发者ID:,项目名称:,代码行数:42,代码来源:
示例2:
.subscribe(() => {
if ( this._observableMedia.isActive(this.matIsLockedOpen) )
{
this.isLockedOpen = true;
this._matSidenav.mode = 'side';
this._matSidenav.toggle(true);
}
else
{
this.isLockedOpen = false;
this._matSidenav.mode = 'over';
this._matSidenav.toggle(false);
}
});
开发者ID:,项目名称:,代码行数:14,代码来源:
示例3: swipe
/**
* Handle swipes and gestures
*/
public swipe(e: TouchEvent, when: string): void {
const coord: [number, number] = [e.changedTouches[0].pageX, e.changedTouches[0].pageY];
const time = new Date().getTime();
if (when === 'start') {
this.swipeCoord = coord;
this.swipeTime = time;
} else if (when === 'end') {
const direction = [coord[0] - this.swipeCoord[0], coord[1] - this.swipeCoord[1]];
const duration = time - this.swipeTime;
if (
duration < 1000 &&
Math.abs(direction[0]) > 30 && // swipe length to be detected
Math.abs(direction[0]) > Math.abs(direction[1] * 3) // 30° should be "horizontal enough"
) {
// definition of a "swipe right" gesture to move in the navigation
// only works in the far left edge of the screen
if (
direction[0] > 0 && // swipe left to right
this.swipeCoord[0] < 20
) {
this.sideNav.open();
}
// definition of a "swipe left" gesture to remove the navigation
// should only work in mobile mode to prevent unwanted closing of the nav
// works anywhere on the screen
if (
direction[0] < 0 && // swipe left to right
this.vp.isMobile
) {
this.sideNav.close();
}
}
}
}
开发者ID:jwinzer,项目名称:OpenSlides,代码行数:39,代码来源:site.component.ts
示例4: ngOnInit
/**
* Initialize the site component
*/
public ngOnInit(): void {
this.vp.checkForChange();
// observe the mainMenuService to receive toggle-requests
this.mainMenuService.toggleMenuSubject.subscribe((value: void) => this.toggleSideNav());
// get a translation via code: use the translation service
// this.translate.get('Motions').subscribe((res: string) => {
// console.log('translation of motions in the target language: ' + res);
// });
// TODO: Remove this, when the ESR version of Firefox >= 64.
const agent = navigator.userAgent.toLowerCase();
if (agent.indexOf('firefox') > -1) {
const index = agent.indexOf('firefox') + 8;
const version = +agent.slice(index, index + 2);
if (version < 64) {
const sideNav = document.querySelector(
'mat-sidenav.side-panel > div.mat-drawer-inner-container'
) as HTMLElement;
sideNav.style.overflow = 'hidden';
sideNav.addEventListener('MozMousePixelScroll', (event: any) => {
sideNav.scrollBy(0, event.detail);
});
}
}
this.router.events.subscribe(event => {
// Scroll to top if accessing a page, not via browser history stack
if (event instanceof NavigationEnd) {
const contentContainer = document.querySelector('.mat-sidenav-content');
if (contentContainer) {
contentContainer.scrollTo(0, 0);
}
}
});
}
开发者ID:CatoTH,项目名称:OpenSlides,代码行数:41,代码来源:site.component.ts
示例5:
this.authService.authStatus.subscribe(authStatus => {
if (!authStatus.isAuthenticated) {
this.sideNav.close()
}
})
开发者ID:ershad1,项目名称:lemon-mart-1,代码行数:5,代码来源:app.component.ts
示例6: mobileAutoCloseNav
/**
* Automatically close the navigation in while navigating in mobile mode
*/
public mobileAutoCloseNav(): void {
if (this.vp.isMobile) {
this.sideNav.close();
}
}
开发者ID:jwinzer,项目名称:OpenSlides,代码行数:8,代码来源:site.component.ts
示例7: toggleSideNav
/**
* Toggles the side nav
*/
public toggleSideNav(): void {
this.sideNav.toggle();
}
开发者ID:jwinzer,项目名称:OpenSlides,代码行数:6,代码来源:site.component.ts
示例8: toggle
/**
* Toggle this sidenav. This is equivalent to calling open() when it's already opened, or close() when it's closed.
*
* @param {boolean} isOpen Whether the sidenav should be open.
*
* @returns {Promise<MatSidnavToggleResult>}
*/
public toggle(isOpen?: boolean): Promise<MatDrawerToggleResult> {
this.sidenav.toggle(isOpen);
return;
}
开发者ID:idealhack,项目名称:gocryptotrader,代码行数:11,代码来源:sidebar.service.ts
示例9: close
/**
* Close this sidenav, and return a Promise that will resolve when it's fully closed (or get rejected if it didn't).
*
* @returns Promise<MatSidnavToggleResult>
*/
public close(): Promise<MatDrawerToggleResult> {
this.sidenav.close();
return;
}
开发者ID:idealhack,项目名称:gocryptotrader,代码行数:9,代码来源:sidebar.service.ts
示例10: open
/**
* Open this sidenav, and return a Promise that will resolve when it's fully opened (or get rejected if it didn't).
*
* @returns Promise<MatSidnavToggleResult>
*/
public open(): Promise<MatDrawerToggleResult> {
this.sidenav.open();
return;
}
开发者ID:idealhack,项目名称:gocryptotrader,代码行数:10,代码来源:sidebar.service.ts
注:本文中的@angular/material.MatSidenav类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论