исправление: свайп — чувствительность и читаемость при любом акцентном цвете
Чувствительность: - MIN_DRAG увеличен с 12 до 22px - Добавлена проверка H_RATIO для pointer-событий (как для колёсика): свайп не начинается если движение слишком диагональное Читаемость: - SWIPE_ACTION_INFO: добавлено поле iconColor для каждого действия - toggleRead: фон теперь --accent-swipe-bg (rgba с пониженной непрозрачностью), иконка использует --accent-text (контрастный к акценту цвет) - delete/toggleFlag: фиксированные полупрозрачные rgba вместо var(--danger/--warning) - applyAccentColor: вычисляет --accent-swipe-bg — при светлом акценте alpha снижается, при тёмном остаётся насыщенным - .action-icon: убран хардкод color:#fff, цвет задаётся через inline style из iconColor Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6fc0cb939c
commit
a0a21100b3
2 changed files with 26 additions and 21 deletions
|
|
@ -31,7 +31,7 @@ const dateDisplay = computed(() => formatMessageDate(props.message.date))
|
|||
// Constants
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
const CLICK_DIST = 6 // px — max displacement to count as a tap/click
|
||||
const MIN_DRAG = 12 // px horizontal before we start the visual swipe
|
||||
const MIN_DRAG = 22 // px horizontal before we start the visual swipe
|
||||
const TRIGGER = 90 // px visual offset → action fires
|
||||
const FLICK_SPEED = 14 // last-event deltaX that counts as a "flick"
|
||||
const FLICK_RATIO = 0.55 // flick trigger = TRIGGER * FLICK_RATIO
|
||||
|
|
@ -40,7 +40,7 @@ const SCALE = 0.50 // visual px per accumulated deltaX past dead zone
|
|||
const RUBBER_PEAK = 72 // visual px where rubber-band starts
|
||||
const RUBBER_K = 0.12 // fraction of excess applied past rubber peak
|
||||
const IDLE_MS = 130 // ms of wheel silence → gesture over
|
||||
const H_RATIO = 2.0 // deltaX must be ≥ deltaY × H_RATIO to start gesture
|
||||
const H_RATIO = 1.8 // deltaX must be ≥ deltaY × H_RATIO to start gesture
|
||||
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
// Reactive / template state
|
||||
|
|
@ -55,10 +55,12 @@ const isSnapping = ref(false)
|
|||
const progress = computed(() => Math.min(1, Math.abs(swipeOffset.value) / TRIGGER))
|
||||
const showLeftBg = computed(() => swipeOffset.value > 0 && props.swipeRightAction !== 'none')
|
||||
const showRightBg = computed(() => swipeOffset.value < 0 && props.swipeLeftAction !== 'none')
|
||||
const leftColor = computed(() => SWIPE_ACTION_INFO[props.swipeRightAction].color)
|
||||
const rightColor = computed(() => SWIPE_ACTION_INFO[props.swipeLeftAction].color)
|
||||
const leftIcon = computed(() => SWIPE_ACTION_INFO[props.swipeRightAction].icon)
|
||||
const rightIcon = computed(() => SWIPE_ACTION_INFO[props.swipeLeftAction].icon)
|
||||
const leftColor = computed(() => SWIPE_ACTION_INFO[props.swipeRightAction].color)
|
||||
const rightColor = computed(() => SWIPE_ACTION_INFO[props.swipeLeftAction].color)
|
||||
const leftIcon = computed(() => SWIPE_ACTION_INFO[props.swipeRightAction].icon)
|
||||
const rightIcon = computed(() => SWIPE_ACTION_INFO[props.swipeLeftAction].icon)
|
||||
const leftIconColor = computed(() => SWIPE_ACTION_INFO[props.swipeRightAction].iconColor)
|
||||
const rightIconColor= computed(() => SWIPE_ACTION_INFO[props.swipeLeftAction].iconColor)
|
||||
const confirmed = computed(() => Math.abs(swipeOffset.value) >= TRIGGER)
|
||||
|
||||
function applyRubberBand(v: number): number {
|
||||
|
|
@ -107,7 +109,7 @@ function onPointerMove(e: PointerEvent): void {
|
|||
|
||||
if (!ptrDragging) {
|
||||
if (Math.abs(dx) < MIN_DRAG) return
|
||||
if (Math.abs(dy) > Math.abs(dx)) return // vertical — not a swipe
|
||||
if (Math.abs(dx) < Math.abs(dy) * H_RATIO) return // слишком диагональ — не свайп
|
||||
ptrDragging = true
|
||||
}
|
||||
|
||||
|
|
@ -238,7 +240,7 @@ onUnmounted(() => {
|
|||
class="action-bg action-left"
|
||||
:style="{ background: leftColor, opacity: progress }"
|
||||
>
|
||||
<span class="action-icon" :class="{ confirmed }">
|
||||
<span class="action-icon" :class="{ confirmed }" :style="{ color: leftIconColor }">
|
||||
<AppIcon v-if="leftIcon" :name="(leftIcon as any)" :size="18" />
|
||||
</span>
|
||||
</div>
|
||||
|
|
@ -249,7 +251,7 @@ onUnmounted(() => {
|
|||
class="action-bg action-right"
|
||||
:style="{ background: rightColor, opacity: progress }"
|
||||
>
|
||||
<span class="action-icon" :class="{ confirmed }">
|
||||
<span class="action-icon" :class="{ confirmed }" :style="{ color: rightIconColor }">
|
||||
<AppIcon v-if="rightIcon" :name="(rightIcon as any)" :size="18" />
|
||||
</span>
|
||||
</div>
|
||||
|
|
@ -326,8 +328,8 @@ onUnmounted(() => {
|
|||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
transition: transform 0.15s ease;
|
||||
filter: drop-shadow(0 1px 3px rgba(0,0,0,0.4));
|
||||
}
|
||||
.action-icon.confirmed { transform: scale(1.3); }
|
||||
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ export const SWIPE_ACTION_LABELS: Record<SwipeAction, string> = {
|
|||
none: 'Нет действия'
|
||||
}
|
||||
|
||||
export const SWIPE_ACTION_INFO: Record<SwipeAction, { icon: string; color: string }> = {
|
||||
delete: { icon: 'trash', color: 'var(--danger)' },
|
||||
toggleRead: { icon: 'envelope', color: 'var(--accent)' },
|
||||
toggleFlag: { icon: 'flag', color: 'var(--warning)' },
|
||||
none: { icon: '', color: 'transparent' }
|
||||
export const SWIPE_ACTION_INFO: Record<SwipeAction, { icon: string; color: string; iconColor: string }> = {
|
||||
delete: { icon: 'trash', color: 'rgba(200, 45, 45, 0.75)', iconColor: 'rgba(255,255,255,0.92)' },
|
||||
toggleRead: { icon: 'envelope', color: 'var(--accent-swipe-bg)', iconColor: 'var(--accent-text)' },
|
||||
toggleFlag: { icon: 'flag', color: 'rgba(200, 130, 0, 0.75)', iconColor: 'rgba(255,245,200,0.95)' },
|
||||
none: { icon: '', color: 'transparent', iconColor: '#fff' },
|
||||
}
|
||||
|
||||
// ─── Accent color ────────────────────────────────────────
|
||||
|
|
@ -51,12 +51,15 @@ function applyAccentColor(hex: string): void {
|
|||
const lum = getLuminance(r, g, b)
|
||||
const root = document.documentElement
|
||||
|
||||
root.style.setProperty('--accent', hex)
|
||||
root.style.setProperty('--accent-hover', lightenHex(hex, 28))
|
||||
root.style.setProperty('--accent-muted', `rgba(${r},${g},${b},0.12)`)
|
||||
root.style.setProperty('--accent-text', lum > 0.35 ? '#0d0d0d' : '#ffffff')
|
||||
root.style.setProperty('--accent-glow', `rgba(${r},${g},${b},0.08)`)
|
||||
root.style.setProperty('--bg-selected', `rgba(${r},${g},${b},0.10)`)
|
||||
root.style.setProperty('--accent', hex)
|
||||
root.style.setProperty('--accent-hover', lightenHex(hex, 28))
|
||||
root.style.setProperty('--accent-muted', `rgba(${r},${g},${b},0.12)`)
|
||||
root.style.setProperty('--accent-text', lum > 0.35 ? '#0d0d0d' : '#ffffff')
|
||||
root.style.setProperty('--accent-glow', `rgba(${r},${g},${b},0.08)`)
|
||||
root.style.setProperty('--bg-selected', `rgba(${r},${g},${b},0.10)`)
|
||||
// Фон свайп-действия: насыщенность зажата — никогда не бывает слепяще белым
|
||||
const swipeAlpha = lum > 0.6 ? 0.45 : 0.72
|
||||
root.style.setProperty('--accent-swipe-bg', `rgba(${r},${g},${b},${swipeAlpha})`)
|
||||
}
|
||||
|
||||
// ─── Storage ─────────────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Reference in a new issue