Skip to content

fix(slider): modify mobile problem #2669

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

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions packages/mobile/components/slider/src/mobile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<template>
<div style="position: relative">
<div
ref="slider"
:class="['tiny-mobile-slider', { 'tiny-mobile-slider__vertical': vertical, disabled }]"
:style="{ height: vertical ? height : '' }"
@touchstart="bindMouseDown"
Expand Down Expand Up @@ -40,7 +41,7 @@
@mouseleave="hideTip"
@keydown="bindKeyDown"
></div>
<div class="tiny-mobile-slider__tips" v-show="showTip && state.showTip" :style="state.tipStyle">
<div ref="sliderTip" class="tiny-mobile-slider__tips" v-show="showTip && state.showTip" :style="state.tipStyle">
{{ state.tipValue }}
</div>
</div>
Expand All @@ -57,12 +58,14 @@

<script lang="ts">
import { renderless, api } from './renderless/vue'
import { props, setup, defineComponent } from '../../../vue-common'
import { $prefix, setup, defineComponent } from '../../../vue-common'
import type { ISliderApi } from './slider'
import { sliderProps } from './slider'
import '@opentiny/vue-theme-mobile/slider/index.less'

export default defineComponent({
name: $prefix + 'Slider',
componentName: 'Slider',
emits: ['update:modelValue', 'change', 'start', 'stop'],
props: sliderProps,
setup(props, context) {
Expand Down
19 changes: 6 additions & 13 deletions packages/mobile/components/slider/src/renderless/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,13 @@ export const bindMouseDown =
let isClickBtn: boolean | undefined = false
let isClickLabel: boolean | undefined = false

if (mode === 'mobile-first') {
const role = Array.from(handleEl.attributes).find((attr) => attr.name === 'role')
const name = role && role.value
isClickBar = hasClass(handleEl, constants.sliderCls(mode)) || hasClass(handleEl, constants.rangeCls(mode))
isClickBtn =
hasClass(handleEl, constants.buttonCls(mode)) ||
hasClass(handleEl, constants.leftSvgCls(mode)) ||
hasClass(handleEl, constants.rightSvgCls(mode))
isClickLabel = hasClass(handleEl, constants.PC_LABEL_CLS)

isClickBar = name === constants.PC_SLIDER_CLS || name === constants.PC_RANGE_CLS
isClickBtn = name === constants.PC_BUTTON_CLS
} else {
isClickBar = hasClass(handleEl, constants.sliderCls(mode)) || hasClass(handleEl, constants.rangeCls(mode))
isClickBtn =
hasClass(handleEl, constants.buttonCls(mode)) ||
hasClass(handleEl, constants.leftSvgCls(mode)) ||
hasClass(handleEl, constants.rightSvgCls(mode))
isClickLabel = hasClass(handleEl, constants.PC_LABEL_CLS)
}
if (state.disabled || (!isClickBtn && !isClickBar && !isClickLabel)) {
state.activeIndex = -1
return
Expand Down
Loading