react-native-image-viewing icon indicating copy to clipboard operation
react-native-image-viewing copied to clipboard

swipe to close is not working

Open kauthenticity opened this issue 3 years ago • 1 comments

I've tried swiping to close image viewing modal but it didn't worked... It works well on andriod but failed in ios...

if (!scaled && swipeToCloseEnabled &&Math.abs(velocityY) > SWIPE_CLOSE_VELOCITY ) { console.log("here") onRequestClose(); }

I've logged scaled, swieToCloseEnabled, Math.abs(velocityY), SWIPE_CLOSE_VELOCITY and found out velocityY was 0. I think nativeEvent didn't gives the right velocity... I hope it will be fixed soon.

Thank You!!!!!

here's my react native info System: OS: macOS 12.1 CPU: (8) arm64 Apple M1 Memory: 163.31 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.15.0 - /usr/local/bin/node Yarn: 3.2.0 - /usr/local/bin/yarn npm: 8.5.5 - /usr/local/bin/npm Watchman: 2022.05.23.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8309675 Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild Languages: Java: 11.0.15 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.68.2 => 0.68.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

kauthenticity avatar Jun 23 '22 08:06 kauthenticity

Same problem

alitsvin avatar Aug 29 '22 14:08 alitsvin

It works for me on iOS, but the threshold is set too high, i literally need to swipe all the way from the top of the screen to the bottom to close it.

rayjackson13 avatar Oct 24 '22 14:10 rayjackson13

You can change file onScrollEndDrag in folder node_modules/react-native-image-viewing/dist/components/ImageItem/ImageItem.android.js After save it patch save lại change in node module const onScrollEndDrag = ({ nativeEvent, }) => { var _a, _b, _c, _d, _e, _f; const velocityY = (_c = (_b = (_a = nativeEvent) === null || _a === void 0 ? void 0 : _a.velocity) === null || _b === void 0 ? void 0 : _b.y, (_c !== null && _c !== void 0 ? _c : 0)); const offsetY = (_f = (_e = (_d = nativeEvent) === null || _d === void 0 ? void 0 : _d.contentOffset) === null || _e === void 0 ? void 0 : _e.y, (_f !== null && _f !== void 0 ? _f : 0)); if ((Math.abs(velocityY) > SWIPE_CLOSE_VELOCITY && offsetY > SWIPE_CLOSE_OFFSET) || offsetY > SCREEN_HEIGHT / 2) { onRequestClose(); } if(_b?.y>1){ onRequestClose(); } };

vannguyen21697 avatar Feb 21 '23 03:02 vannguyen21697