Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeidro committed Oct 22, 2024
2 parents 259e55d + e2bd06c commit 89b8baa
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions addons/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ module.exports = async (page, scenario, config) => {
}, scenario);
}

// Common actions
await page.evaluate(async(config) => {
// Avoid lazy css load.
document.querySelectorAll('link[rel="stylesheet"][data-onload-media][onload]').forEach((stylelink) => {
Expand All @@ -72,27 +71,27 @@ module.exports = async (page, scenario, config) => {
iframe.loading = 'eager';
});

// Slick refresh to avoid minimal changes.
if (typeof $ == 'undefined' && typeof jQuery == 'function') {
window.$ = jQuery;
}
const slickCarousels = document.querySelectorAll('.slick-slider');
slickCarousels.forEach((carousel) => {
jQuery(carousel).slick('setPosition');

// Avoid autoplay in carousels.
if (jQuery(carousel).slick('slickGetOption', 'autoplay')) {
jQuery(carousel).slick('slickSetOption', {
'autoplay': false,
if ($(carousel).slick('slickGetOption', 'autoplay')) {
$(carousel).slick('slickSetOption', {
'speed': 0,
'fade': false,
'infinite': false
}, true);
jQuery(carousel).slick('slickGoTo', 0, false);

// Sometimes slick doesn't get the changes, for these cases the
// carrousel is rebuild.
if (jQuery(carousel).slick('slickCurrentSlide') > 0) {
let options = jQuery(carousel).slick('getSlick').options;
jQuery(carousel).slick('unslick').slick(options);
}
}, false);
$(carousel).on('afterChange', function (event, slick) {
slick.slickSetOption({
'autoplay': false,
}, true);
});
}

$(carousel).slick('slickGoTo', 0, true);
});
if (slickCarousels.length > 0) {
const head = document.head || document.getElementsByTagName('head')[0];
Expand Down

0 comments on commit 89b8baa

Please sign in to comment.