mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-18 12:34:25 +08:00
fix(date-picker): block transition when calendar time change
This commit is contained in:
parent
86a51f4fa3
commit
697e649edb
@ -27,8 +27,8 @@ export default {
|
||||
if (this.active) {
|
||||
this.noTransition = true
|
||||
this.$nextTick().then(() => {
|
||||
if (this.$refs.self) {
|
||||
this.$refs.self.getBoundingClientRect()
|
||||
if (this.$el) {
|
||||
this.$el.getBoundingClientRect()
|
||||
}
|
||||
this.noTransition = false
|
||||
})
|
||||
|
@ -74,8 +74,8 @@
|
||||
class="n-date-picker-calendar__dates"
|
||||
>
|
||||
<div
|
||||
v-for="dateItem in dateArray(startCalendarDateTime, valueAsMomentArray, currentDateTime)"
|
||||
:key="`${dateItem.timestamp}${dateItem.isDateOfDisplayMonth}`"
|
||||
v-for="(dateItem, i) in dateArray(startCalendarDateTime, valueAsMomentArray, currentDateTime)"
|
||||
:key="i"
|
||||
class="n-date-picker-calendar__date"
|
||||
:class="{
|
||||
'n-date-picker-calendar__date--current': dateItem.isCurrentDate,
|
||||
@ -159,8 +159,8 @@
|
||||
class="n-date-picker-calendar__dates"
|
||||
>
|
||||
<div
|
||||
v-for="dateItem in dateArray(endCalendarDateTime, valueAsMomentArray, currentDateTime)"
|
||||
:key="`${dateItem.timestamp}${dateItem.isDateOfDisplayMonth}`"
|
||||
v-for="(dateItem, i) in dateArray(endCalendarDateTime, valueAsMomentArray, currentDateTime)"
|
||||
:key="i"
|
||||
class="n-date-picker-calendar__date"
|
||||
:class="{
|
||||
'n-date-picker-calendar__date--current': dateItem.isCurrentDate,
|
||||
|
@ -106,8 +106,8 @@
|
||||
class="n-date-picker-calendar__dates"
|
||||
>
|
||||
<div
|
||||
v-for="dateItem in dateArray(startCalendarDateTime, valueAsMomentArray, currentDateTime)"
|
||||
:key="`${dateItem.timestamp}${dateItem.isDateOfDisplayMonth}`"
|
||||
v-for="(dateItem, i) in dateArray(startCalendarDateTime, valueAsMomentArray, currentDateTime)"
|
||||
:key="i"
|
||||
class="n-date-picker-calendar__date"
|
||||
:class="{
|
||||
'n-date-picker-calendar__date--current': dateItem.isCurrentDate,
|
||||
@ -191,8 +191,8 @@
|
||||
class="n-date-picker-calendar__dates"
|
||||
>
|
||||
<div
|
||||
v-for="dateItem in dateArray(endCalendarDateTime, valueAsMomentArray, currentDateTime)"
|
||||
:key="`${dateItem.timestamp}${dateItem.isDateOfDisplayMonth}`"
|
||||
v-for="(dateItem, i) in dateArray(endCalendarDateTime, valueAsMomentArray, currentDateTime)"
|
||||
:key="i"
|
||||
class="n-date-picker-calendar__date"
|
||||
:class="{
|
||||
'n-date-picker-calendar__date--current': dateItem.isCurrentDate,
|
||||
|
@ -68,6 +68,28 @@ export default {
|
||||
} else return null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
startCalendarDateTime (newCalendarDateTime, oldCalendarDateTime) {
|
||||
if (newCalendarDateTime.isValid() && oldCalendarDateTime) {
|
||||
if (
|
||||
newCalendarDateTime.year() !== oldCalendarDateTime.year() ||
|
||||
newCalendarDateTime.month() !== oldCalendarDateTime.month()
|
||||
) {
|
||||
this.banTransitionOneTick()
|
||||
}
|
||||
}
|
||||
},
|
||||
endCalendarDateTime (newCalendarDateTime, oldCalendarDateTime) {
|
||||
if (newCalendarDateTime.isValid() && oldCalendarDateTime) {
|
||||
if (
|
||||
newCalendarDateTime.year() !== oldCalendarDateTime.year() ||
|
||||
newCalendarDateTime.month() !== oldCalendarDateTime.month()
|
||||
) {
|
||||
this.banTransitionOneTick()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
resetSelectingStatus (e) {
|
||||
if (this.$refs.startDates.contains(e.target) || this.$refs.endDates.contains(e.target)) {
|
||||
|
@ -170,16 +170,16 @@ export default {
|
||||
}
|
||||
},
|
||||
nextYear () {
|
||||
this.calendarDateTime = moment(this.calendarDateTime.add(1, 'year'))
|
||||
this.calendarDateTime = moment(this.calendarDateTime).add(1, 'year')
|
||||
},
|
||||
prevYear () {
|
||||
this.calendarDateTime = moment(this.calendarDateTime.subtract(1, 'year'))
|
||||
this.calendarDateTime = moment(this.calendarDateTime).subtract(1, 'year')
|
||||
},
|
||||
nextMonth () {
|
||||
this.calendarDateTime = moment(this.calendarDateTime.add(1, 'month'))
|
||||
this.calendarDateTime = moment(this.calendarDateTime).add(1, 'month')
|
||||
},
|
||||
prevMonth () {
|
||||
this.calendarDateTime = moment(this.calendarDateTime.subtract(1, 'month'))
|
||||
this.calendarDateTime = moment(this.calendarDateTime).subtract(1, 'month')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user