Changeset 35601
- Timestamp:
- 2021-10-15T09:50:47+13:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/WordTimingSelector.vue
r35549 r35601 10 10 11 11 <div class="word-attachment-container" :style="{ left: leftHandleLeft }"> 12 <span>{{ wordStartTime }}</span>13 <span v-if="isMounted" class="material-icons mdi-m word-handle" @mousedown="can ShiftMinValue = true">12 <span>{{ wordStartTimeString }}</span> 13 <span v-if="isMounted" class="material-icons mdi-m word-handle" @mousedown="canAdjustWordStartTime = true"> 14 14 first_page 15 15 </span> … … 17 17 18 18 <div class="word-attachment-container" :style="{ left: rightHandleLeft }"> 19 <span v-if="isMounted" class="material-icons mdi-m word-handle" @mousedown="can ShiftMaxValue = true">19 <span v-if="isMounted" class="material-icons mdi-m word-handle" @mousedown="canAdjustWordEndTime = true"> 20 20 last_page 21 21 </span> 22 <span>{{ wordEndTime }}</span>22 <span>{{ wordEndTimeString }}</span> 23 23 </div> 24 24 </div> … … 112 112 /** @type {Array<TWord>} */ 113 113 surroundingWords: Array, 114 word: TWord, 115 upperBound: Number 114 word: TWord 116 115 }, 117 116 data() { … … 120 119 /** @type {Array<Word>} */ 121 120 // mySurroundingWords: [], 122 can ShiftMinValue: false,123 can ShiftMaxValue: false,121 canAdjustWordStartTime: false, 122 canAdjustWordEndTime: false, 124 123 wordsContainerWidth: 0, 125 124 isProduction: false … … 145 144 return Util.formatSecondsTimeString(this.surroundingWords[this.surroundingWords.length - 1].endTime, false, 2); 146 145 }, 147 wordStartTime () {146 wordStartTimeString() { 148 147 return Util.formatSecondsTimeString(this.word.startTime, false, 2); 149 148 }, 150 wordEndTime () {149 wordEndTimeString() { 151 150 return Util.formatSecondsTimeString(this.word.endTime, false, 2); 152 151 }, … … 166 165 } 167 166 else { 168 return this.surroundingWords[this.surroundingWords.length - 1].endTime - this.surroundingWords[0].startTime; 167 let length = this.surroundingWords[this.surroundingWords.length - 1].endTime; 168 169 // Removes the buffer from 0s 170 if (this.wordIndex !== 0) { 171 length -= this.surroundingWords[0].startTime; 172 } 173 174 return length; 169 175 } 170 176 }, … … 181 187 */ 182 188 wordLeftOffsetPx() { 183 return this.surroundingWords[0].startTime * this.scalingFactor; 189 if (this.wordIndex === 0) { 190 return 0; 191 } 192 else { 193 return this.surroundingWords[0].startTime * this.scalingFactor; 194 } 184 195 }, 185 196 mySurroundingWords() { … … 214 225 return myWords; 215 226 }, 227 scaleTime(time) { 228 return time * this.scalingFactor; 229 }, 230 timeToPosition(time) { 231 return time * this.scalingFactor - this.wordLeftOffsetPx; 232 }, 216 233 convertWord(word) { 217 const left = (word.startTime * this.scalingFactor - this.wordLeftOffsetPx);234 const left = this.timeToPosition(word.startTime); 218 235 const length = (word.endTime - word.startTime) * this.scalingFactor; 219 236 … … 228 245 } 229 246 230 if (this.can ShiftMinValue) {247 if (this.canAdjustWordStartTime) { 231 248 this.onMinHandleMouseMove(event); 232 249 } 233 else if (this.can ShiftMaxValue) {250 else if (this.canAdjustWordEndTime) { 234 251 this.onMaxHandleMouseMove(event); 235 252 } … … 243 260 } 244 261 245 const word = this.mySurroundingWords[this.wordIndex]; 246 247 if (event.movementX < 0 && word.left + event.movementX < 0) { 248 return; 249 } 250 251 if (event.movementX > 0 && word.left + event.movementX >= word.right()) { 252 return; 253 } 254 255 this.mySurroundingWords[this.wordIndex].left += event.movementX; 256 word.length -= event.movementX; 262 // const word = this.mySurroundingWords[this.wordIndex]; 263 264 // if (event.movementX < 0 && word.left + event.movementX < 0) { 265 // return; 266 // } 267 268 // if (event.movementX > 0 && word.left + event.movementX >= word.right()) { 269 // return; 270 // } 271 272 // word.left += event.movementX; 273 // word.length -= event.movementX; 274 275 this.adjustWordStartTime(event.movementX); 257 276 258 277 this.myWordToWord(); … … 280 299 }, 281 300 onDocumentMouseUp() { 282 this.can ShiftMinValue = false;283 this.can ShiftMaxValue = false;301 this.canAdjustWordStartTime = false; 302 this.canAdjustWordEndTime = false; 284 303 }, 285 304 myWordToWord() { … … 292 311 const word = new TWord(this.word.word, startTime, endTime, this.word.id, this.word.shouldHighlight, this.word.deletionAttempts); 293 312 this.$emit("update:word", word); 313 }, 314 adjustWordStartTime(amount) { 315 const word = this.mySurroundingWords[this.wordIndex]; 316 word.left += amount; 317 word.length -= amount; 318 319 if (amount < 0) { 320 if (this.wordIndex === 0) { 321 if (word.left > 0) { 322 return; 323 } 324 325 const diff = 0 - word.left; 326 word.left = 0; 327 word.length -= diff; 328 } 329 else { 330 // Adjust previous word 331 const previousWord = this.mySurroundingWords[this.wordIndex - 1]; 332 333 if (word.left > previousWord.right()) { 334 return; 335 } 336 337 const diff = word.left - previousWord.right(); // Will be negative 338 word.left -= diff; 339 word.length += diff; 340 341 // TODO: This logic needs all words to be reactively updated to work 342 343 // previousWord.length += amount; 344 // const leftBoundary = previousWord.left + this.timeToPosition(0.1); 345 346 // if (previousWord.right() > leftBoundary) { 347 // return; 348 // } 349 350 // const diff = leftBoundary - previousWord.right(); // Will be negative 351 // word.left -= diff; 352 // word.length += diff; 353 // previousWord.length -= diff; 354 } 355 } 356 else { 357 if (word.left > (word.right() - this.scaleTime(0.1))) { 358 const diff = word.left - (word.right() - this.scaleTime(0.1)) // Will be positive 359 word.left -= diff; 360 word.length += diff; 361 } 362 } 294 363 } 295 364 },
Note:
See TracChangeset
for help on using the changeset viewer.