Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment flag for using amp-base-carousel from amp-lightbox-gallery. #21569

Merged
merged 7 commits into from Apr 3, 2019

Conversation

sparhami
Copy link

@sparhami sparhami commented Mar 26, 2019

There is still more work to do before actually getting this out, but setting up the groundwork.

  • Implement methods needed for next/prev on amp-base-carousel.
  • Change carousel creation / reuse tags and selectors to use
    amp-base-carousel for the experiment.
  • Fix a race between goToSlide and updateUi which would result in the call
    to goToSlide being ignored.

For #21568

- Implement methods needed for next/prev on `amp-base-carousel`.
- Change carousel creation / reuse tags and selectors to use
`amp-base-carousel` for the experiment.
Sepand Parhami added 2 commits March 27, 2019 10:45
- Fix a race between `goToSlide` and `updateUi` which would result in the call
  to `goToSlide` being ignored.
@sparhami sparhami requested a review from cathyxz March 27, 2019 21:30
Copy link
Contributor

@cathyxz cathyxz left a comment

Choose a reason for hiding this comment

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

We chatted offline about this: there could potentially be a race condition where if goToSlide is called in the middle of the user interacting with the carousel, it would directly jump to the requested slide and result in a jarring UX. We should either fix or file / note this behavior.

extensions/amp-base-carousel/0.1/carousel.js Outdated Show resolved Hide resolved
extensions/amp-base-carousel/0.1/carousel.js Show resolved Hide resolved
- Reword comment.
- Change `updateCurrentIndex` to update `restingIndex` instead.
- Ignore programmatic scrolls when the user is scrolling.
- Make multiple rapid succession calls to advance end on the correct
slide.
@sparhami
Copy link
Author

sparhami commented Apr 2, 2019

We chatted offline about this: there could potentially be a race condition where if goToSlide is called in the middle of the user interacting with the carousel, it would directly jump to the requested slide and result in a jarring UX. We should either fix or file / note this behavior.

Added logic to goToSlide to bail out if the user is scrolling. Also added a small fix to allow calling advance multiple times in a row before the current index has updated.

@@ -838,6 +869,8 @@ export class Carousel {
* @private
*/
resetScrollReferencePoint_(force = false) {
this.scrolling_ = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be after making sure that the user is not in the middle of a drag?

Copy link
Author

Choose a reason for hiding this comment

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

I considered it, but we already have something to check for touching. So if they stopped scrolling (no scroll event recently), but they are still touching the screen, I think it would be cleaner to say that there is no scrolling, and interested code can check for touching as well. If they are dragging, we should get scroll events, so that would still count as scrolling.

@sparhami sparhami merged commit d23164a into ampproject:master Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants