react-native-resource-calendar 1.0.16 → 1.0.17

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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React19 from 'react';
2
- import React19__default, { createContext, useState, useEffect, useMemo, useContext, useRef, useCallback } from 'react';
2
+ import React19__default, { createContext, useState, useEffect, useRef, useMemo, useContext, useCallback } from 'react';
3
3
  import { Gesture, GestureDetector } from 'react-native-gesture-handler';
4
4
  import Animated2, { useSharedValue, useAnimatedRef, runOnJS, withSpring, useFrameCallback, scrollTo, useAnimatedScrollHandler, useAnimatedStyle, useAnimatedProps } from 'react-native-reanimated';
5
5
  import { InteractionManager, View, StyleSheet, Text, TouchableOpacity, TextInput, useWindowDimensions, Platform, Dimensions, Image } from 'react-native';
@@ -355,18 +355,22 @@ var TimeLabels = React19.forwardRef(({
355
355
  const intervalId = setInterval(update, 300);
356
356
  return () => clearInterval(intervalId);
357
357
  }, [timezone]);
358
+ const lastScrolledDateRef = useRef(null);
358
359
  useEffect(() => {
360
+ if (!layout) return;
361
+ const dateKey = date.getTime();
362
+ if (lastScrolledDateRef.current === dateKey) return;
359
363
  InteractionManager.runAfterInteractions(() => {
360
364
  let pos = isToday ? currentTimeYPosition - 240 : timeToYPosition(startMinutes, hourHeight);
361
365
  if (ref.current) {
362
366
  ref.current.scrollTo({
363
367
  y: Math.round(pos / APPOINTMENT_BLOCK_HEIGHT) * APPOINTMENT_BLOCK_HEIGHT,
364
- // Offset by 240px to give a little margin above the red line
365
368
  animated: true
366
369
  });
370
+ lastScrolledDateRef.current = dateKey;
367
371
  }
368
372
  });
369
- }, [date, isToday, APPOINTMENT_BLOCK_HEIGHT, startMinutes, hourHeight]);
373
+ }, [layout, date, isToday, APPOINTMENT_BLOCK_HEIGHT, startMinutes, hourHeight, currentTimeYPosition]);
370
374
  return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement(Col_default, null, Array.from({ length: 24 }).map((_, index) => /* @__PURE__ */ React19.createElement(View, { key: index, style: [styles.timeLabel, { height: hourHeight }] }, /* @__PURE__ */ React19.createElement(
371
375
  Text,
372
376
  {