Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: MkRangeのタッチ操作時にtooltipが複数重なって表示されないように #265

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions packages/frontend/src/components/MkRange.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ SPDX-License-Identifier: AGPL-3.0-only

<template>
<div class="timctyfi" :class="{ disabled, easing }">
<div class="label"><slot name="label"></slot></div>
<div class="label">
<slot name="label"></slot>
</div>
<div v-adaptive-border class="body">
<div ref="containerEl" class="container">
<div class="track">
Expand All @@ -14,16 +16,21 @@ SPDX-License-Identifier: AGPL-3.0-only
<div v-if="steps && showTicks" class="ticks">
<div v-for="i in (steps + 1)" class="tick" :style="{ left: (((i - 1) / steps) * 100) + '%' }"></div>
</div>
<div ref="thumbEl" v-tooltip="textConverter(finalValue)" class="thumb" :style="{ left: thumbPosition + 'px' }" @mousedown="onMousedown" @touchstart="onMousedown"></div>
<div
ref="thumbEl" class="thumb" :style="{ left: thumbPosition + 'px' }"
@mousedown="onMousedown" @touchstart="onMousedown"
></div>
</div>
</div>
<div class="caption"><slot name="caption"></slot></div>
<div class="caption">
<slot name="caption"></slot>
</div>
</div>
</template>

<script lang="ts" setup>
import { computed, defineAsyncComponent, onMounted, onUnmounted, ref, watch, shallowRef } from 'vue';
import * as os from '@/os.js';
import { computed, defineAsyncComponent, onMounted, onUnmounted, ref, shallowRef, watch } from 'vue';
import { popup } from '@/os.js';

const props = withDefaults(defineProps<{
modelValue: number;
Expand Down Expand Up @@ -105,7 +112,7 @@ const onMousedown = (ev: MouseEvent | TouchEvent) => {
ev.preventDefault();

const tooltipShowing = ref(true);
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkTooltip.vue')), {
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkTooltip.vue')), {
showing: tooltipShowing,
text: computed(() => {
return props.textConverter(finalValue.value);
Expand Down Expand Up @@ -262,12 +269,12 @@ const onMousedown = (ev: MouseEvent | TouchEvent) => {
> .container {
> .track {
> .highlight {
transition: width 0.2s cubic-bezier(0,0,0,1);
transition: width 0.2s cubic-bezier(0, 0, 0, 1);
}
}

> .thumb {
transition: left 0.2s cubic-bezier(0,0,0,1);
transition: left 0.2s cubic-bezier(0, 0, 0, 1);
}
}
}
Expand Down