quarks
quarks

Reputation: 35276

Query if class is already shown

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?

Upvotes: 0

Views: 86

Answers (2)

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(...);

Upvotes: 1

Bhojendra Rauniyar
Bhojendra Rauniyar

Reputation: 85545

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.");
            }
        });
    }

}

Upvotes: 1

Related Questions