本文整理汇总了TypeScript中@angular/material.MatSidenav.open方法的典型用法代码示例。如果您正苦于以下问题:TypeScript MatSidenav.open方法的具体用法?TypeScript MatSidenav.open怎么用?TypeScript MatSidenav.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/material.MatSidenav
的用法示例。
在下文中一共展示了MatSidenav.open方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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();
}
}
}
}
示例2: 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;
}
示例3: open
public open() {
return this.sidenav.open();
}