From 0e815f5faa79db4109c0236d80d70d0776e4aa7d Mon Sep 17 00:00:00 2001 From: Luigi Rosso Date: Mon, 16 Dec 2019 09:21:52 +0800 Subject: [PATCH] Fix for applying wrong animation to artboard. Issue #205. --- flare_dart/CHANGELOG.md | 4 ++++ flare_dart/lib/animation/keyframe.dart | 4 ++-- flare_dart/pubspec.yaml | 2 +- flare_flutter/CHANGELOG.md | 4 ++++ flare_flutter/lib/flare_actor.dart | 3 ++- flare_flutter/pubspec.yaml | 2 +- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/flare_dart/CHANGELOG.md b/flare_dart/CHANGELOG.md index ed76067..a8cbf8f 100644 --- a/flare_dart/CHANGELOG.md +++ b/flare_dart/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.3.1] - 2019-12-16 09:17:37 + +- Type checking when applying trim path animation. Improves robustness and helps prevent crashes when applying animations from non-matching artboards. + ## [2.3.0] - 2019-12-05 17:25:03 - Support for layer effects including masking, drop shadows, inner shadows, and blurs. diff --git a/flare_dart/lib/animation/keyframe.dart b/flare_dart/lib/animation/keyframe.dart index 755c13b..e59bd04 100644 --- a/flare_dart/lib/animation/keyframe.dart +++ b/flare_dart/lib/animation/keyframe.dart @@ -1148,7 +1148,7 @@ class KeyFrameStrokeColor extends KeyFrameWithInterpolation { class KeyFrameStrokeEnd extends KeyFrameNumeric { @override void setValue(ActorComponent component, double value, double mix) { - if (component == null) return; + if (component is! ActorStroke) return; ActorStroke star = component as ActorStroke; star.trimEnd = star.trimEnd * (1.0 - mix) + value * mix; @@ -1184,7 +1184,7 @@ class KeyFrameStrokeOffset extends KeyFrameNumeric { class KeyFrameStrokeStart extends KeyFrameNumeric { @override void setValue(ActorComponent component, double value, double mix) { - if (component == null) return; + if (component is! ActorStroke) return; ActorStroke star = component as ActorStroke; star.trimStart = star.trimStart * (1.0 - mix) + value * mix; diff --git a/flare_dart/pubspec.yaml b/flare_dart/pubspec.yaml index 31cc75b..049f0da 100644 --- a/flare_dart/pubspec.yaml +++ b/flare_dart/pubspec.yaml @@ -1,6 +1,6 @@ name: flare_dart description: Vector design and runtime animation. -version: 2.3.0 +version: 2.3.1 author: "Rive Team " homepage: https://github.com/2d-inc/Flare-Flutter environment: diff --git a/flare_flutter/CHANGELOG.md b/flare_flutter/CHANGELOG.md index 01d0b46..aae7f70 100644 --- a/flare_flutter/CHANGELOG.md +++ b/flare_flutter/CHANGELOG.md @@ -1,3 +1,7 @@ +## [1.8.2] - 2019-12-16 09:19:22 + +- Clear out layers when instancing artboards to prevent animations from other artboards being applied. + ## [1.8.1] - 2019-12-09 19:33:06 - Disable blur effects if they are less than a certain threshold. Skia seems to drop the whole layer if it's too close to zero (but not zero). diff --git a/flare_flutter/lib/flare_actor.dart b/flare_flutter/lib/flare_actor.dart index 56536a1..de8923c 100644 --- a/flare_flutter/lib/flare_actor.dart +++ b/flare_flutter/lib/flare_actor.dart @@ -245,7 +245,7 @@ class FlareActorRenderObject extends FlareRenderBox { @override void onUnload() { - _animationLayers.length = 0; + _animationLayers.clear(); } String get filename => _filename; @@ -285,6 +285,7 @@ class FlareActorRenderObject extends FlareRenderBox { if (_controller != null) { _controller.initialize(_artboard); } + _animationLayers.clear(); _updateAnimation(onlyWhenMissing: true); // Immediately update the newly instanced artboard and compute // bounds so that the widget can take up the necessary space diff --git a/flare_flutter/pubspec.yaml b/flare_flutter/pubspec.yaml index 97d80cd..e68f2c8 100644 --- a/flare_flutter/pubspec.yaml +++ b/flare_flutter/pubspec.yaml @@ -1,6 +1,6 @@ name: flare_flutter description: Vector design and runtime animation for Flutter. -version: 1.8.1 +version: 1.8.2 author: "Rive Team " homepage: https://github.com/2d-inc/Flare-Flutter environment: