|
1 |
| -/* global inject */ |
2 | 1 | const { I } = inject();
|
3 | 2 | const assert = require('assert');
|
4 | 3 |
|
@@ -38,6 +37,7 @@ module.exports = {
|
38 | 37 | await I.executeScript(Helpers.waitForAudio);
|
39 | 38 | I.waitForInvisible(this._progressBarSelector);
|
40 | 39 | },
|
| 40 | + |
41 | 41 | getCurrentAudioTime() {
|
42 | 42 | return I.executeScript(Helpers.getCurrentAudioTime);
|
43 | 43 | },
|
@@ -73,6 +73,52 @@ module.exports = {
|
73 | 73 | I.wait(1); // We gotta wait here because clicks on the canvas are not processed immediately
|
74 | 74 | },
|
75 | 75 |
|
| 76 | + async createRegion(tagName, start, length) { |
| 77 | + const { x, y, height } = await this.getWrapperPosition(tagName); |
| 78 | + |
| 79 | + return I.dragAndDropMouse({ |
| 80 | + x: x + start, |
| 81 | + y: y + height / 2, |
| 82 | + }, { |
| 83 | + x: x + start + length, |
| 84 | + y: y + height / 2, |
| 85 | + }); |
| 86 | + }, |
| 87 | + |
| 88 | + async getWrapperPosition(tagName) { |
| 89 | + const wrapperPosition = await I.executeScript((tagName) => { |
| 90 | + const wrapper = Htx.annotationStore.selected.names.get(tagName)._ws.container; |
| 91 | + const bbox = wrapper.getBoundingClientRect(); |
| 92 | + |
| 93 | + return { |
| 94 | + x: bbox.x, |
| 95 | + y: bbox.y, |
| 96 | + width: bbox.width, |
| 97 | + height: bbox.height, |
| 98 | + }; |
| 99 | + }, tagName); |
| 100 | + |
| 101 | + return wrapperPosition; |
| 102 | + }, |
| 103 | + |
| 104 | + async moveRegion(regionId, offset = 30) { |
| 105 | + const regionPosition = await I.executeScript((regionId) => { |
| 106 | + const region = Htx.annotationStore.selected.regions.find(r => r.cleanId === regionId); |
| 107 | + const element = region.getRegionElement(); |
| 108 | + const rect = element.getBoundingClientRect(); |
| 109 | + |
| 110 | + return { |
| 111 | + x: rect.x + rect.width / 2, |
| 112 | + y: rect.y + rect.height / 2, |
| 113 | + }; |
| 114 | + }, regionId); |
| 115 | + |
| 116 | + return I.dragAndDropMouse(regionPosition, { |
| 117 | + x: regionPosition.x + offset, |
| 118 | + y: regionPosition.y, |
| 119 | + }); |
| 120 | + }, |
| 121 | + |
76 | 122 | /**
|
77 | 123 | * Toggle the audio control menu. This houses the volume slider and mute button.
|
78 | 124 | */
|
|
0 commit comments