1<!-- Copyright (C) 2020 The Android Open Source Project 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14--> 15<template> 16 <div class="transition-container" :style="transitionStyle" @click="handleTransitionClick()"> 17 <md-tooltip md-direction="left"> {{tooltip}} </md-tooltip> 18 <arrow class="arrow-start" :style="transitionComponentColor"/> 19 <div class="connector" :style="transitionComponentColor"/> 20 <arrow class="arrow-end" :style="transitionComponentColor"/> 21 </div> 22</template> 23<script> 24import Arrow from './Arrow.vue'; 25import {LocalStore} from '../../localstore.js'; 26 27var transitionCount = false; 28 29export default { 30 name: 'transition-container', 31 components: { 32 'arrow': Arrow, 33 }, 34 props: { 35 'width': { 36 type: Number, 37 }, 38 'startPos': { 39 type: Number, 40 }, 41 'startTime': { 42 type: Number, 43 }, 44 'endTime': { 45 type: Number, 46 }, 47 'color': { 48 type: String, 49 }, 50 'overlap': { 51 type: Number, 52 }, 53 'tooltip': { 54 type: String, 55 }, 56 'store': { 57 type: LocalStore, 58 }, 59 }, 60 methods: { 61 handleTransitionClick() { 62 if (transitionCount) { 63 this.$store.dispatch('updateTimelineTime', this.startTime); 64 transitionCount = false; 65 } else { 66 this.$store.dispatch('updateTimelineTime', this.endTime); 67 transitionCount = true; 68 } 69 }, 70 }, 71 computed: { 72 transitionStyle() { 73 return { 74 width: this.width + '%', 75 left: this.startPos + '%', 76 bottom: this.overlap * 100 + '%', 77 } 78 }, 79 transitionComponentColor() { 80 return { 81 borderTopColor: this.color, 82 } 83 }, 84 }, 85}; 86</script> 87<style scoped> 88.transition-container { 89 position: absolute; 90 height: 15px; 91 display: inline-flex; 92} 93 94.arrow-start { 95 position: absolute; 96 left: 0%; 97} 98 99.arrow-end { 100 position: absolute; 101 right: 0%; 102} 103 104.connector { 105 position: absolute; 106 display: inline-block; 107 width: auto; 108 height: 9px; 109 left: 5px; 110 right: 5px; 111 border-top: 1px solid; 112} 113</style>