diff --git a/extensions/amp-story/1.0/amp-story.js b/extensions/amp-story/1.0/amp-story.js index 58fe278b822d3..fdf0ae908bfeb 100644 --- a/extensions/amp-story/1.0/amp-story.js +++ b/extensions/amp-story/1.0/amp-story.js @@ -416,7 +416,8 @@ export class AmpStory extends AMP.BaseElement { this.switchTo_(args['id'], NavigationDirection.NEXT); this.closeOpacityMask_(); } - } this.switchTo_(args['id'], NavigationDirection.NEXT); + } + this.switchTo_(args['id'], NavigationDirection.NEXT); }); } } @@ -2241,19 +2242,22 @@ export class AmpStory extends AMP.BaseElement { } if (isExperimentOn(this.win,'amp-story-branching')) { this.sidebar_.addEventListener('click', e => { - if (e.target.tagName === 'A') { - // Do not let the browser scroll - e.preventDefault(); + if (e.target.tagName === 'A') { const url = e.target.getAttribute('href'); - // Handle for absolute URLs, in addition to fragments only. - this.win.location.hash = url.slice(url.search('\#(.*)')); + if (url.indexOf('#page=') >= 0) { + // Do not let the browser scroll + e.preventDefault(); - const actions = Services.actionServiceForDoc(this.element); - actions.execute(dev().assertElement(this.sidebar_), - 'close', /* args */ null, /* source */ null, /* caller */ null, - /* event */ null, ActionTrust.HIGH); - this.closeOpacityMask_(); + // Handle for absolute URLs, in addition to fragments only. + this.win.location.hash = url.slice(url.search('\#(.*)')); + + const actions = Services.actionServiceForDoc(this.element); + actions.execute(dev().assertElement(this.sidebar_), + 'close', /* args */ null, /* source */ null, /* caller */ null, + /* event */ null, ActionTrust.HIGH); + this.closeOpacityMask_(); + } } }); }