Skip to content

Instantly share code, notes, and snippets.

@JiaLiPassion
Created September 17, 2017 04:24
Show Gist options
  • Save JiaLiPassion/45664f6a28c8b522fca30c841610c6b4 to your computer and use it in GitHub Desktop.
Save JiaLiPassion/45664f6a28c8b522fca30c841610c6b4 to your computer and use it in GitHub Desktop.
New Zone BlackList
// before load polyfill.js
<script>
// black list scroll event handler for addEventListener
Zone[Zone.__symbol__('BLACK_LISTED_EVENTS')] = ['scroll', 'mouseenter', 'mouseleave', 'mousemove', 'mouseover', 'mouseout', 'mousewheel'];
// black list scroll event handler for onProp
const targets = [window, Document.prototype, HTMLBodyElement.prototype, HTMLElement.prototype];
__Zone_ignore_on_properties = [];
targets.forEach(function(target) {
__Zone_ignore_on_properties.push({
target: target,
ignoreProperties: ['scroll', 'mouseenter', 'mouseleave', 'mousemove', 'mouseover', 'mouseout', 'mousewheel']
});
});
// disable requestAnimationFrame
__Zone_disable_requestAnimationFrame = true;
</script>
@PhaedrusTheGreek
Copy link

I tried importing the bit contained within the <script> tags as blacklist.js from polyfill.js after Zone JS, and it loaded but mousemove is still triggering Angular reaction.

/***************************************************************************************************
 * Zone JS is required by Angular itself.
 */
import 'zone.js/dist/zone';  // Included with Angular CLI.



/***************************************************************************************************
 * APPLICATION IMPORTS
 */
import 'blacklist.js';

@JiaLiPassion
Copy link
Author

@PhaedrusTheGreek, which version of zone.js and angular are you using ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment