Hey @michaellee2245! Simple fix here, we just need to recalculate after the images are loaded.
<script>
window.fsAttributes = window.fsAttributes || [];
window.fsAttributes.push([
'cmsload',
(listInstances) => {
console.log('cmsload Successfully loaded!');
const [listInstance] = listInstances;
let macyInstance = Macy({
container: '#macy-container',
margin: {
x: 24,
y: 24,
},
columns: 4,
breakAt: {
1200: 4,
991: 3,
767: 2,
479: 1,
},
});
const cursorInit = function () {
// Custom Cursor Element
$(
'a, .gallery_copy-btn, .swiper-btn-prev, .swiper-btn-next, .about_team-bio_btn, .gallery-filter-wrapper, .pr__form-submit_btn, .footer_form-submit-btn, .lightbox-modal-close, .play-button-wrapper, .contact_wrapper'
).on('mouseenter', function () {
$('.cursor_dot-wrapper').addClass('is--smaller');
//$('.cursor_dot-inner').addClass('is--larger');
});
$(
'a, .gallery_copy-btn, .swiper-btn-prev, .swiper-btn-next, .about_team-bio_btn, .gallery-filter-wrapper, .pr__form-submit_btn, .footer_form-submit-btn, .lightbox-modal-close, .play-button-wrapper, .contact_wrapper'
).on('mouseleave', function () {
$('.cursor_dot-wrapper').removeClass('is--smaller');
//$('.cursor_dot-inner').removeClass('is--larger');
});
};
const gsapInit = function () {
const clipEl = $(this).find("[data-btn='clip']").attr('aria-hidden', 'true');
const durationSetting = 0.4;
const easeSetting = 'power2.out';
const getPercentTop = (el, e) => {
let elTop = el.offset().top - $(window).scrollTop();
let mouseTop = e.pageY - $(window).scrollTop() - elTop;
return (mouseTop / el.innerHeight()) * 100;
};
const getPercentLeft = (el, e) => {
let elLeft = el.offset().left;
let mouseLeft = e.pageX - elLeft;
return (mouseLeft / el.innerWidth()) * 100;
};
$(this).on('mouseenter', function (e) {
let percentTop = getPercentTop($(this), e);
let percentLeft = getPercentLeft($(this), e);
gsap.set(clipEl, { display: 'flex' });
gsap.fromTo(
clipEl,
{ clipPath: `circle(0% at ${percentLeft}% ${percentTop}%)` },
{
clipPath: `circle(141.4% at ${percentLeft}% ${percentTop}%)`,
duration: durationSetting,
ease: easeSetting,
}
);
});
$(this).on('mouseleave', function (e) {
let percentTop = getPercentTop($(this), e);
let percentLeft = getPercentLeft($(this), e);
gsap.to(clipEl, {
clipPath: `circle(0% at ${percentLeft}% ${percentTop}%)`,
overwrite: true,
duration: durationSetting,
ease: easeSetting,
});
});
};
// Button Clip Path Hover
$("[data-btn='wrap']").each(gsapInit);
macyInstance.runOnImageLoad(function () {
macyInstance.recalculate(true);
}, true);
listInstance.on('renderitems', (renderedItems) => {
console.log(renderedItems);
$("[data-btn='wrap']").each(gsapInit);
$("[data-btn='wrap']").each(cursorInit);
macyInstance.runOnImageLoad(function () {
macyInstance.recalculate(true);
}, true);
});
},
]);
</script>
Can you test this code please?
I just added an extra
macyInstance.runOnImageLoad(function () {
macyInstance.recalculate(true);
}, true);
after the gsapInit