Skip to content

Commit b46388a

Browse files
committed
Fix pre commit issues
1 parent bbb086a commit b46388a

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

src/Date/Month.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,15 @@ function Month(props: MonthSingleProps | MonthRangeProps | MonthMultiProps) {
277277

278278
return (
279279
<View
280-
style={{ height: getMonthHeight(scrollMode, index, startWeekOnMonday, startYear, endYear) }}
280+
style={{
281+
height: getMonthHeight(
282+
scrollMode,
283+
index,
284+
startWeekOnMonday,
285+
startYear,
286+
endYear
287+
),
288+
}}
281289
>
282290
<View
283291
style={[
@@ -441,7 +449,7 @@ function weeksOffset(
441449
): number {
442450
const dynamicStartAtIndex = getStartAtIndex(startYear, endYear)
443451
const dynamicGridCounts = createGridCounts(getTotalMonths(startYear, endYear))
444-
452+
445453
if (index === dynamicStartAtIndex) {
446454
return 0
447455
}
@@ -482,15 +490,17 @@ export function getIndexFromVerticalOffset(
482490
): number {
483491
const dynamicStartAtIndex = getStartAtIndex(startYear, endYear)
484492
const dynamicBeginOffset = estimatedMonthHeight * dynamicStartAtIndex
485-
let estimatedIndex = dynamicStartAtIndex + Math.ceil(offset / estimatedMonthHeight)
493+
let estimatedIndex =
494+
dynamicStartAtIndex + Math.ceil(offset / estimatedMonthHeight)
486495

487496
const realOffset = getVerticalMonthsOffset(
488497
estimatedIndex,
489498
startWeekOnMonday,
490499
startYear,
491500
endYear
492501
)
493-
const difference = (realOffset - dynamicBeginOffset - offset) / estimatedMonthHeight
502+
const difference =
503+
(realOffset - dynamicBeginOffset - offset) / estimatedMonthHeight
494504
if (difference >= 1 || difference <= -1) {
495505
estimatedIndex -= Math.floor(difference)
496506
}
@@ -514,7 +524,8 @@ export function getVerticalMonthsOffset(
514524
const ob = weeksOffset(index, startWeekOnMonday, startYear, endYear)
515525
const monthsHeight = weekSize * ob
516526
const c = monthsHeight + count * (dayNamesHeight + montHeaderHeight)
517-
const dynamicBeginOffset = estimatedMonthHeight * getStartAtIndex(startYear, endYear)
527+
const dynamicBeginOffset =
528+
estimatedMonthHeight * getStartAtIndex(startYear, endYear)
518529

519530
return (c || 0) + dynamicBeginOffset
520531
}

src/Date/Swiper.native.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ function SwiperInner({
7878
}
7979
const offset = isHorizontal
8080
? getHorizontalMonthOffset(index, width)
81-
: getVerticalMonthsOffset(index, startWeekOnMonday, startYear, endYear) - montHeaderHeight
81+
: getVerticalMonthsOffset(
82+
index,
83+
startWeekOnMonday,
84+
startYear,
85+
endYear
86+
) - montHeaderHeight
8287

8388
if (isHorizontal) {
8489
parentRef.current.scrollTo({
@@ -196,7 +201,9 @@ function SwiperInner({
196201
height: isHorizontal
197202
? height
198203
: estimatedMonthHeight * getTotalMonths(startYear, endYear),
199-
width: isHorizontal ? width * getTotalMonths(startYear, endYear) : width,
204+
width: isHorizontal
205+
? width * getTotalMonths(startYear, endYear)
206+
: width,
200207
},
201208
]}
202209
>

src/Date/Swiper.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
useState,
2727
} from 'react'
2828
import { sharedStyles } from '../shared/styles'
29-
import { getTotalMonths } from './dateUtils'
3029

3130
const useIsomorphicLayoutEffect =
3231
typeof window !== 'undefined' ? useLayoutEffect : useEffect
@@ -138,10 +137,14 @@ function VerticalScroller({
138137
endYear?: number
139138
}) {
140139
// Ensure initial index is within allowed range
141-
const constrainedInitialIndex = isIndexWithinRange(initialIndex, startYear, endYear)
142-
? initialIndex
140+
const constrainedInitialIndex = isIndexWithinRange(
141+
initialIndex,
142+
startYear,
143+
endYear
144+
)
145+
? initialIndex
143146
: Math.max(
144-
Math.min(initialIndex, getMaxIndex(endYear)),
147+
Math.min(initialIndex, getMaxIndex(endYear)),
145148
getMinIndex(startYear)
146149
)
147150

src/Date/dateUtils.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,8 @@ export const totalMonths = startAtIndex * 2
202202
export const beginOffset = estimatedMonthHeight * startAtIndex
203203

204204
// Create a dynamic grid counts array
205-
export function createGridCounts(
206-
totalMonths: number
207-
): Array<number | undefined> {
208-
return new Array<number | undefined>(totalMonths)
205+
export function createGridCounts(count: number): Array<number | undefined> {
206+
return new Array<number | undefined>(count)
209207
}
210208

211209
export const gridCounts = new Array<number | undefined>(totalMonths)

0 commit comments

Comments
 (0)