@@ -3,18 +3,11 @@ import classnames from 'classnames'
3
3
import dayjs from 'dayjs'
4
4
import { delayQuerySelector } from '../../../utils/common'
5
5
import generateCalendarGroup from '../common/helper'
6
- import AtCalendarDateList from '../ui/date-list/index.vue'
7
- import AtCalendarDayList from '../ui/day-list/index.vue'
8
6
import mixins from '../../mixins'
9
7
10
8
const ANIMTE_DURATION = 300
11
9
12
10
const AtCalendarBody = Vue . extend ( {
13
- name : 'AtCalendarBody' ,
14
- components : {
15
- AtCalendarDateList,
16
- AtCalendarDayList,
17
- } ,
18
11
mixins : [ mixins ] ,
19
12
props : {
20
13
marks : {
@@ -62,12 +55,22 @@ const AtCalendarBody = Vue.extend({
62
55
} ,
63
56
onDayClick : {
64
57
type : Function ,
65
- default : ( ) => ( ) => { } ,
58
+ default : function ( ) {
59
+ return ( ) => { }
60
+ } ,
66
61
} ,
67
62
onLongClick : {
68
63
type : Function ,
69
- default : ( ) => ( ) => { } ,
64
+ default : function ( ) {
65
+ return ( ) => { }
66
+ } ,
70
67
} ,
68
+ onSwipeMonth : {
69
+ type : Function ,
70
+ default : function ( ) {
71
+ return ( ) => { }
72
+ }
73
+ }
71
74
} ,
72
75
data ( ) {
73
76
const { validDates, marks, format, minDate, maxDate, selectedDates } = this
@@ -93,6 +96,7 @@ const AtCalendarBody = Vue.extend({
93
96
offsetSize : 0 ,
94
97
isAnimate : false ,
95
98
} ,
99
+ isH5 : process . env . TARO_ENV === 'h5' ,
96
100
}
97
101
} ,
98
102
computed : {
@@ -118,6 +122,32 @@ const AtCalendarBody = Vue.extend({
118
122
selectedDates,
119
123
}
120
124
} ,
125
+ h5CalendarBody ( ) {
126
+ return classnames (
127
+ 'main' ,
128
+ 'at-calendar-slider__main' ,
129
+ `at-calendar-slider__main--${ process . env . TARO_ENV } `
130
+ )
131
+ } ,
132
+ h5CalendarMainBodyCls ( ) {
133
+ const { isSwiper, isAnimate } = this
134
+ return classnames ( 'main__body body' , {
135
+ 'main__body--slider' : isSwiper ,
136
+ 'main__body--animate' : isAnimate
137
+ } )
138
+ } ,
139
+ h5CalendarMainBodyStyle ( ) {
140
+ const { isSwiper } = this
141
+ const { offsetSize } = this . state
142
+ return {
143
+ transform : isSwiper
144
+ ? `translateX(-100%) translate3d(${ offsetSize } ,0,0)`
145
+ : '' ,
146
+ WebkitTransform : isSwiper
147
+ ? `translateX(-100%) translate3d(${ offsetSize } px,0,0)`
148
+ : ''
149
+ }
150
+ }
121
151
} ,
122
152
watch : {
123
153
nextProps ( val ) {
@@ -155,7 +185,9 @@ const AtCalendarBody = Vue.extend({
155
185
} ,
156
186
mounted ( ) {
157
187
delayQuerySelector ( this , '.at-calendar-slider__main' ) . then ( ( res ) => {
158
- this . maxWidth = res [ 0 ] . width
188
+ if ( res [ 0 ] ) {
189
+ this . maxWidth = res [ 0 ] . width
190
+ }
159
191
} )
160
192
} ,
161
193
methods : {
@@ -241,7 +273,7 @@ const AtCalendarBody = Vue.extend({
241
273
if ( absOffsetSize > breakpoint ) {
242
274
const res = isRight ? this . maxWidth : - this . maxWidth
243
275
return this . animateMoveSlide ( res , ( ) => {
244
- this . atSwipeMonth ( isRight ? - 1 : 1 )
276
+ this . onSwipeMonth ( isRight ? - 1 : 1 )
245
277
} )
246
278
}
247
279
this . animateMoveSlide ( 0 )
@@ -256,7 +288,7 @@ const AtCalendarBody = Vue.extend({
256
288
} ,
257
289
handleAnimateFinish ( ) {
258
290
if ( this . changeCount > 0 ) {
259
- this . atSwipeMonth ( this . isPreMonth ? - this . changeCount : this . changeCount )
291
+ this . onSwipeMonth ( this . isPreMonth ? - this . changeCount : this . changeCount )
260
292
this . changeCount = 0
261
293
}
262
294
} ,
0 commit comments