diff options
author | Manuel Carrasco Moñino <manuel.carrasco.m@gmail.com> | 2013-12-10 13:49:39 +0100 |
---|---|---|
committer | Manuel Carrasco Moñino <manuel.carrasco.m@gmail.com> | 2013-12-10 13:49:39 +0100 |
commit | 6b0b5e9f83a81f314b0bf6219eae66294eea20d2 (patch) | |
tree | 4fba1c2eecb07d1070fc57f90fada5fc39bf223b | |
parent | d01b00ce50eb63fed97521a71eccafb804bf6c75 (diff) | |
download | gwtquery-6b0b5e9f83a81f314b0bf6219eae66294eea20d2.tar.gz gwtquery-6b0b5e9f83a81f314b0bf6219eae66294eea20d2.zip |
Using transitionend envents instead of gquery delays
-rw-r--r-- | gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transitions.java | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transitions.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transitions.java index e1479ad1..c7fe0b9b 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transitions.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/effects/Transitions.java @@ -308,9 +308,9 @@ public class Transitions extends GQuery { return this; } - final Properties p = (stringOrProperties instanceof String) ? $$((String) stringOrProperties) : (Properties) stringOrProperties; - - final String oldTransitions = css(transition); + final Properties p = (stringOrProperties instanceof String) + ? $$((String) stringOrProperties) + : (Properties) stringOrProperties; if (easing == null) { easing = EasingCurve.ease; @@ -326,23 +326,24 @@ public class Transitions extends GQuery { final String transitionValue = value; // Use gQuery queue, so as we can chain transitions, animations etc. - delay(0, new Function(){public void f() { - // This is called once per element - $(this) - // Configure animation using transition property - .css(transition, transitionValue) - // Set all css properties for this transition using the css method in this class - .as(Transitions).css(p); - }}); - - // restore oldTransitions in the element, and use the queue to prevent more effects being run. - // TODO: Use transitionEnd events once GQuery supports non-bit events - delay(duration + delay, new Function(){public void f() { - // This is called once per element - $(this).as(Transitions) - .css(transition, oldTransitions) - .each(funcs); - }}); + queue(new Function(){ + public void f() { + // This is called once per element + final String old = $(this).css(transition); + $(this) + // Configure animation using transition property + .css(transition, transitionValue) + // Set all css properties for this transition using the css method in this class + .as(Transitions).css(p) + // Bind to transitionEnd to unlock the queue and restore old transitions + .bind(transitionEnd, new Function(){ + public void f(){ + $(this).dequeue().unbind(transitionEnd); + $(this).css(transition, old); + } + }); + } + }); return this; } |