This is an automated email from the ASF dual-hosted git repository.

ovilia pushed a commit to branch fix-timeline-event
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit 0e29b0d74413e1aa959a4ece7d4345e3cde594fe
Author: Ovilia <zwl.s...@gmail.com>
AuthorDate: Thu Apr 8 15:25:26 2021 +0800

    fix(timeline): trigger timelineplaychange event when play to the end #14588
---
 src/component/timeline/timelineAction.ts | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/component/timeline/timelineAction.ts 
b/src/component/timeline/timelineAction.ts
index c4ef686..202bc18 100644
--- a/src/component/timeline/timelineAction.ts
+++ b/src/component/timeline/timelineAction.ts
@@ -22,6 +22,7 @@ import TimelineModel from './TimelineModel';
 import { defaults } from 'zrender/src/core/util';
 import { Payload } from '../../util/types';
 import { EChartsExtensionInstallRegisters } from '../../extension';
+import ExtensionAPI from '../../core/ExtensionAPI';
 
 export interface TimelineChangePayload extends Payload {
     type: 'timelineChange'
@@ -38,14 +39,25 @@ export function installTimelineAction(registers: 
EChartsExtensionInstallRegister
 
         {type: 'timelineChange', event: 'timelineChanged', update: 
'prepareAndUpdate'},
 
-        function (payload: TimelineChangePayload, ecModel: GlobalModel) {
+        function (payload: TimelineChangePayload, ecModel: GlobalModel, api: 
ExtensionAPI) {
 
             const timelineModel = ecModel.getComponent('timeline') as 
TimelineModel;
             if (timelineModel && payload.currentIndex != null) {
                 timelineModel.setCurrentIndex(payload.currentIndex);
 
-                if (!timelineModel.get('loop', true) && 
timelineModel.isIndexMax()) {
+                if (
+                    !timelineModel.get('loop', true)
+                    && timelineModel.isIndexMax()
+                    && timelineModel.getPlayState()
+                ) {
                     timelineModel.setPlayState(false);
+
+                    // The timeline has played to the end, trigger event
+                    api.dispatchAction({
+                        type: 'timelinePlayChange',
+                        playState: false,
+                        from: payload.from
+                    });
                 }
             }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org
For additional commands, e-mail: commits-h...@echarts.apache.org

Reply via email to