Skip to content

Commit

Permalink
make sure outlinks still work
Browse files Browse the repository at this point in the history
  • Loading branch information
bramanudom committed Feb 20, 2019
1 parent c37f7ee commit f821798
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions extensions/amp-story/1.0/amp-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}
Expand Down Expand Up @@ -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_();
}
}
});
}
Expand Down

0 comments on commit f821798

Please sign in to comment.