aloisdeniel / aloisdeniel/keyframes_tween

Interpolating between animations from previous value

Đang mở
#3 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Dart
Star
19
Fork
3
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I'm trying to achieve a behavior similar to TweenAnimationBuilder such that the previous value of the tween is used to start/continue the animation when running it.

My use-case is quickly switching between days and interpolating between some values. However, on top of that there's a transition sequence that I would like to play when doing so.

When playing this animation fully from value `a` to value `b` everything works as expected:

```dart

KeyframesTween getLabelTween(
double previousValue,
double value,
) {

return KeyframesTween([
KeyframeProperty(
[
1.0.keyframe(0.0),
0.0.keyframe(10 / 60),
0.0.keyframe(15 / 60),
1.0.keyframe(45 / 60, VisibleCurves.functionalEntrance),
],
name: 'opacity',
),
KeyframeProperty(
[
0.0.keyframe(10 / 60),
6.0.keyframe(15 / 60),
0.0.keyframe(45 / 60, VisibleCurves.functionalEntrance),
],
name: 'offset',
),

KeyframeProperty(
[
previousValue.keyframe(0.0),
0.0.keyframe(15 / 60),
value.keyframe(1.0),
],
name: 'value',
),
]);
}
```

However, when switching from `a` to `b` and then quickly to `c` the animation will restart from 0 and if the transition was in the middle, it will look jarring.

```dart
@override
void didUpdateWidget(covariant AnimatedTextSwitcher oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.keyBuilder != widget.keyBuilder) {
switchDayAnimation(oldWidget.value);
}
}

void switchDayAnimation(String previousValue) {
_tween = getLabelTween(previousValue, widget.value);
_controller.forward(from: 0);
}
```

I'm trying to find a way to "memoize" the most recent animation state similarly how `TweenAnimationBuilder` achieves it. Do you see any possibility to combine that with keyframes_flutter?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.