2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2021 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 import React, { Component } from 'react';
22 import { Link } from 'react-router-dom';
23 import Col from 'react-bootstrap/lib/Col';
25 class AnimationControls extends Component {
33 return (this.props.get('sliderTickArray')).indexOf(this.props.get('currentStateHistoryValue'));
36 navigateAnimation = (index, command) => {
38 this.props.set('isPlaying',false);
39 this.props.set('isStopped', false);
40 this.props.set('isPaused', true);
41 this.props.setValueState((this.props.get('sliderTickArray'))[index]);
42 }else if (command === 'play'){
43 this.props.setValueState((this.props.get('sliderTickArray'))[index]);
45 this.props.setNavigate((this.props.get('sliderTickArray'))[index]);
49 if(this.props.get('isPlaying')){
50 var index = Math.min((this.props.get('sliderTickArray')).length - 1, this.getIndex() + 1);
51 this.navigateAnimation(this.getIndex() + 1, 'play');
52 if(index === (this.props.get('sliderTickArray')).length - 1){
53 this.props.set('isPlaying', false);
54 this.props.set('isStopped', true);
55 this.props.set('isPaused', false);
58 this.props.clear(this.props.get('intervalId'));
62 animationControl = (controlType) => {
63 console.log("Control was hit: " + controlType);
66 if(!this.props.get('isPlaying')){
67 if(!this.props.get('intervalId')){
68 this.props.set('intervalId', setInterval(this.play, 10000));
70 this.props.set('isPlaying', true);
71 this.props.set('isStopped', false);
72 this.props.set('isPaused', false);
76 if(this.props.get('isPlaying')){
77 this.props.clear(this.props.get('intervalId'));
78 this.props.set('isPlaying', false);
79 this.props.set('isPaused', true);
83 if(this.props.get('isPlaying') || this.props.get('isPaused')){
84 this.props.clear(this.props.get('intervalId'));
85 this.props.set('isPlaying', false);
86 this.props.set('isStopped', true);
87 this.props.set('isPaused', false);
90 case 'skipForwardStep':
91 var index = Math.min((this.props.get('sliderTickArray')).length - 1, this.getIndex() + 1);
92 this.navigateAnimation(index);
94 case 'skipBackwardStep':
95 var index = Math.max(0, this.getIndex() - 1);
96 this.navigateAnimation(index);
98 case 'skipForwardLast':
99 this.navigateAnimation((this.props.get('sliderTickArray')).length - 1);
101 case 'skipBackwardEpoch':
102 this.navigateAnimation(0);
105 this.props.set('isPlaying', false);
106 this.props.set('isStopped', false);
107 this.props.set('isPaused', false);
114 <i className='icon-controls-skipbackstartover animationControlIcon' onClick={() => this.animationControl('skipBackwardEpoch')} role="img"></i>
115 <i className='icon-controls-rewind animationControlIcon' onClick={() => this.animationControl('skipBackwardStep')} role="img"></i>
116 { !this.props.playControlsDisabled && (<span><i className={'icon-controls-pointer ' + (this.props.get('isPlaying') ? 'animationPlayingIcon' : 'animationControlIcon')} onClick={() => this.animationControl('play')} role="img"></i>
117 <i className={'icon-controls-pause ' + (this.props.get('isPaused') ? 'animationPausedIcon' : 'animationControlIcon')} onClick={() => this.animationControl('pause')} role="img"></i>
118 <i className={'icon-controls-stop ' + (this.props.get('isStopped') ? 'animationStoppedIcon' : 'animationControlIcon')} onClick={() => this.animationControl('stop')} role="img"></i></span>)}
119 <i className='icon-controls-fastforward animationControlIcon' onClick={() => this.animationControl('skipForwardStep')} role="img"></i>
120 <i className='icon-controls-skipforward animationControlIcon' onClick={() => this.animationControl('skipForwardLast')} role="img"></i>
126 export default AnimationControls;