-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Slideshow] Add fixed position background #2346
Conversation
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.
Not working for me unfortunately. I would be OK to use a background-image
in this case - we can make it responsive using either several divs or the newish image-set CSS function. We will need to add some stuff for a11y if we go that route.
Not working for me either. Both Chrome & Safari. No fixed background effect appearing |
I pushed a new commit that uses In regards to accessibility, I retained the original image and just hid it using one of the WebAIM-recommended techniques. This is one approach for exposing the image to screen readers. The other I know of would be to remove the (The PR description above still outlines about the initial version — I can update next week.) |
Hey 👋 Just seen this issue and thought I'd toss in my two cents from a support perspective 🪙 🪙 For the css property background-attachment: fixed; that is being proposed, there are limitations with it's usage in Safari on iOS. When this property is used, it often creates frustration and/or confusion for merchants which we tend to see in tickets escalated to Theme Support. A current example within Dawn is where the fixed gradient doesn't get applied to the header or footer on mobile and iPad. In a previous review, we found that this particular issue made up ~5% of issue tickets that had been escalated to our team. I suspect the fixed image effect would be more popular than the gradient and as a result, create more support debt - just something to consider if implementing. A similar effect was previously used in the Narrative theme that caused a lot of frustration for merchants at the time and to overcome the Safari issue on iOS, a function was added to the js to check the device and a class as a fallback. I don't believe it solved the problem as there were still further issues reported and it's implementation goes against the zero js principle but thought I'd share for some added context. |
@@ -117,6 +117,23 @@ | |||
#Slide-{{ section.id }}-{{ forloop.index }} .banner__media::after { | |||
opacity: {{ block.settings.image_overlay_opacity | divided_by: 100.0 }}; | |||
} | |||
{%- if section.settings.image_behavior == 'fixed' -%} | |||
#Slide-{{ section.id }}-{{ forloop.index }} .animate--fixed { | |||
background: url("{{ block.settings.image | image_url: width: 3840 }}") center no-repeat; |
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.
Are we sure we always want this size for the image?
background-size: cover; | ||
background-attachment: fixed; | ||
} | ||
#Slide-{{ section.id }}-{{ forloop.index }} .animate--fixed img { |
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.
Are these sr-only
styles? We should create a class in base.css
, maybe right where we have our visually-hidden
class. It would make it obvious what this is, as sr-only
is a widely used and familiar class name and we could make use of it 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.
Tested this on Safari, Firefox, Edge, Chrome, with different breakpoints. It seems to work fine for me!
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.
Thank you! It behaves as expected from a UX perspective.
Small finds
- The focal point is not preserved (Video reference)
- The Image slide placeholder illustration background changes as you select from None to the new setting. (Video reference)
@@ -2923,6 +2923,18 @@ | |||
"change_slides_speed": { | |||
"label": "Change slides every" | |||
}, | |||
"animations": { | |||
"content": "Animations" |
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.
Localization quality issue found
The following issues may affect the quality of localized translations if they are not addressed:
- The value
Animations
for keysections.slideshow.settings.animations.content
is very short. Short strings are more likely to be misunderstood by translators without context. Please provide additional context for the translators if possible.
Please look out for other instances of this issue in your PR and fix them as well if possible.
Questions about these messages? Hop in the #help-localization Slack channel.
}, | ||
"image_behavior": { | ||
"options__1": { | ||
"label": "None" |
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.
Localization quality issue found
The following issues may affect the quality of localized translations if they are not addressed:
- The value
None
for keysections.slideshow.settings.image_behavior.options__1.label
is very short. Short strings are more likely to be misunderstood by translators without context. Please provide additional context for the translators if possible.
Please look out for other instances of this issue in your PR and fix them as well if possible.
Questions about these messages? Hop in the #help-localization Slack channel.
"options__2": { | ||
"label": "Fixed background position" | ||
}, | ||
"label": "Image behavior" |
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.
Localization quality issue found
The following issues may affect the quality of localized translations if they are not addressed:
- The value
Image behavior
for keysections.slideshow.settings.image_behavior.label
is very short. Short strings are more likely to be misunderstood by translators without context. Please provide additional context for the translators if possible.
Please look out for other instances of this issue in your PR and fix them as well if possible.
Questions about these messages? Hop in the #help-localization Slack channel.
Closing this as it's inactive/old. |
PR Summary:
Adds a fixed position background option to the Slideshow section.
fixed-position.mp4
Why are these changes introduced?
Closes #2345.
What approach did you take?
This implements a new dropdown menu as shown in the ticket. When "Fixed background position" is selected, a CSS class is applied to the media elements within the Slideshow slides. This class sets the position of the media element to
fixed
, and usesclip-path(0)
on the parent to ensure the image doesn't bleed outside of its intended container.The CSS for this is defined in
base.css
so that we can theoretically reuse it for the Image with Text (#2340) and Image Banner (#2341) sections.Other considerations
⚠ We may want to re-evaluate this approach, since it's causing some issues in Chrome. Sometimes, the pseudo element and/or slideshow content doesn't appear correctly when you scroll into it or advance onto the next slide. Scrolling a little or moving the mouse near the slideshow fixes this. From what I can infer, this is related to the use of
clip-path
. These issues are not present in Safari or Firefox. 😞If for some reason this approach falls through, we could also explore setting the
background-image
of the media container, and usingbackground-attachment: fixed
. This should avoid the issues, but is far more verbose and likely less performant, as it eliminates the ability for us to usesrcset
. 😕📹 Example
28-33-mid8y-50ej0.mp4
Visual impact on existing themes
None. This is an optional feature.
Testing steps/scenarios
Checklist