Skip to content

Instantly share code, notes, and snippets.

@e-oz
Created December 26, 2022 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e-oz/aa02d77e4514de9651ad8fd57023fa4c to your computer and use it in GitHub Desktop.
Save e-oz/aa02d77e4514de9651ad8fd57023fa4c to your computer and use it in GitHub Desktop.
NgZone optimisations for Angular CDK Drag & Drop
platformBrowserDynamic().bootstrapModule(AppModule, {
ngZoneEventCoalescing: true,
ngZoneRunCoalescing: true,
}).catch((err) => console.error(err));
//import '@angular/localize/init';
import './zone-flags';
import 'zone.js';
import 'zone.js/plugins/zone-patch-rxjs';
/* eslint-disable @typescript-eslint/no-explicit-any */
//
// https://angular.io/guide/zone#setting-up-zonejs
// https://github.com/angular/angular/blob/master/packages/zone.js/lib/zone.configurations.api.ts
//
(window as any).__Zone_disable_defineProperty = true;
(window as any).__Zone_disable_requestAnimationFrame = true;
(window as any).__Zone_disable_on_property = true;
(window as any).__zone_symbol__UNPATCHED_EVENTS = [
'blur', 'focus',
'drag', 'dragend', 'dragenter', 'dragleave', 'dragover', 'dragstart',
'durationchange',
'emptied',
'mouseenter', // needed for mat-tooltip (if no zone-rxjs patch)
'mouseleave', // needed for mat-tooltip (if no zone-rxjs patch)
'mouseout',
'mousemove', // needed for mat-slider (if no zone-rxjs patch)
'mouseover',
'scroll',
'mousewheel',
'ratechange', 'timeupdate', 'waiting', 'touchmove',
'mozpointerlockchange', 'mozpointerlockerror'
];
(window as any).__Zone_disable_EventEmitter = true;
(window as any).__Zone_disable_nextTick = true;
(window as any).__Zone_disable_fs = true;
(window as any).__Zone_disable_node_timers = true;
(window as any).__Zone_disable_crypto = true;
(window as any).__Zone_disable_blocking = true;
// (window as any).__Zone_disable_EventTarget = true;
(window as any).__Zone_disable_FileReader = true;
(window as any).__Zone_disable_MutationObserver = true;
(window as any).__Zone_disable_IntersectionObserver = true;
(window as any).__Zone_disable_customElements = true;
(window as any).__Zone_disable_XHR = true;
(window as any).__Zone_disable_geolocation = true;
(window as any).__Zone_disable_canvas = true;
try {
if (window?.location?.hostname !== 'localhost') {
(window as any).__zone_symbol__DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION = true;
(window as any).__zone_symbol__ignoreConsoleErrorUncaughtError = true;
}
} catch (e) {
console.error(e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment