Skip to content

Commit

Permalink
fix(Slider): slider btn cannot drag in mobile device (#4860)
Browse files Browse the repository at this point in the history
* fix(Slider): slider btn cannot drag in mobile device

* fix(Slider): slider btn cannot drag in mobile device

---------

Co-authored-by: Ethan Zhao <ethan.zhao@henkel.com>
  • Loading branch information
zd5043039119 and Ethan Zhao authored Dec 23, 2024
1 parent 975d3cc commit 020f13a
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/slider/slider-button.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import {
PropType,
defineComponent,
ComponentPublicInstance,
ref,
PropType,
computed,
reactive,
defineComponent,
inject,
nextTick,
reactive,
ref,
watchEffect,
inject,
} from 'vue';
import TTooltip from '../tooltip/index';
import { TdSliderProps } from './type';

import isFunction from 'lodash/isFunction';
import { usePrefixClass } from '../hooks/useConfig';
import { useSliderTooltip } from './hooks/useSliderTooltip';
import { sliderPropsInjectKey } from './util/constants';
import isFunction from 'lodash/isFunction';

export default defineComponent({
name: 'TSliderButton',
Expand Down Expand Up @@ -147,10 +147,16 @@ export default defineComponent({
}
let diff = 0;
const parentSliderSize = parentProps.sliderSize;
const { type } = event;
let { clientY, clientX } = event as MouseEvent;
if (type === 'touchmove') {
const touch = (event as TouchEvent).touches;
[clientY, clientX] = [touch[0].clientY, touch[0].clientX];
}
if (props.vertical) {
diff = slideButtonProps.startY - (event as MouseEvent).clientY;
diff = slideButtonProps.startY - clientY;
} else {
diff = (event as MouseEvent).clientX - slideButtonProps.startX;
diff = clientX - slideButtonProps.startX;
}
diff = (diff / parentSliderSize) * 100;
slideButtonProps.newPos = slideButtonProps.startPos + diff;
Expand Down

0 comments on commit 020f13a

Please sign in to comment.