Shopify themes, liquid, logos, and UX
Hi All,
How can I change my announcement bar to transition to the next rather than have them stacked underneath each other. Thanks.
Solved! Go to the solution
This is an accepted solution.
You can try adding this JavaScript code to the end of the announcement-bar.liquid file in the Sections folder. It might be what you want (It works on a recent version of Dawn theme):
<script>
let announcementIndex = 0;
showAnnouncements();
function showAnnouncements() {
let i;
let announcements = document.getElementsByClassName("announcement-bar");
console.log(announcements);
for (i = 0; i < announcements.length; i++) {
announcements[i].style.display = "none";
}
announcementIndex++;
if (announcementIndex > announcements.length) {
announcementIndex = 1;
}
announcements[announcementIndex - 1].style.display = "block";
setTimeout(showAnnouncements, 4000); // Change announcement every 4 seconds
}
</script>
Hi @LabelSource
Could you please share your store URL and password if any to check?
Hi Sagar, I have not yet published this on my site so it wont display, can i send you a link for the customise page to my shopify to see?
This is an accepted solution.
You can try adding this JavaScript code to the end of the announcement-bar.liquid file in the Sections folder. It might be what you want (It works on a recent version of Dawn theme):
<script>
let announcementIndex = 0;
showAnnouncements();
function showAnnouncements() {
let i;
let announcements = document.getElementsByClassName("announcement-bar");
console.log(announcements);
for (i = 0; i < announcements.length; i++) {
announcements[i].style.display = "none";
}
announcementIndex++;
if (announcementIndex > announcements.length) {
announcementIndex = 1;
}
announcements[announcementIndex - 1].style.display = "block";
setTimeout(showAnnouncements, 4000); // Change announcement every 4 seconds
}
</script>
Alan, thank you very much sir, works a dream!
User | RANK |
---|---|
227 | |
167 | |
66 | |
53 | |
53 |
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023