diff --git a/animator.cpp b/animator.cpp index 4ae9fa6ee..b77eea33b 100644 --- a/animator.cpp +++ b/animator.cpp @@ -282,13 +282,14 @@ int Animator::animateItem(QGraphicsItem* item, Animation animation) return -1; } + int duration = d->driver->animationDuration(animation); + AnimationState* state = new AnimationState; state->id = ++d->animId; state->item = item; state->animation = animation; state->curve = d->driver->animationCurve(animation); - //TODO: variance in times based on the value of animation - state->frames = frames / 3; + state->frames = qMax(1.0, frames * (duration / 1000.0)); state->currentFrame = 0; state->interval = d->driver->animationDuration(animation) / qreal(state->frames); state->interval = qMax(MIN_TICK_RATE_INT, state->interval - (state->interval % MIN_TICK_RATE_INT)); @@ -337,7 +338,7 @@ int Animator::moveItem(QGraphicsItem* item, Movement movement, const QPoint &des state->curve = d->driver->movementAnimationCurve(movement); //TODO: variance in times based on the value of animation int duration = d->driver->movementAnimationDuration(movement); - state->frames = (duration / 1000.0) * frames; + state->frames = qMax(1.0, frames * (duration / 1000.0)); state->currentFrame = 0; state->interval = duration / qreal(state->frames); state->interval = qMax(MIN_TICK_RATE_INT, state->interval - (state->interval % MIN_TICK_RATE_INT)); @@ -441,14 +442,16 @@ void Animator::stopItemMovement(int id) int Animator::animateElement(QGraphicsItem *item, Animation animation) { //kDebug() << "startElementAnimation(AnimId " << animation << ")"; + int frames = d->driver->elementAnimationFps(animation); + int duration = d->driver->animationDuration(animation); + ElementAnimationState *state = new ElementAnimationState; state->item = item; state->curve = d->driver->elementAnimationCurve(animation); state->animation = animation; - //TODO: variance in times based on the value of animation - state->frames = d->driver->elementAnimationFps(animation) / 5; + state->frames = qMax(1.0, frames * (duration / 1000.0)); state->currentFrame = 0; - state->interval = d->driver->elementAnimationDuration(animation) / qreal(state->frames); + state->interval = duration / qreal(state->frames); state->interval = qMax(MIN_TICK_RATE_INT, state->interval - (state->interval % MIN_TICK_RATE_INT)); state->currentInterval = state->interval; state->id = ++d->animId;