Created
March 24, 2017 22:31
-
-
Save icfantv/423297cfcdc1873b99d1f4b1eb7a183a to your computer and use it in GitHub Desktop.
The Twilight Zone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const events: any = { | |
'addEventListener:scroll': true, | |
'addEventListener:mouseenter': false, | |
'addEventListener:mouseleave' : false, | |
'addEventListener:mousemove': true, | |
}; | |
// const twilightZone = Zone.current.fork(Zone['wtfZoneSpec']).fork({ | |
const twilightZone = Zone.current.fork({ | |
name: 'twilight', | |
onScheduleTask : function (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, task: Task): Task { | |
let cancel = false; | |
if (task.type === 'eventTask') { | |
const parts = task.source.split('.'); | |
if (events[parts[1]]) { | |
cancel = true; | |
} | |
} else if (task.type === 'macroTask') { | |
if (task.source === 'requestAnimationFrame') { | |
cancel = true; | |
} | |
} | |
if (cancel) { | |
// console.log("Escaping NgZone", task.source); | |
task.cancelScheduleRequest(); | |
return currentZone.parent.scheduleTask(task); | |
} | |
return parentZoneDelegate.scheduleTask(targetZone, task); | |
} | |
}); | |
twilightZone.run(() => { | |
platformBrowserDynamic().bootstrapModule(SpinnakerModule); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment