Changeset 35456 for main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/WordTimingSelector.vue
- Timestamp:
- 2021-09-23T16:52:55+12:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/WordTimingSelector.vue
r35455 r35456 4 4 5 5 <div class="words-container" ref="wordsContainer"> 6 <input type="range" class="slider-continuous" ref="slider" /> 7 8 <div class="surround-word" v-for="word in mySurroundingWords" :key="word.id" :style="{ left: word.left, width: word.length }"> 6 <div class="word" v-for="word in mySurroundingWords" :key="word.id" :style="{ left: word.left, width: word.length }" 7 :class="[ shouldHoist(word) ? 'hoisted' : 'surround-word' ]"> 9 8 <span>{{ word.word }}</span> 10 9 </div> … … 19 18 display: flex; 20 19 align-items: center; 20 justify-content: center; 21 21 gap: 1em; 22 height: 3em; 22 23 } 23 24 24 25 .words-container { 25 flex-grow: 0. 5;26 flex-grow: 0.6; 26 27 position: relative; 27 height: 2.5em;28 height: 1.5em; 28 29 } 29 30 30 . surround-word {31 .word { 31 32 position: absolute; 32 33 text-align: center; … … 39 40 background-color: rgba(var(--bg-color-raw), 0.3); 40 41 border: 1px solid rgba(var(--bg-color-raw), 0.6); 42 } 43 44 .surround-word { 45 top: 50%; 46 } 47 48 .hoisted { 49 top: -50%; 50 background-color: var(--highlighted-word-bg); 41 51 } 42 52 </style> … … 62 72 surroundingWords: Array, 63 73 word: { word: String, startTime: Number, endTime: Number }, 64 wordIndex: Number,65 74 upperBound: Number 66 75 }, … … 90 99 watch: { 91 100 surroundingWords() { 92 this. scaleWords();101 this.getMySurroundingWords(); 93 102 } 94 103 }, 95 104 methods: { 96 scaleWords() {105 getMySurroundingWords() { 97 106 if (!this.isMounted) { 98 107 return; … … 105 114 106 115 const audioLength = this.surroundingWords[this.surroundingWords.length - 1].endTime - this.surroundingWords[0].startTime; 107 const sliderLengthPx = this.$refs. slider.offsetWidth;116 const sliderLengthPx = this.$refs.wordsContainer.offsetWidth; 108 117 109 118 const scalingFactor = sliderLengthPx / audioLength; … … 118 127 } 119 128 129 // myWords.splice(this.surroundingWords.indexOf(this.word), 1); 120 130 this.mySurroundingWords = myWords; 131 }, 132 shouldHoist(word) { 133 return word.startTime === this.word.startTime; 121 134 } 122 135 }, 123 136 mounted() { 124 137 this.isMounted = true; 125 this. scaleWords();138 this.getMySurroundingWords(); 126 139 } 127 140 }
Note:
See TracChangeset
for help on using the changeset viewer.