前提
- react-nativeのモーダル
- react-responsive-carouselのカルーセル
- next/imageのImage
を使用しています。
実現したいこと
上記前提で記載したものを使用して、複数の画像を表示しております。
現在閉じるボタンを押してモーダルを閉じることはできますが、
画像の外側をクリックしてモーダルを閉じる実装を追加したいです。
該当のソースコード
現在は画像と一緒にモーダルが閉じてしまっています。
javascript
1type ImageModalProps = ModalProps & { 2 closeModal: () => void 3 images: Images 4} 5 6const ImageModal: React.FC<ImageModalProps> = ({ images, closeModal, ...rest }) => { 7 8 const contentsWidth = Dimensions.get('window').width 9 const contentsHeight = Dimensions.get('window').height 10 11 return ( 12 <Modal {...rest}> 13 <TouchableOpacity activeOpacity={1} onPressOut={() => closeModal()}> 14 <Carousel> 15 {images.image.map((img, index) => ( 16 <TouchableWithoutFeedback key={index}> 17 <div> 18 {img.file_url && ( 19 <Image 20 src={img.file_url} 21 objectFit="contain" 22 width={contentsWidth} 23 height={contentsHeight} 24 /> 25 )} 26 </div> 27 </TouchableWithoutFeedback> 28 ))} 29 </Carousel> 30 <View style={{ position: 'absolute', top: 10, right: 30 }}> 31 <TouchableOpacity onPress={() => closeModal()}> 32 <FontAwesomeIcon icon={faTimesCircle} /> 33 </TouchableOpacity> 34 </View> 35 </TouchableOpacity> 36 </Modal> 37 ) 38} 39
どなたかお分かりになる方、ご助言いただけますと幸いです。

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。