howljs / react-native-calendar-kit

React Native Calendar Kit is a powerful and flexible calendar component for React Native applications. It provides a customizable and feature-rich calendar view with support for various functionalities
https://howljs.github.io/react-native-calendar-kit/docs/intro/
MIT License
443 stars 73 forks source link

Add onZoomIntervalChange #25

Closed gunnartorfis closed 1 year ago

gunnartorfis commented 1 year ago

Adding a onZoomIntervalChange would allow us to do some calculations inside renderEventContent.

For my case, I'm rendering a multi-event type event where each of the event types has to take X % of the total event's height. In order for me to calculate that, I need the current interval height - if I want to have pinch to zoom enabled.

I guess it could be added here? https://github.com/howljs/react-native-calendar-kit/blob/da8c653e55ce33d3c41e7190b1342632cb69adaf/src/hooks/usePinchGesture.tsx#L55

gunnartorfis commented 1 year ago

I can do my calculations without it, sorry about that.

snettah commented 5 months ago

I can do my calculations without it, sorry about that.

How did you do ? I also need to calculate the event height to place some cursors on the event based on the timeIntervalHeight

edit: found the solution

  const paddingTopStart = useDerivedValue(() => {
    return (timeIntervalHeight.value / 60) * pause_start
  }, [pause_start, timeIntervalHeight])

  const paddingTopEnd = useDerivedValue(() => {
    return (timeIntervalHeight.value / 60) * pause_end
  }, [pause_end, timeIntervalHeight])

  const startLineStyle = useAnimatedStyle(() => {
    return {
      top: paddingTopStart.value,
      height: paddingTopEnd.value - paddingTopStart.value,
    }
  })