From 94e9626e350487ade2617ebf0706897d77df1b17 Mon Sep 17 00:00:00 2001 From: Ray Cromwell Date: Wed, 29 Apr 2009 23:40:20 +0000 Subject: More implementations and docs --- .../src/main/java/gwtquery/client/Effects.java | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'gwtquery-core/src/main/java/gwtquery/client/Effects.java') diff --git a/gwtquery-core/src/main/java/gwtquery/client/Effects.java b/gwtquery-core/src/main/java/gwtquery/client/Effects.java index d7c42b9d..21fabb86 100644 --- a/gwtquery-core/src/main/java/gwtquery/client/Effects.java +++ b/gwtquery-core/src/main/java/gwtquery/client/Effects.java @@ -24,6 +24,75 @@ public class Effects extends GQuery { super(list); } + /** + * function( prop, speed, easing, callback ) { + var optall = jQuery.speed(speed, easing, callback); + + return this[ optall.queue === false ? "each" : "queue" ](function(){ + + var opt = jQuery.extend({}, optall), p, + hidden = this.nodeType == 1 && jQuery(this).is(":hidden"), + self = this; + + for ( p in prop ) { + if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) + return opt.complete.call(this); + + if ( ( p == "height" || p == "width" ) && this.style ) { + // Store display property + opt.display = jQuery.css(this, "display"); + + // Make sure that nothing sneaks out + opt.overflow = this.style.overflow; + } + } + + if ( opt.overflow != null ) + this.style.overflow = "hidden"; + + opt.curAnim = jQuery.extend({}, prop); + + jQuery.each( prop, function(name, val){ + var e = new jQuery.fx( self, opt, name ); + + if ( /toggle|show|hide/.test(val) ) + e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); + else { + var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/), + start = e.cur(true) || 0; + + if ( parts ) { + var end = parseFloat(parts[2]), + unit = parts[3] || "px"; + + // We need to compute starting value + if ( unit != "px" ) { + self.style[ name ] = (end || 1) + unit; + start = ((end || 1) / e.cur(true)) * start; + self.style[ name ] = start + unit; + } + + // If a +=/-= token was provided, we're doing a relative animation + if ( parts[1] ) + end = ((parts[1] == "-=" ? -1 : 1) * end) + start; + + e.custom( start, end, unit ); + } else + e.custom( start, val, "" ); + } + }); + + // For JS strict compliance + return true; + }); + }, + * @return + */ + public Effects animate(Properties props, String speed, String easing, + Function callback) { + return this; + } + public Effects fadeOut() { Animation a = new Animation() { -- cgit v1.2.3