完成 relative axis 实现
This commit is contained in:
parent
104ee9af5d
commit
ee882a53db
@ -3,13 +3,17 @@
|
|||||||
class="axis-item"
|
class="axis-item"
|
||||||
:style="itemStyle"
|
:style="itemStyle"
|
||||||
>
|
>
|
||||||
<span>{{ props.pivot.label }}</span>
|
<span>{{ makeDiffLabel() }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, defineComponent } from 'vue';
|
import { computed, defineComponent } from 'vue';
|
||||||
import { boxShift } from './pivot-view';
|
import { boxShift, Id2Pivot } from './pivot-view';
|
||||||
|
import { globalLookup } from '@/hook/global';
|
||||||
|
import { RelativeAxis } from './relative-axis';
|
||||||
|
import formatTime from '@/hook/wave-view/format-time';
|
||||||
|
import { cursorX2time } from './cursor';
|
||||||
|
|
||||||
|
|
||||||
defineComponent({ name: 'axis-item' });
|
defineComponent({ name: 'axis-item' });
|
||||||
@ -24,6 +28,21 @@ const itemStyle = computed(() => ({
|
|||||||
left: props.pivot.x - boxShift + 'px'
|
left: props.pivot.x - boxShift + 'px'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
function makeDiffLabel() {
|
||||||
|
if (RelativeAxis.show) {
|
||||||
|
const currentPivotId = RelativeAxis.currentPivotId;
|
||||||
|
const currentPivot = Id2Pivot.get(currentPivotId);
|
||||||
|
if (currentPivot) {
|
||||||
|
const t1 = cursorX2time(currentPivot.x);
|
||||||
|
const t2 = cursorX2time(props.pivot.x);
|
||||||
|
const relativeTime = t2 - t1;
|
||||||
|
return formatTime(relativeTime, globalLookup.timescale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '?';
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { reactive } from "vue";
|
import { reactive } from "vue";
|
||||||
|
|
||||||
export const RelativeAxis = reactive({
|
export const RelativeAxis = reactive({
|
||||||
show: false
|
show: false,
|
||||||
|
currentPivotId: -1
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -225,8 +225,8 @@ function handleUserContextMenu(event) {
|
|||||||
|
|
||||||
|
|
||||||
function displayRelativeAxis() {
|
function displayRelativeAxis() {
|
||||||
|
RelativeAxis.currentPivotId = props.id;
|
||||||
|
RelativeAxis.show = true;
|
||||||
|
|
||||||
currentPivotId.value = 0;
|
currentPivotId.value = 0;
|
||||||
UserPivotCtxShows.delete(props.id);
|
UserPivotCtxShows.delete(props.id);
|
||||||
@ -236,6 +236,8 @@ function cancelRelativeAxis() {
|
|||||||
if (RelativeAxis.show === false) {
|
if (RelativeAxis.show === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RelativeAxis.show = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user