+
+
+ {props => (
+ this.setState({lightbox1Open: false})}
+ closeConfirm={this.state.lightbox1Blocked && lightbox1BlockedMessage}
+ deps={{backButton: this.backButtonService}}
+ // TBD: no way to inject ref.current instead? No re-render
+ // on hydration...
+ transitionAnchor={this.buttonRef}
+ >
+ This is a lightbox
+
+
+
+
+
+
+ scroll down...
+
+
+
+
+ )}
+
+
+
+
+
+
+
+
amp-react-img
amp-react-img
}
}
-ReactDOM.render(, document.getElementById('app'))
+// TODO: redo this service via Router.history object.
+class BackButtonServiceFake {
+ /** @return BackButtonMarker */
+ push() {
+ return new BackButtonMarkerFake();
+ }
+}
+
+class BackButtonMarkerFake {
+ constructor() {
+ this.closed = false;
+ /** @type {?function()} */
+ this.onPop = null;
+
+ /** @private {boolean} */
+ this.popped_ = false;
+ this.popHandler_ = () => {
+ this.popped_ = true;
+ this.pop();
+ };
+ window.addEventListener('popstate', this.popHandler_);
+ history.pushState({index: 1}, '');
+ }
+
+ pop() {
+ if (this.closed) {
+ return;
+ }
+ this.closed = true;
+ if (this.onPop) {
+ this.onPop();
+ this.onPop = null;
+ }
+ if (!this.popped_) {
+ this.popped_ = true;
+ history.go(-1);
+ }
+ if (this.popHandler_) {
+ window.removeEventListener('popstate', this.popHandler_);
+ this.popHandler_ = null;
+ }
+ }
+}
+
+
+ReactDOM.render(, document.getElementById('app'))