Hello,
I am trying to figure out a way to make the review section on my homepage auto rotate, but there isn’t an option for this in the theme settings. I’m wondering how I can do this in the theme code. Thanks in advance!
Website: https://chinchileproducts.com
Thanks,
Tony
Hi @ChinChile ,
Please paste below script code in your
online store → edit code → assest - > empire.js
Put below code at very end of the JS file
document.addEventListener("DOMContentLoaded", function(event) {
var direction = 0;
setInterval(function(){
console.log(direction,"direction");
if(direction == 0){
var _next = document.querySelector(".flickity-button.next").hasAttribute("disabled");
console.log(1,"next",_next);
if(_next === false){
document.querySelector(".flickity-button.next").click()
}else{
direction = 1
}
}
if(direction == 1){
console.log(2,"next");
var _next = document.querySelector(".flickity-button.previous").hasAttribute("disabled");
if(_next === false){
document.querySelector(".flickity-button.previous").click()
}else{
direction = 0
}
}
},5000)
});
Hope it will help…
Hi @gr_trading ,
Thank you for the reply. I added the code and it was working on desktop, but on mobile it was affecting the featured collection instead of the testimonial section.
Hi @ChinChile ,
Please find the updated script
document.addEventListener("DOMContentLoaded", function(event) {
var direction = 0;
setInterval(function(){
console.log(direction,"direction");
if(direction == 0){
var _next = document.querySelector(".testimonials .flickity-button.next").hasAttribute("disabled");
console.log(1,"next",_next);
if(_next === false){
document.querySelector(".testimonials .flickity-button.next").click()
}else{
direction = 1
}
}
if(direction == 1){
console.log(2,"next");
var _next = document.querySelector(".testimonials .flickity-button.previous").hasAttribute("disabled");
if(_next === false){
document.querySelector(".testimonials .flickity-button.previous").click()
}else{
direction = 0
}
}
},5000);
})
1 Like