コード例 #1
0
void AnimationEffectTiming::duration(UnrestrictedDoubleOrString& returnValue)
{
    if (std::isnan(m_parent->specifiedTiming().iterationDuration))
        returnValue.setString("auto");
    else
        returnValue.setUnrestrictedDouble(m_parent->specifiedTiming().iterationDuration * 1000);
}
コード例 #2
0
void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String& animationId, double duration, double delay)
{
    Animation* animation = assertAnimation(errorString, animationId);
    if (!animation)
        return;

    AnimationType type = m_idToAnimationType.get(animationId);
    if (type == AnimationType::CSSTransition) {
        KeyframeEffect* effect = toKeyframeEffect(animation->effect());
        KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->model());
        const AnimatableValueKeyframeEffectModel* oldModel = toAnimatableValueKeyframeEffectModel(model);
        // Refer to CSSAnimations::calculateTransitionUpdateForProperty() for the structure of transitions.
        const KeyframeVector& frames = oldModel->getFrames();
        ASSERT(frames.size() == 3);
        KeyframeVector newFrames;
        for (int i = 0; i < 3; i++)
            newFrames.append(toAnimatableValueKeyframe(frames[i]->clone().get()));
        // Update delay, represented by the distance between the first two keyframes.
        newFrames[1]->setOffset(delay / (delay + duration));
        model->setFrames(newFrames);

        AnimationEffectTiming* timing = animation->effect()->timing();
        UnrestrictedDoubleOrString unrestrictedDuration;
        unrestrictedDuration.setUnrestrictedDouble(duration + delay);
        timing->setDuration(unrestrictedDuration);
    } else if (type == AnimationType::WebAnimation) {
        AnimationEffectTiming* timing = animation->effect()->timing();
        UnrestrictedDoubleOrString unrestrictedDuration;
        unrestrictedDuration.setUnrestrictedDouble(duration);
        timing->setDuration(unrestrictedDuration);
        timing->setDelay(delay);
    }
}
コード例 #3
0
void AnimationEffect::getComputedTiming(ComputedTimingProperties& computedTiming)
{
    // ComputedTimingProperties members.
    computedTiming.setEndTime(endTimeInternal() * 1000);
    computedTiming.setActiveDuration(activeDurationInternal() * 1000);

    if (ensureCalculated().isInEffect) {
        computedTiming.setLocalTime(ensureCalculated().localTime * 1000);
        computedTiming.setProgress(ensureCalculated().progress);
        computedTiming.setCurrentIteration(ensureCalculated().currentIteration);
    } else {
        computedTiming.setLocalTimeToNull();
        computedTiming.setProgressToNull();
        computedTiming.setCurrentIterationToNull();
    }

    // KeyframeEffectOptions members.
    computedTiming.setDelay(specifiedTiming().startDelay * 1000);
    computedTiming.setEndDelay(specifiedTiming().endDelay * 1000);
    computedTiming.setFill(Timing::fillModeString(resolvedFillMode(specifiedTiming().fillMode, isKeyframeEffect())));
    computedTiming.setIterationStart(specifiedTiming().iterationStart);
    computedTiming.setIterations(specifiedTiming().iterationCount);

    UnrestrictedDoubleOrString duration;
    duration.setUnrestrictedDouble(iterationDuration() * 1000);
    computedTiming.setDuration(duration);

    computedTiming.setPlaybackRate(specifiedTiming().playbackRate);
    computedTiming.setDirection(Timing::playbackDirectionString(specifiedTiming().direction));
    computedTiming.setEasing(specifiedTiming().timingFunction->toString());
}
コード例 #4
0
void AnimationNodeTiming::setDuration(const UnrestrictedDoubleOrString& durationOrAuto)
{
    // Any strings other than "auto" are coerced to "auto".
    double duration = durationOrAuto.isString() ? std::numeric_limits<double>::quiet_NaN() : durationOrAuto.getAsUnrestrictedDouble();
    Timing timing = m_parent->specifiedTiming();
    TimingInput::setIterationDuration(timing, duration);
    m_parent->updateSpecifiedTiming(timing);
}