javascript - jQuery animation works with only one element -
i need make working elements under nothing should fade (images).
currently works
div.logo
tag
i guess @ moment reason mine <h1>
element allowing animations underneath when getting .top()
, .left()
, on, doing last element in list.
i need borders of each element in resulting list.
any appreciated
demo: http://jsfiddle.net/z9b8s/
js:
function displaythese(selectorstring) { var $heading = $(selectorstring); var h1top = $heading.position().top; var h1bottom = h1top + $heading.height(); var h1left = $heading.position().left; var h1right = h1top + $heading.width(); var divs = $('li').filter(function () { var $e = $(this); var top = $e.position().top; var bottom = top + $e.height(); var left = $e.position().left; var right = left + $e.width(); return top > h1bottom || bottom < h1top || left > h1right || right < h1left; }); return divs; } (function fadeindiv() { var divstochange = displaythese('h1, div.logo'); var elem = divstochange.eq(math.floor(math.random() * divstochange.length)); if (!elem.is(':visible')) { elem.prev().remove(); elem.animate({ opacity: 1 }, math.floor(math.random() * 1000), fadeindiv); } else { elem.animate({ opacity: (math.random() * 1) }, math.floor(math.random() * 1000), function () { window.settimeout(fadeindiv); }); } })(); $(window).resize(function () { // items not change var divs = $('li').not(displaythese()); divs.css({ opacity: 0.3 }); });
Comments
Post a Comment