From 200d9af315a61272553f5902b7b743f8c3493123 Mon Sep 17 00:00:00 2001 From: Hedger Wang Date: Wed, 23 Sep 2015 19:51:08 -0700 Subject: [PATCH] Add method `stopPropagation` and `stop` to NavigationEvent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: @​public Add method `stopPropagation` and `stop` to NavigationEvent so we can stop event easily once event bubbling and capturing is supported. Reviewed By: @fkgozali Differential Revision: D2471903 --- .../Navigator/Navigation/NavigationEvent.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Libraries/CustomComponents/Navigator/Navigation/NavigationEvent.js b/Libraries/CustomComponents/Navigator/Navigation/NavigationEvent.js index b1d6268da..474336b65 100644 --- a/Libraries/CustomComponents/Navigator/Navigation/NavigationEvent.js +++ b/Libraries/CustomComponents/Navigator/Navigation/NavigationEvent.js @@ -57,6 +57,7 @@ var _navigationEventPool = new NavigationEventPool(); class NavigationEvent { _data: any; _defaultPrevented: boolean; + _propagationStopped: boolean; _disposed: boolean; _target: ?Object; _type: ?string; @@ -71,6 +72,7 @@ class NavigationEvent { this._data = data; this._defaultPrevented = false; this._disposed = false; + this._propagationStopped = false; } /* $FlowFixMe - get/set properties not yet supported */ @@ -97,6 +99,19 @@ class NavigationEvent { this._defaultPrevented = true; } + stopPropagation(): void { + this._propagationStopped = true; + } + + stop(): void { + this.preventDefault(); + this.stopPropagation(); + } + + isPropagationStopped(): boolean { + return this._propagationStopped; + } + /** * Dispose the event. * NavigationEvent shall be disposed after being emitted by