Javad
Javad

Reputation: 178

OwlCarousel load after page dom or images load

I have a page with some sections. Any section have some OwlCarouse.When menu items anchor to sections (http://site/index.html#section), page scrolled to first of section position but when I copy link into another tab, position changed.

I think the problem is related to OwlCarousel jQuery loading. How to load it after page loading?

Upvotes: 0

Views: 2928

Answers (2)

Javad
Javad

Reputation: 178

    if ( window.location.hash ) scroll(0,0);
    setTimeout( function() { scroll(0,0); }, 1);

    $(function() {

        if(window.location.hash) {
            $('html, body').animate({
                scrollTop: $(window.location.hash).offset().top + 'px'
            }, 1000, 'swing');
        }
    });

Upvotes: 1

Developer107
Developer107

Reputation: 1758

Try initializing owl carousel after window is loaded:

$("window").load(function(){
  // initialize owl carousel
})

Upvotes: 0

Related Questions