(props: IPhotoSliderProps)
| 77 | }; |
| 78 | |
| 79 | export default function PhotoSlider(props: IPhotoSliderProps) { |
| 80 | const { |
| 81 | loop = 3, |
| 82 | speed: speedFn, |
| 83 | easing: easingFn, |
| 84 | photoClosable, |
| 85 | maskClosable = true, |
| 86 | maskOpacity = defaultOpacity, |
| 87 | pullClosable = true, |
| 88 | bannerVisible = true, |
| 89 | overlayRender, |
| 90 | toolbarRender, |
| 91 | className, |
| 92 | maskClassName, |
| 93 | photoClassName, |
| 94 | photoWrapClassName, |
| 95 | loadingElement, |
| 96 | brokenElement, |
| 97 | images, |
| 98 | index: controlledIndex = 0, |
| 99 | onIndexChange: controlledIndexChange, |
| 100 | visible, |
| 101 | onClose, |
| 102 | afterClose, |
| 103 | portalContainer, |
| 104 | } = props; |
| 105 | |
| 106 | const [state, updateState] = useSetState(initialState); |
| 107 | const [innerIndex, updateInnerIndex] = useState(0); |
| 108 | |
| 109 | const { |
| 110 | x, |
| 111 | touched, |
| 112 | pause, |
| 113 | |
| 114 | lastCX, |
| 115 | lastCY, |
| 116 | |
| 117 | bg = maskOpacity, |
| 118 | lastBg, |
| 119 | overlay, |
| 120 | minimal, |
| 121 | |
| 122 | scale, |
| 123 | rotate, |
| 124 | onScale, |
| 125 | onRotate, |
| 126 | } = state; |
| 127 | |
| 128 | // 受控 index |
| 129 | const isControlled = props.hasOwnProperty('index'); |
| 130 | const index = isControlled ? controlledIndex : innerIndex; |
| 131 | const onIndexChange = isControlled ? controlledIndexChange : updateInnerIndex; |
| 132 | // 内部虚拟 index |
| 133 | const virtualIndexRef = useRef(index); |
| 134 | |
| 135 | // 当前图片 |
| 136 | const imageLength = images.length; |
nothing calls this directly
no test coverage detected
searching dependent graphs…