Skip to content

Commit

Permalink
[amp-story] Prevent clicks on top 80% (#32518)
Browse files Browse the repository at this point in the history
* prevent clicks on bottom 80%

* readability
  • Loading branch information
Enriqe committed Feb 10, 2021
1 parent f8e229c commit daa95ee
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions extensions/amp-story/1.0/page-advancement.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,12 @@ export class ManualAdvancement extends AdvancementConfig {
* We want clicks on certain elements to be exempted from normal page
* navigation
* @param {!Event} event
* @param {!ClientRect} pageRect
* @return {boolean}
* @private
*/
isProtectedTarget_(event) {
return !!closest(
isBottomCtaTappableTarget_(event, pageRect) {
const target = closest(
dev().assertElement(event.target),
(el) => {
const elementRole = el.getAttribute('role');
Expand All @@ -456,6 +457,8 @@ export class ManualAdvancement extends AdvancementConfig {
},
/* opt_stopAt */ this.element_
);

return !!target && this.isInScreenBottom_(target, pageRect);
}

/**
Expand Down Expand Up @@ -708,7 +711,7 @@ export class ManualAdvancement extends AdvancementConfig {
if (
!this.isRunning() ||
!this.isNavigationalClick_(event) ||
this.isProtectedTarget_(event) ||
this.isBottomCtaTappableTarget_(event, pageRect) ||
!this.shouldHandleEvent_(event)
) {
// If the system doesn't need to handle this click, then we can simply
Expand All @@ -717,6 +720,7 @@ export class ManualAdvancement extends AdvancementConfig {
}

event.stopPropagation();
event.preventDefault();

this.storeService_.dispatch(
Action.SET_ADVANCEMENT_MODE,
Expand Down

0 comments on commit daa95ee

Please sign in to comment.