Skip to content

Conversation

@prateekbh
Copy link
Member

Adds a threshold to swipe before education system is triggered

gestures.onGesture(SwipeXYRecognizer, e => {
const xSwipe = Math.abs(e.data.deltaX);
const ySwipe = Math.abs(e.data.deltaY);
const minSwipeDelta = 50;
Copy link
Member

@alanorozco alanorozco Dec 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be a top-level-constant, MIN_SWIPE_FOR_HINT_OVERLAY_PX = 50.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

gestures.onGesture(SwipeXYRecognizer, () => {
if (this.bookend_.isActive()) {
gestures.onGesture(SwipeXYRecognizer, e => {
const xSwipe = Math.abs(e.data.deltaX);
Copy link
Member

@alanorozco alanorozco Dec 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Refactor into boolean method.
  2. Make short-circuit clauses independent.
if (this.bookend_.isActive()) {
  return;
}
if (!isSwipeLargeEnoughForHint_(e.data.deltaX, e.data.deltaY)) {
  return;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const xSwipe = Math.abs(e.data.deltaX);
const ySwipe = Math.abs(e.data.deltaY);
const minSwipeDelta = 50;
const canShowEducationOverlay =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid the word education as the current terminology is hint.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is remove

const ySwipe = Math.abs(e.data.deltaY);
const minSwipeDelta = 50;
const canShowEducationOverlay =
xSwipe > minSwipeDelta || ySwipe > minSwipeDelta;
Copy link
Member

@alanorozco alanorozco Dec 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inaccurate, you should calculate line distance:

Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2)) 
  > MIN_SWIPE_FOR_HINT_OVERLAY_PX

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah... makes sense

@alanorozco alanorozco changed the title Less sensitive swipe Increase swipe sensitivity for hint overlay Dec 22, 2017
@alanorozco alanorozco changed the title Increase swipe sensitivity for hint overlay Decrease swipe sensitivity for hint overlay Dec 22, 2017
@alanorozco alanorozco merged commit bde8583 into ampproject:master Jan 1, 2018
@prateekbh prateekbh deleted the lessSensitiveSwipe branch January 2, 2018 02:04
gzgogo pushed a commit to gzgogo/amphtml that referenced this pull request Jan 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants