Skip to content

Commit 4fd31cf

Browse files
committed
PlayState added to general animation options.
1 parent 3c27c06 commit 4fd31cf

File tree

5 files changed

+11
-2
lines changed

5 files changed

+11
-2
lines changed

src/apps/weblib/js-api/vizzu.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ interface AnimOption {
193193
}
194194

195195
interface AnimOptions {
196+
playState: 'paused'|'running';
196197
easing: Easing;
197198
duration: Duration;
198199
delay: Duration;

src/base/anim/control.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Control
2525
void seekTime(Duration pos);
2626
void pause() { playState = PlayState::paused; }
2727
void play() { playState = PlayState::running; }
28+
void setPlayState(PlayState state) { playState = state; }
2829
void stop();
2930

3031
void reverse() {

src/chart/animator/animator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void Animator::animate(const Diag::DiagramPtr &diagram,
4343
prepareActual();
4444
createPlan(*source, *target, *actual, options);
4545
::Anim::Control::reset();
46-
::Anim::Control::play();
46+
::Anim::Control::setPlayState(options.playState);
4747
}
4848

4949
void Animator::finish()

src/chart/animator/options.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ void Options::set(const std::string &path,
2828

2929
if (parts.size() == 1)
3030
{
31-
all.set(path, value);
31+
if (path == "playState") {
32+
playState = ::Anim::Control::PlayState(value);
33+
}
34+
else all.set(path, value);
3235
}
3336
else if (parts.size() == 2)
3437
{

src/chart/animator/options.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <optional>
66

77
#include "base/anim/options.h"
8+
#include "base/anim/control.h"
89
#include "base/refl/enum.h"
910

1011
namespace Vizzu
@@ -18,6 +19,8 @@ class Enum(SectionId)
1819
class Options
1920
{
2021
public:
22+
Options() : playState(::Anim::Control::PlayState::running) {}
23+
2124
struct Section {
2225
std::optional<::Anim::Easing> easing;
2326
std::optional<::Anim::Duration> delay;
@@ -27,6 +30,7 @@ class Options
2730
};
2831

2932
Section all;
33+
::Anim::Control::PlayState playState;
3034
std::array<Section, SectionId::EnumInfo::count()> sections;
3135

3236
void set(const std::string &path, const std::string &value);

0 commit comments

Comments
 (0)