jquery - Run javascript autoscroll function after page full load -
jquery - Run javascript autoscroll function after page full load -
i have functionality on page should auto-scroll javascript when url matches:
$(window).load(function () { if (window.location.href.indexof("something-on-url") > -1) { $("html,body").animate({ scrolltop: $("#specificdiv").offset().top }, 300); }
the problem have carousel of images @ top of page, , takes while until loaded, makes autoscroll before carousel there (the carousel height not taken count it's autoscrolling many pixels should minus carousel height).
i've tried document.ready()
instead of $(window).load
, same result. i've tried adding picture/carousel height, if go img.height()
, give me "0" @ time, , hardcoded it's not alternative since mobile responsive site. i've tried using .onload()
img tag in carousel , on carousel tags, doesn't trigger autoscroll (never).
only thing working far, it's delay scroll function settimeout()
, depending on user may load carousel slower, safe settimeout()
long cases.
i found prepare looking carousel documentation comment of user workabyte. how looks now:
$(window).load(function () { if (window.location.href.indexof("something-on-url") > -1) { $(".orbit-slides-container").one("orbit:before-slide-change", function () { $("html,body").animate({ scrolltop: $("#specificdiv").offset().top }, 200); }); }
the orbit:before-slide-change
event orbit api (http://foundation.zurb.com/docs/v/4.3.2/components/orbit.html). there event supposedly triggered when carousel loaded, orbit:ready
, didn't work me.
javascript jquery onload pageload autoscroll
Comments
Post a Comment