mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-21 02:50:11 +08:00
fix: fix time picker scroll bug (#1227)
* fix: fix time picker scroll bug * chore: update * chore: update
This commit is contained in:
parent
1efee81cf3
commit
f2f66b3e64
@ -64,6 +64,7 @@ import {
|
||||
PropType,
|
||||
} from 'vue'
|
||||
import { Dayjs } from 'dayjs'
|
||||
import debounce from 'lodash/debounce'
|
||||
import { RepeatClick } from '@element-plus/directives'
|
||||
import ElScrollbar from '@element-plus/scrollbar'
|
||||
import { getTimeLists } from './useTimePicker'
|
||||
@ -111,6 +112,11 @@ export default defineComponent({
|
||||
|
||||
setup(props, ctx) {
|
||||
// data
|
||||
let isScrolling = false
|
||||
const debouncedResetScroll = debounce(type => {
|
||||
isScrolling = false
|
||||
adjustCurrentSpinner(type)
|
||||
}, 200)
|
||||
const currentScrollbar = ref(null)
|
||||
const listHoursRef: Ref<Nullable<HTMLElement>> = ref(null)
|
||||
const listMinutesRef: Ref<Nullable<HTMLElement>> = ref(null)
|
||||
@ -284,6 +290,8 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
const handleScroll = type => {
|
||||
isScrolling = true
|
||||
debouncedResetScroll(type)
|
||||
const value = Math.min(Math.round((listRefsMap[type].value.$el.querySelector('.el-scrollbar__wrap').scrollTop - (scrollBarHeight(type) * 0.5 - 10) / typeItemHeight(type) + 3) / typeItemHeight(type)), (type === 'hours' ? 23 : 59))
|
||||
modifyDateField(type, value)
|
||||
}
|
||||
@ -333,7 +341,10 @@ export default defineComponent({
|
||||
props.disabledSeconds,
|
||||
)
|
||||
|
||||
watch(() => props.spinnerDate, adjustSpinners)
|
||||
watch(() => props.spinnerDate, () => {
|
||||
if (isScrolling) return
|
||||
adjustSpinners()
|
||||
})
|
||||
|
||||
return {
|
||||
getRefId,
|
||||
|
Loading…
Reference in New Issue
Block a user