wpamirhosseinmohammadi / WPami

0 stars 0 forks source link

Problem Barba JS And Elementor #1

Open wpamirhosseinmohammadi opened 2 hours ago

wpamirhosseinmohammadi commented 2 hours ago

Hello I have a problem with Elementor and Barba Js, and that is that when the page is changed, the Elementor styles do not work, that is, only for the first time when the page is opened, there is a style, and when the Barba Js page is changed, no style is read, I mean the Elementor styles. Where is the problem? ` document.addEventListener('DOMContentLoaded', function () {

barba.init({

    timeout:4000,
    transitions: [
        {
            name: 'fade-transition',
            leave(data) {

                return gsap.to(data.current.container, {
                    opacity: 0,
                    duration: 0.5,
                });
            },
            enter(data) {

                return gsap.from(data.next.container, {
                    opacity: 0,
                    duration: 0.5,
                });
            },
        },
    ],
    views: [
        {
            namespace: 'home', // namespace پیش‌فرض
            beforeEnter() {

                if (typeof elementorFrontend !== 'undefined') {
                    elementorFrontend.init();
                }
            },
        },
    ],
});

barba.hooks.after(() => {
    if (typeof elementorFrontend !== 'undefined') {
        elementorFrontend.init(); // بازنشانی انیمیشن‌های المنتور
    }
});

barba.hooks.beforeLeave(() => {
    document.querySelectorAll('a').forEach(link => {
        const href = link.getAttribute('href');
        if (href && href.startsWith('#')) {
            link.setAttribute('data-barba-prevent', 'all');
        }
    });
});

});

` @Ihatetomatoes

wpamirhosseinmohammadi commented 2 hours ago

@Ihatetomatoes Thank you for helping me