我想創建對話框,但問題是我想禁用對話框中的動畫,以便如何禁用它。如何禁用動畫角質材料2中的角度對話框4
回答
您可以通過導入禁止
NoopAnimationsModule
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
@NgModule({
...
imports: [NoopAnimationsModule],
...
})
如果我想在特定條件下禁用動畫,那我該怎麼做。 –
嘗試在組件字段示例中添加轉換.mat-dialog-container { transition:none; } – CharanRoot
你搖滾。它工作。 –
在你要保持你的動畫在您的應用程序的情況下,但能夠禁用一個附加到一個對話框,你可以通過一個對話框來覆蓋對話框,你可以控制和禁用所有的動畫該容器內的mations。
覆蓋OverlayContainer部件
創建延伸從CDK
import { OverlayContainer } from '@angular/cdk/overlay'; export class CustomOverlayContainer extends OverlayContainer { _defaultContainerElement: HTMLElement; constructor() { super(); } public setContainer(container: HTMLElement) { this._defaultContainerElement = this._containerElement; this._containerElement = container; } public restoreContainer() { this._containerElement = this._defaultContainerElement; } }
覆蓋上的應用程序模塊提供者的CDK OverlayContainer由自定義一個所述一個自定義OverlayContainer
export function initOverlay() { return new CustomOverlayContainer(); } @NgModule({ ... providers: [ ... { provide: OverlayContainer, useFactory: initOverlay } ... ] ... })
替換對話框包裝
獲取訪問的新對話框容器和替換默認的一個
export class AppComponent implements AfterViewInit {
@ViewChild('dialogContainer') dialogContainer: ElementRef;
constructor(private dialog: MatDialog, private overlayContainer: OverlayContainer) {
}
ngAfterViewInit() {
(this.overlayContainer as CustomOverlayContainer).setContainer(this.dialogContainer.nativeElement);
this.dialog.open(...);
}
}
禁用動畫
添加[@.disabled]
綁定到你的容器,以便禁用其內部發生的所有動畫。 https://angular.io/api/animations/trigger#disable-animations
<div #dialogContainer [@.disabled]="true"></div>
- 1. 關閉角度材質對話框
- 2. 角度材質對話框返回值
- 3. 角度材質2 - 禁用紋波?
- 4. 如何清除對話框材質內部的對角線2
- 5. 如何簡化角度材質對話框的使用?
- 6. 角度材質2對話框顯得更暗
- 7. 材料角度與角4在生產
- 8. 材料和角度2
- 9. 角2材料
- 10. 如何禁用角度材質2側面導航的背景?
- 11. 角度材質2:如何覆蓋對話框最大寬度爲100vw?
- 12. 角材料對話框犯規收縮
- 13. 如何在角度材質中禁用自動填充md-autocomplete
- 14. 卡住角度2的角度材質中的MdSnackBar的Observable Loop
- 15. 使用角度2材質圖標
- 16. 如何在「角度材質」對話框中使用相同的控制器?
- 17. 角度材料,$ mdDialog
- 18. 如何選擇角度材料2和量角器的選項?
- 19. Angular CLI的角度2材質
- 20. 如何使角材料對話框在IE10中工作
- 21. Angular 4如何禁用角度材質標籤組中的標籤導航?
- 22. 角度材料4柔性佈局
- 23. 角度4&材料步進器
- 24. 單元測試角材料2對話框
- 25. 啓動時的角度材料2微調框
- 26. 禁用角度材質對話框區域外的點擊以關閉對話框(使用Angular Version 4.0+)
- 27. 角度材質銷燬對話框實例
- 28. 角度材質MD對話框加載延遲
- 29. 角度材質對話框關閉限制
- 30. 角度材質對話框顯示不正確
'進口{} NoopAnimationsModule從 '@角/平臺的瀏覽器/動畫';'而不是'進口{} BrowserAnimationsModule '@角/平臺的瀏覽器/動畫';'在主'AppModule'並放入'imports'數組中。這完全關閉了動畫。除此之外,你不清楚你在問什麼。 –