Query if class is already shown

89 Views Asked by At

Hello I need to be able to identify if a given class is already "faded in":

private void fadeIn() {
        // TODO: Check first if class is already shown! otherwise, don't run this as it fade's out when it is run over a already faded in class
        $(".hopscotch-bubble").fadeIn(new com.google.gwt.query.client.Function() {
            @Override
            public void f() {
                JSNIHelper.infoNotify("INFO", "Fade in method invoked.");
            }
        });
    }

How do I do that?

2

There are 2 best solutions below

0
Manolo Carrasco Moñino On BEST ANSWER

gwtquery fadeIn finishes showing a hidden element so $(selector).visible() should return whether the element is visible.

But normally, if you want to take care of not running two animations, the normal way in gquery and jquery is stop all pending animations.

$(selector).stop(true).fadeIn(...);
0
Bhojendra Rauniyar On

I don't know java anyway the concept is to assign a variable and check that variable is true and if true call the function something like below:

private void fadeIn() {
        // TODO: Check first if class is already shown! otherwise, don't run this as it fade's out when it is run over a already faded in class
var faded = 1;
if(faded){ 
faded = 0;       
$(".hopscotch-bubble").fadeIn(new com.google.gwt.query.client.Function() {
            @Override
            public void f() {
                JSNIHelper.infoNotify("INFO", "Fade in method invoked.");
            }
        });
    }

}