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

[Announcement Bar] Auto-rotate fixes #2810

Merged
merged 7 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update auto-rotate for the announcement bar
  • Loading branch information
kjellr committed Jul 10, 2023
commit 4c47e1bef9bab6a404cd8f48725f267094a00759
5 changes: 5 additions & 0 deletions assets/component-slideshow.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ slideshow-component .slideshow.banner {
position: relative;
display: flex;
flex-direction: column;
visibility: visible;
}

.slideshow__slide--hidden {
visibility: hidden;
}

@media screen and (max-width: 749px) {
Expand Down
15 changes: 6 additions & 9 deletions assets/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -735,13 +735,9 @@ class SlideshowComponent extends SliderComponent {
if (this.announcementBarSlider) {
this.announcementBarArrowButtonWasClicked = false;

this.desktopLayout = window.matchMedia('(min-width: 750px)');
this.reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');

[this.reducedMotion, this.desktopLayout].forEach((mediaQuery) => {
mediaQuery.addEventListener('change', () => {
if (this.slider.getAttribute('data-autoplay') === 'true') this.setAutoPlay();
});
this.reducedMotion.addEventListener('change', () => {
if (this.slider.getAttribute('data-autoplay') === 'true') this.setAutoPlay();
});

[this.prevButton, this.nextButton].forEach((button) => {
Expand Down Expand Up @@ -771,7 +767,7 @@ class SlideshowComponent extends SliderComponent {
this.autoplayButtonIsSetToPlay = true;
this.play();
} else {
this.reducedMotion.matches || this.announcementBarArrowButtonWasClicked || !this.desktopLayout.matches
this.reducedMotion.matches || this.announcementBarArrowButtonWasClicked
? this.pause()
: this.play();
}
Expand Down Expand Up @@ -839,8 +835,7 @@ class SlideshowComponent extends SliderComponent {
this.play();
} else if (
!this.reducedMotion.matches &&
!this.announcementBarArrowButtonWasClicked &&
this.desktopLayout.matches
!this.announcementBarArrowButtonWasClicked
) {
this.play();
}
Expand Down Expand Up @@ -900,13 +895,15 @@ class SlideshowComponent extends SliderComponent {
button.removeAttribute('tabindex');
});
item.setAttribute('aria-hidden', 'false');
item.classList.remove('slideshow__slide--hidden');
item.removeAttribute('tabindex');
} else {
if (linkElements.length)
linkElements.forEach((button) => {
button.setAttribute('tabindex', '-1');
});
item.setAttribute('aria-hidden', 'true');
item.classList.add('slideshow__slide--hidden');
item.setAttribute('tabindex', '-1');
}
});
Expand Down
2 changes: 1 addition & 1 deletion locales/en.default.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@
"name": "Announcement bar",
"settings": {
"auto_rotate": {
"label": "Auto-rotate on desktop"
"label": "Auto-rotate announcements"
kjellr marked this conversation as resolved.
Show resolved Hide resolved
},
"change_slides_speed": {
"label": "Change every"
Expand Down
Loading