Skip to content

Commit

Permalink
fix(calendar): 修复日历组件滚动问题 + 修复手机机型兼容问题
Browse files Browse the repository at this point in the history
  • Loading branch information
SzHeJason committed Nov 26, 2018
1 parent c723dd9 commit fd544a0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
4 changes: 1 addition & 3 deletions src/components/calendar/body/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@include display-flex;

width: 100%;
margin-bottom: 20px;

&--animate {
transition: transform 300ms cubic-bezier(0.36, 0.66, 0.04, 1);
Expand All @@ -18,8 +17,7 @@

&--weapp {
.main__body {
// prettier-ignore
height: 235PX;
height: 480px;
}
}
}
12 changes: 7 additions & 5 deletions src/components/calendar/body/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,17 @@ export default class AtCalendarBody extends Taro.Component<
}

@bind
private handleChange (e: BaseEvent & { detail: { current: number } }) {
const { current } = e.detail
this.currentSwiperIndex = current
this.changeCount = this.changeCount + 1
private handleChange (e: BaseEvent) {
const { current, source } = e.detail

if (source === 'touch') {
this.currentSwiperIndex = current
this.changeCount = this.changeCount + 1
}
}

@bind
private handleAnimateFinish () {
console.log(this.currentSwiperIndex)
if (this.changeCount > 0) {
this.props.onSwipeMonth(
this.isPreMonth ? -this.changeCount : this.changeCount
Expand Down
20 changes: 13 additions & 7 deletions src/components/calendar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,26 +117,32 @@ export default class AtCalendar extends Taro.Component<Props, Readonly<State>> {
): State {
let end: number
let start: number
let generateDateValue: number

if (isMultiSelect) {
const { start: cStart, end: cEnd } = currentDate as Calendar.SelectedDate
start = dayjs(cStart)
.startOf('day')
.valueOf()

const dayjsStart = dayjs(cStart)

start = dayjsStart.startOf('day').valueOf()
generateDateValue = dayjsStart.startOf('month').valueOf()

end = cEnd
? dayjs(cEnd)
.startOf('day')
.valueOf()
: start
} else {
start = dayjs(currentDate as Calendar.DateArg)
.startOf('day')
.valueOf()
const dayjsStart = dayjs(currentDate as Calendar.DateArg)

start = dayjsStart.startOf('day').valueOf()
generateDateValue = dayjsStart.startOf('month').valueOf()

end = start
}

return {
generateDate: start,
generateDate: generateDateValue,
selectedDate: this.getSelectedDate(start, end)
}
}
Expand Down

0 comments on commit fd544a0

Please sign in to comment.