Queue an animation for an element.

The goal of this method is to reuse animations.
@param e
@param anim
@param duration
177918
public void queueAnimation(final GQAnimation anim, final int duration) {
    if (isOff()) {
      anim.onStart();
      anim.onComplete();
    } else {
      queue(anim.e, DEFAULT_NAME, new Function() {
        public void cancel(Element e) {
          Animation anim = (Animation) data(e, GQAnimation.ACTUAL_ANIMATION, null);
          if (anim != null) {
            anim.cancel();
          }
        }

        public void f(Element e) {
          anim.run(duration);
        }
      });
    }
  }
1349533
public void drawAnimation(Animation anim, float x, float y) {
		drawAnimation(anim, x, y, Color.white);
	}
482665
function (animId) {
                var animInfo = this.animations[animId];
                if (animInfo) {
                    if (animInfo.isRunning) {
                        this._finalizeAnimation(this.animations[animId], true);
                    } else {
                        delete this.animations[animId];
                        if (animInfo.queue) {
                            var queueOrder = ariaUtilsArray.indexOf(this.queues[animInfo.queue].list, animInfo);
                            this.queues[animInfo.queue].list.splice(queueOrder, 1);
                        }
                    }
                    return true;
                }
                return false;
            }
33581
public void setCurrentItemShowing(int index, boolean animate) {
        if (index != HOUR_INDEX && index != MINUTE_INDEX) {
            Log.e(TAG, "TimePicker does not support view at index " + index);
            return;
        }

        int lastIndex = getCurrentItemShowing();
        mCurrentItemShowing = index;

        if (animate && (index != lastIndex)) {
            ObjectAnimator[] anims = new ObjectAnimator[4];
            if (index == MINUTE_INDEX) {
                anims[0] = mHourRadialTextsView.getDisappearAnimator();
                anims[1] = mHourRadialSelectorView.getDisappearAnimator();
                anims[2] = mMinuteRadialTextsView.getReappearAnimator();
                anims[3] = mMinuteRadialSelectorView.getReappearAnimator();
            } else if (index == HOUR_INDEX) {
                anims[0] = mHourRadialTextsView.getReappearAnimator();
                anims[1] = mHourRadialSelectorView.getReappearAnimator();
                anims[2] = mMinuteRadialTextsView.getDisappearAnimator();
                anims[3] = mMinuteRadialSelectorView.getDisappearAnimator();
            }

            if (mTransition != null && mTransition.isRunning()) {
                mTransition.end();
            }
            mTransition = new AnimatorSet();
            mTransition.playTogether(anims);
            mTransition.start();
        } else {
            int hourAlpha = (index == HOUR_INDEX) ? 255 : 0;
            int minuteAlpha = (index == MINUTE_INDEX) ? 255 : 0;
            mHourRadialTextsView.setAlpha(hourAlpha);
            mHourRadialSelectorView.setAlpha(hourAlpha);
            mMinuteRadialTextsView.setAlpha(minuteAlpha);
            mMinuteRadialSelectorView.setAlpha(minuteAlpha);
        }

    }
453555
public void showWithAnimationWithListener(Animator.AnimatorListener animatorListener) {
		scrollDirection = SCROLL_TO_TOP;
		ObjectAnimator objectAnimator = objectAnimatorFactory.getObjectAnimator(animatedView, ANIMATION_TYPE, HIDDEN_Y_POSITION);
		if (animatorListener != null) {
			objectAnimator.addListener(animatorListener);
		}
		objectAnimator.setDuration(durationInMillis);
		objectAnimator.start();
	}
289662
public final void setDuration(int duration) {
        if (isComplete()) {
            this.getLogger()
                    .warn(
                            "{} is already closed, the new duration of {} will be ignored on: {}",
                            this.getClass().getSimpleName(),
                            duration,
                            this);
            return;
        }
        this.duration = duration;
    }
432433
public void setContentViewExitAnimation(int anim) {
        contentExitAnimation = AnimationUtils.loadAnimation(
                mTrigger.getContext(), anim);
        contentExitAnimation.setAnimationListener(mExitAnimationListener);
    }
398454
function(duration) {
    $("#header").addClass("timer");
    $("#timer").show().animate({width: "100%"}, duration, function() {
      $("#header").removeClass("timer");
      $("#timer").hide().css({width: "0"});
    });
  }
776039
public static final <T extends UIObject> void stopAnimation(final T widget, final String animation){
        if (widget != null && animation != null) {
            stopAnimation(widget.getElement(), animation);
        }
    }
1099929
@ReflectiveAccess
    protected void setInterval(String interval) {
        this.interval = ConversionService.SHARED.convert(interval, Duration.class).orElseThrow(() -> new IllegalArgumentException("Invalid Duration Specified"));
    }
648566
function Animation(duration, timingFunction, frames) {
    var defer;

    var frameQueue = getFrameQueue(duration, frames);
    var framePercent = 1 / (duration / INTERVAL);
    var frameIndex = 0;

    var bezier = getBezier(timingFunction);

    if (!bezier) {
        throw new Error('unexcept timing function');
    }

    var currentFrame;

    var isPlaying = false;
    /**
     * 播放动画
     * @method play
     * @return {lib.animation~Animation} this 当前实例
     * @instance
     * @memberOf lib.animation~Animation
     */
    this.play = function() {
        if (isPlaying) return;
        isPlaying = true;

        if (!defer) {
            defer = PromiseDefer();
            PromiseMixin(defer.promise, this);
        }

        function request() {
            var percent = framePercent * (frameIndex + 1).toFixed(10);
            var currentFrame = frameQueue[frameIndex];

            currentFrame
                .request(percent.toFixed(10), timingFunction(percent).toFixed(10))
                .then(function() {
                    if (!isPlaying) return;

                    if (frameIndex === frameQueue.length - 1) {
                        isPlaying = false;
                        defer && defer.resolve('FINISH');
                        defer = null;
                    } else {
                        frameIndex++;
                        request();
                    }
                }, function() {
                    // CANCEL
                });
        }

        request();
        return this;
    }

    /**
     * 暂停动画
     * @method stop
     * @return {lib.animation~Animation} this 当前实例
     * @instance 
     * @memberOf lib.animation~Animation
     */
    this.stop = function() {
        if (!isPlaying) return;
        isPlaying = false;

        if (frameQueue[frameIndex]) {
            frameQueue[frameIndex].cancel();
        }

        return this;
    }
}
1209291
@Override
	public void registerAnimation(NavigationAnimation animation) {
		// boolean cancelSupport = configuration.getHintValue(MapConfiguration.ANIMATION_CANCEL_SUPPORT);
		// if (!cancelSupport && currentAnimation != null) {
		// return;
		// }

		if (currentAnimation != null) {
			currentAnimation.cancel();
		}
		this.currentAnimation = animation;

		// Schedule the animation from the moment the browser event loop returns:
		Scheduler.get().scheduleDeferred(new ScheduledCommand() {

			@Override
			public void execute() {
				if (currentAnimation != null) {
					if (Dom.isTransformationSupported()) {
						currentAnimation.run();
					} else {
						applyView(currentAnimation.getEndView());
						currentAnimation = null;
					}
				}
			}
		});
	}
130620
public void animateContentViewRotationY(float degree, float alpha,
                                            Animator.AnimatorListener listener,
                                            int duration) {

        if (DBG) Log.v(TAG, "animateContentViewRotationY - " +
                       "degree=" + degree + ", alpha=" + alpha);

        mContentView.animate().cancel();
        mContentView.animate()
            .alpha(alpha)
            .rotationY(degree)
            .setListener(listener)
            .setDuration(duration)
            .start();
    }
1229035
protected void animate(int translationY) {
		ObjectAnimator animator = objectAnimatorFactory.getObjectAnimator(animatedView, ANIMATION_TYPE, translationY);
		animator.setDuration(durationInMillis);
		animator.start();
	}
43854
function (end, queue) {
            var self = this;
            util.each(self, function (elem) {
                Anim.pause(elem, queue);
            });
            return self;
        }
484471
function (elem, animDuration) {
            var self = this;
            var mapElemBBox;
            var plotOffsetX;
            var plotOffsetY;

            if (elem.options.toFront === true) {
                elem.mapElem.toFront();
            }

            // Set the cursor attribute related to the HTML link
            if (elem.options.href !== undefined) {
                elem.options.attrs.cursor = "pointer";
                if (elem.options.text) elem.options.text.attrs.cursor = "pointer";
            } else {
                // No HTML links, check if a cursor was defined to pointer
                if (elem.mapElem.attrs.cursor === 'pointer') {
                    elem.options.attrs.cursor = "auto";
                    if (elem.options.text) elem.options.text.attrs.cursor = "auto";
                }
            }

            // Update the label
            if (elem.textElem) {
                // Update text attr
                elem.options.text.attrs.text = elem.options.text.content;

                // Get mapElem size, and apply an offset to handle future width/height change
                mapElemBBox = elem.mapElem.getBBox();
                if (elem.options.size || (elem.options.width && elem.options.height)) {
                    if (elem.options.type === "image" || elem.options.type === "svg") {
                        plotOffsetX = (elem.options.width - mapElemBBox.width) / 2;
                        plotOffsetY = (elem.options.height - mapElemBBox.height) / 2;
                    } else {
                        plotOffsetX = (elem.options.size - mapElemBBox.width) / 2;
                        plotOffsetY = (elem.options.size - mapElemBBox.height) / 2;
                    }
                    mapElemBBox.x -= plotOffsetX;
                    mapElemBBox.x2 += plotOffsetX;
                    mapElemBBox.y -= plotOffsetY;
                    mapElemBBox.y2 += plotOffsetY;
                }

                // Update position attr
                var textPosition = self.getTextPosition(mapElemBBox, elem.options.text.position, elem.options.text.margin);
                elem.options.text.attrs.x = textPosition.x;
                elem.options.text.attrs.y = textPosition.y;
                elem.options.text.attrs['text-anchor'] = textPosition.textAnchor;

                // Update text element attrs and attrsHover
                self.setHoverOptions(elem.textElem, elem.options.text.attrs, elem.options.text.attrsHover);

                if (self.isAttrsChanged(elem.textElem.attrs, elem.options.text.attrs)) {
                    self.animate(elem.textElem, elem.options.text.attrs, animDuration);
                }
            }

            // Update elements attrs and attrsHover
            self.setHoverOptions(elem.mapElem, elem.options.attrs, elem.options.attrsHover);

            if (self.isAttrsChanged(elem.mapElem.attrs, elem.options.attrs)) {
                self.animate(elem.mapElem, elem.options.attrs, animDuration);
            }

            // Update the cssClass
            if (elem.options.cssClass !== undefined) {
                $(elem.mapElem.node).removeClass().addClass(elem.options.cssClass);
            }
        }
626186
function(element, attrs, duration, callback) {
            var self = this;
            // Check element
            if (!element) return;
            if (duration > 0) {
                // Filter out non-animated attributes
                // Note: we don't need to delete from original attribute (they won't be set anyway)
                var attrsNonAnimated = {};
                for (var i=0 ; i < self._nonAnimatedAttrs.length ; i++) {
                    var attrName = self._nonAnimatedAttrs[i];
                    if (attrs[attrName] !== undefined) {
                        attrsNonAnimated[attrName] = attrs[attrName];
                    }
                }
                // Set non-animated attributes
                element.attr(attrsNonAnimated);
                // Start animation for all attributes
                element.animate(attrs, duration, 'linear', function() {
                    if (callback) callback();
                });
            } else {
                // No animation: simply set all attributes...
                element.attr(attrs);
                // ... and call the callback if needed
                if (callback) callback();
            }
        }