-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Announcement bar] Slides animation. #2595
Conversation
f8bc819
to
758ccb6
Compare
6541e4e
to
50069e5
Compare
1932286
to
1b40cdf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reviewed the CSS, sharing some initial thoughts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The animation looks good! Left some code suggestions.
Also, I noticed if I click next a few times quickly, the animation for returning to the 1st announcement is not playing at the correct moment anymore (between slide 4 -> 5, instead of 5 -> 1)
screencast.2023-06-06.18-33-45.mp4
assets/global.js
Outdated
setTimeout(() => { | ||
slide.classList.add(`announcement-bar-slider--fade-in-next`); | ||
}, 200); | ||
setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can some of these setTimout
be avoided if we leverage animation delay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried but I couldn't find a way to make it work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I think we can keep the setTimeout
. One other question is why we need to apply animation classes on every slide on every button click? Could we only need to apply animation on the outgoing and incoming slide?
I pushed updates. I tried to account for your suggestions regarding CSS and combined them. @KaichenWang , regarding this quick clicking issue I think it's a very edge case and you really need to click faster than 200ms to reproduce it. I don't think it's reasonable to cover that case 🤔. |
assets/global.js
Outdated
setTimeout(() => { | ||
slide.classList.add(`announcement-bar-slider--fade-in-next`); | ||
}, 200); | ||
setTimeout(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I think we can keep the setTimeout
. One other question is why we need to apply animation classes on every slide on every button click? Could we only need to apply animation on the outgoing and incoming slide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sharing my current feeling on the approach.
Curious of your thoughts as well as @KaichenWang's
We can open a separate issue for this. Agreed it's an edge case, but we should try to understand why it's happening. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Tested:
- Announcement bar
- Slideshow section
- Complementary products
* Rename announcement-bar to utility-bar section. Add basic logic for social-icons in the utility-bar. * Remove social icons from the utility bar for tablet Remove social icons snippet * Prevent auto-rotation after users interact with arrow buttons. Change the slider width for screens wider than 1200px. Rename back a file name from utility-bar to announcement-bar. * Prevent auto-rotation for mobile. Reduce social icons sizes for in the utility bar. Change grid system. * Prevent showing bottom-border when the utility bar is empty. * Add layout for screens under 1200px. * Adjust a separater line for max-width: 1199px * Revert announcement-bar name. Remove additional layout for desktop under 1120px. Remove JS logic. * Minor changes. * Refactor of css classes. Refactor of liquid logic. Use social-icons as a snippet. * Refactor in social-icons snippet. Change the naming in css accordingly BEM. * Update 14 translation files * Update 6 translation files * Change label for show_social. * Update 15 translation files * Update 5 translation files --------- Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com>
* Use live region to announce recipient form * Inject text instead of toogling aria-hidden * Announce form collapsed when checkbox unticked * Update 20 translation files * Update 4 translation files * Update 6 translation files --------- Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of my comments are nitpicks but there is one for iOS/Safari that I think we would sort before shipping ideally.
this.slider.scrollTo({ | ||
left: position, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we use the new function you added here ? setSlidePosition(position)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inside itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no, I didn't realize. It got me confused cause the function is so similar for the SliderComponent and SlideshowComponent. And named the same way as well though does it differently, one with a timeout and one without.
assets/global.js
Outdated
this.announcementBarSlider = this.querySelector('.announcement-bar-slider'); | ||
// Value below should match --duration-announcement-bar CSS value | ||
this.delay = this.announcementBarSlider ? 250 : 0; | ||
this.sliderTransitionSelector = 'slider--transition'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is something I'm seeing on Safari for the last slide:
RPReplay_Final1687374243.MP4
this.setSlidePosition(this.slideScrollPosition); | ||
|
||
this.appleAnimationToAnnouncementBar(event.currentTarget.name); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I noticed is that all the logic is added to be tackled onButtonClick when it should also be running on scroll/swipe 😬
If you use it on mobile and swipe instead of you will see that it doesn't apply all the changes necessary.
So I think you could either look into:
- applying some of the
announcement-bar-slider--fade-***
class in liquid by default. Since you know which slide will be showing on page load and which ones won't. - look at applying the same transitions in the
update()
function where it's checking what is the current page and what's the previous page. If you apply the logic you added toonButtonClick
there it should work in all cases. Tho it might be triggered too late compared to when the button is clicked 🤔
From what I'm seeing it's working ok on page load. No animation is applied but at least all slides are being shown. If you click on the previous or next button though, and then swipe later, the slides are hidden. Ideally they would work whatever the method you're using to go to the next slide is.
RPReplay_Final1687551919.MP4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for flagging this Ludo.
This is happening because when you start scrolling/swiping we don't apply animation but some slides still have animation classes because we remove them only with the next cycle. I added code to prevent it. Now it looks good to me.
I would not apply animation for cases when we scroll/swipe because I think it looks better and more natural to have the effect we have now for scrolling.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having the animation on scroll/swipe would be good but I don't think we should delay this PR more for it. It could be a thing we look into adding in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, just gotta remove a console log 👍
this.setSlidePosition(this.slideScrollPosition); | ||
|
||
this.appleAnimationToAnnouncementBar(event.currentTarget.name); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having the animation on scroll/swipe would be good but I don't think we should delay this PR more for it. It could be a thing we look into adding in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
* Add animation to the announcement bar. * Add animation for the current and next slides. * Make animation works for auto-rotating. * Ensure the slider rotates in reverse when it reaches the end/begining. * Add condition to apply delay for announcement-bar only * Refactor and update some logic. * Refactoring. * Remove unneccessary css code. * Refactor css. Change the order. * Refactor JS. * Refactor css. * Isolate all logic in slideshowComponent. * Simplify applyAnimation method. * Reuse currentPage * Apply animation on selected slides. * Adjust duration of animation and shifting. * Refactoring * Another refactoring * Remove timeout and add delay in css * Refactoring * Add no-js * Prevent snapping during animation * Fix auto-rotation positioning * Refactor applyAnimation * Refactor and remove unused elements * [Announcement bar] Add social icons (Shopify#2497) * Rename announcement-bar to utility-bar section. Add basic logic for social-icons in the utility-bar. * Remove social icons from the utility bar for tablet Remove social icons snippet * Prevent auto-rotation after users interact with arrow buttons. Change the slider width for screens wider than 1200px. Rename back a file name from utility-bar to announcement-bar. * Prevent auto-rotation for mobile. Reduce social icons sizes for in the utility bar. Change grid system. * Prevent showing bottom-border when the utility bar is empty. * Add layout for screens under 1200px. * Adjust a separater line for max-width: 1199px * Revert announcement-bar name. Remove additional layout for desktop under 1120px. Remove JS logic. * Minor changes. * Refactor of css classes. Refactor of liquid logic. Use social-icons as a snippet. * Refactor in social-icons snippet. Change the naming in css accordingly BEM. * Update 14 translation files * Update 6 translation files * Change label for show_social. * Update 15 translation files * Update 5 translation files --------- Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> * Use live region to announce recipient form (Shopify#2672) * Use live region to announce recipient form * Inject text instead of toogling aria-hidden * Announce form collapsed when checkbox unticked * Update 20 translation files * Update 4 translation files * Update 6 translation files --------- Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> * Safari fix and addressing feadback * Correct typo * Remove unnecessary code * Prevent applying animation when you scroll * Remove console.log * Refactoring --------- Co-authored-by: Ludo <[email protected]> Co-authored-by: translation-platform[bot] <34770790+translation-platform[bot]@users.noreply.github.com> Co-authored-by: Fred Ma <[email protected]>
PR Summary:
This PR adds animation for slides in the announcement bar.
Why are these changes introduced?
Fixes #2550.
What approach did you take?
scroll-behavior:
fromsmooth
toauto
to prevent the current way of visual animation.Other considerations
Visual impact on existing themes
Before
After
Testing steps/scenarios
Demo links
Checklist