react-native-resource-calendar 1.0.23 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -362,6 +362,7 @@ var TimeLabels = React19__namespace.forwardRef(({
362
362
  const isToday = dateFns.isSameDay(/* @__PURE__ */ new Date(), date);
363
363
  const [currentTimeYPosition, setCurrentTimeYPosition] = React19.useState(timeToYPosition(getCurrentTimeInMinutes(timezone), hourHeight));
364
364
  const [currentTime, setCurrentTime] = React19.useState(dateFns.format(dateFnsTz.toZonedTime(/* @__PURE__ */ new Date(), timezone), "h:mm"));
365
+ const APPOINTMENT_BLOCK_HEIGHT = hourHeight / 4;
365
366
  const updateCurrentTimeYPosition = () => {
366
367
  setCurrentTimeYPosition(timeToYPosition(getCurrentTimeInMinutes(timezone), hourHeight));
367
368
  };
@@ -378,6 +379,22 @@ var TimeLabels = React19__namespace.forwardRef(({
378
379
  const intervalId = setInterval(update, 300);
379
380
  return () => clearInterval(intervalId);
380
381
  }, [timezone]);
382
+ const lastScrolledDateRef = React19.useRef(null);
383
+ React19.useEffect(() => {
384
+ if (!layout) return;
385
+ const dateKey = date.getTime();
386
+ if (lastScrolledDateRef.current === dateKey) return;
387
+ reactNative.InteractionManager.runAfterInteractions(() => {
388
+ let pos = isToday ? currentTimeYPosition - 240 : timeToYPosition(startMinutes, hourHeight);
389
+ if (ref.current) {
390
+ ref.current.scrollTo({
391
+ y: Math.round(pos / APPOINTMENT_BLOCK_HEIGHT) * APPOINTMENT_BLOCK_HEIGHT,
392
+ animated: true
393
+ });
394
+ lastScrolledDateRef.current = dateKey;
395
+ }
396
+ });
397
+ }, [layout, date, isToday, APPOINTMENT_BLOCK_HEIGHT, startMinutes, hourHeight, currentTimeYPosition]);
381
398
  return /* @__PURE__ */ React19__namespace.createElement(React19__namespace.Fragment, null, /* @__PURE__ */ React19__namespace.createElement(Col_default, null, Array.from({ length: 24 }).map((_, index) => /* @__PURE__ */ React19__namespace.createElement(reactNative.View, { key: index, style: [styles.timeLabel, { height: hourHeight }] }, /* @__PURE__ */ React19__namespace.createElement(
382
399
  reactNative.Text,
383
400
  {
@@ -1350,7 +1367,7 @@ var CalendarInner = (props) => {
1350
1367
  const {
1351
1368
  date,
1352
1369
  numberOfColumns: numberOfColumnsProp = 3,
1353
- startMinutes = 0,
1370
+ startMinutes,
1354
1371
  hourHeight = 120,
1355
1372
  snapIntervalInMinutes = 5,
1356
1373
  timezone = Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone,
@@ -1769,22 +1786,6 @@ var CalendarInner = (props) => {
1769
1786
  React19.useEffect(() => {
1770
1787
  dateRef.current = date;
1771
1788
  }, [date]);
1772
- const lastScrolledDateRef = React19.useRef(null);
1773
- React19.useEffect(() => {
1774
- if (!layout) return;
1775
- const isToday = dateFns.isSameDay(/* @__PURE__ */ new Date(), date);
1776
- const APPOINTMENT_BLOCK_HEIGHT = hourHeight / 4;
1777
- const dateKey = date.getTime();
1778
- const currentTimeYPosition = timeToYPosition(getCurrentTimeInMinutes(timezone), hourHeight);
1779
- if (lastScrolledDateRef.current === dateKey) return;
1780
- let pos = isToday ? currentTimeYPosition - 240 : timeToYPosition(startMinutes, hourHeight);
1781
- const y = Math.round(pos / APPOINTMENT_BLOCK_HEIGHT) * APPOINTMENT_BLOCK_HEIGHT;
1782
- Animated2.runOnUI((yVal) => {
1783
- "worklet";
1784
- Animated2.scrollTo(verticalScrollViewRef, 0, yVal, true);
1785
- })(y);
1786
- lastScrolledDateRef.current = dateKey;
1787
- }, [layout, date, startMinutes, hourHeight]);
1788
1789
  const renderItem = React19.useCallback(({ item, index }) => {
1789
1790
  const rid = !isMultiDay ? item : activeResourceId ?? resourceIds[0];
1790
1791
  const dayDate = !isMultiDay ? void 0 : item.dayDate;