javascript - Is it possible to use animate with an attribute with jQuery? -
i want change opacity of element jquery (with fade in animation):
$(`#pano-${index}`).animate({ 'opacity': 1})
but don't result want:
<a-sky style="opacity: 1;"></a-sky>
i want accomplish this:
<a-sky opacity: 1></a-sky>
is possible jquery?
note: works ... doesn't have animation: $(#pano-${index}).attr('opacity', 1)
as starter ten, timer loop...
var opacity = 0, // starting opacity step = 0.1, // step size target = 1, // target value time = 50; // delay in milliseconds // start timer loop, , record it's index var interval = setinterval(function(){ // assuming selector works, set opacity $(`#pano-${index}`).attr({opacity: opacity}); // increment opacity step size opacity += step; // if reached our target value, stop timer if(opacity >= target){ clearinterval(interval); } }, time);
Comments
Post a Comment