samedi 27 juin 2015

fadein() not triggering but everything else is

I have this small snippet that triggers when I use socket.io:

socket.on('wheelspin', function (random) {
    var img = document.querySelector('img');
    $("img").fadeIn();
    console.log('wheelspin!!!');
    console.log('fadeIn');

        img.removeAttribute('style');
        var deg  = 0; 

        console.log('deg = ' + deg);
        console.log('Number = ' + random);
        if(random == 0) {var deg = 15; var css = '-webkit-transform: rotate(' + deg + 'deg);'; }
        img.setAttribute('style', css);
}

Whenever I run this, the webpage console displays the console.logs but it doesn't do the fadeIn. If I do the following outside the socket trigger it works:

$( document ).ready(function() {
    $("img").fadeIn();
 });

Any advice?

Thanks

Aucun commentaire:

Enregistrer un commentaire