Open4

@yamada-ui/Swipeableの記録

108えん108えん

Viewがdivみたいなやつらしい。でonLayoutのnativeEventで要素のxの位置とってそう
https://reactnative.dev/docs/layoutevent
幅は?
このViewでとってるのは境界のいち?

https://github.com/software-mansion/react-native-gesture-handler/blob/0fccc4209cae199cda25e68228128136e49b66e2/src/components/Swipeable.tsx#L533-L537

108えん108えん

一旦こんな感じで本来のwidthは取れる

swipeable-right-action.tsx
  const rightRef = useRef<HTMLDivElement>(null)
  const rightWidth = rightRef?.current?.offsetWidth ?? 0
  useEffect(() => console.log(`width:${rightWidth}`), [rightWidth])

  return (
    <motion.div
      className={cx("ui-swipeable__left-action", className)}
      ref={ref}
      style={{
        position: "absolute",
        top: 0,
        right: 0,
        height,
        width,
        overflow: "hidden",
      }}
    >
      <ui.div
        __css={{
          zIndex: -1,
          w: "100%",
          h: "100%",
          whiteSpace: "nowrap",
          display: "flex",
          justifyContent: "flex-end",
          alignItems: "center",
          background: "red.500",
          px: 4,
          ...styles.swipeableRightAction,
        }}
        {...rest}
        onClick={() => {
          setDirection("none")
        }}
      >
        <ui.div ref={rightRef} width="fit-content">
          {resolvedChildren}
        </ui.div>
      </ui.div>
    </motion.div>
  )
})