Skip to content

Commit

Permalink
feat: bump
Browse files Browse the repository at this point in the history
  • Loading branch information
bobihuang committed Sep 19, 2024
1 parent 90e4e95 commit aad22b6
Show file tree
Hide file tree
Showing 6 changed files with 5,630 additions and 4,791 deletions.
2 changes: 2 additions & 0 deletions dist/Lightbox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface LightboxProps<T = any> extends IGestureProps {
onOpen?: Func<T, void>;
willClose?: Func<T, void>;
onClose?: Func<T, void>;
onPress?: Func<T, void>;
onLongPress?: Func<T, void>;
onLayout?: Func<T, void>;
swipeToDismiss?: boolean;
Expand All @@ -32,6 +33,7 @@ export interface LightboxProps<T = any> extends IGestureProps {
useNativeDriver?: boolean;
dragDismissThreshold?: number;
modalProps?: ModalProps;
openOnLongPress?: boolean;
}
declare const Lightbox: React.FC<LightboxProps>;
export default Lightbox;
4 changes: 2 additions & 2 deletions dist/Lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Animated, TouchableHighlight, View, } from "react-native";
import LightboxOverlay from "./LightboxOverlay";
import { useNextTick } from "./hooks";
const noop = () => { };
const Lightbox = ({ activeProps, swipeToDismiss = true, useNativeDriver = false, disabled = false, renderContent, renderHeader, renderItem, didOpen = noop, onOpen = noop, willClose = noop, onClose = noop, onLongPress = noop, onLayout = noop, springConfig = { tension: 30, friction: 7 }, backgroundColor = "black", underlayColor, style, dragDismissThreshold = 150, children, modalProps = {}, ...rest }) => {
const Lightbox = ({ activeProps, swipeToDismiss = true, useNativeDriver = false, disabled = false, renderContent, renderHeader, renderItem, didOpen = noop, onOpen = noop, willClose = noop, onClose = noop, onPress = noop, onLongPress = noop, onLayout = noop, springConfig = { tension: 30, friction: 7 }, backgroundColor = "black", underlayColor, style, dragDismissThreshold = 150, children, modalProps = {}, openOnLongPress = false, ...rest }) => {
const layoutOpacity = useRef(new Animated.Value(1));
const _root = useRef(null);
const closeNextTick = useNextTick(onClose);
Expand Down Expand Up @@ -64,7 +64,7 @@ const Lightbox = ({ activeProps, swipeToDismiss = true, useNativeDriver = false,
if (renderItem) {
return renderItem(open);
}
return (<TouchableHighlight underlayColor={underlayColor} onPress={open} onLongPress={onLongPress} disabled={disabled}>
return (<TouchableHighlight underlayColor={underlayColor} onPress={openOnLongPress ? onPress : open} onLongPress={openOnLongPress ? open : onLongPress} disabled={disabled}>
{children}
</TouchableHighlight>);
};
Expand Down
19 changes: 17 additions & 2 deletions dist/LightboxOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const LightboxOverlay = ({ useNativeDriver = false, dragDismissThreshold, spring
longPressGapTimer,
longPressCallback,
});
const [deviceWidth, setDeviceWidth] = useState(Dimensions.get('window').width);
const [deviceHeight, setDeviceHeight] = useState(Dimensions.get('window').height);
const [{ isAnimating, isPanning, target }, setState] = useState({
isAnimating: false,
isPanning: false,
Expand Down Expand Up @@ -156,6 +158,19 @@ const LightboxOverlay = ({ useNativeDriver = false, dragDismissThreshold, spring
},
});
};
useEffect(() => {
const onChange = ({ window }) => {
setDeviceWidth(window.width);
setDeviceHeight(window.height);
};
const removeEventListener = () => {
if (Dimensions.removeEventListener) {
Dimensions.removeEventListener('change', onChange);
}
};
Dimensions.addEventListener('change', onChange);
return removeEventListener;
}, []);
useEffect(() => {
initPanResponder();
}, [useNativeDriver, isAnimating]);
Expand Down Expand Up @@ -196,11 +211,11 @@ const LightboxOverlay = ({ useNativeDriver = false, dragDismissThreshold, spring
}),
width: openVal.current.interpolate({
inputRange: [0, 1],
outputRange: [origin.width, WINDOW_WIDTH],
outputRange: [origin.width, deviceWidth],
}),
height: openVal.current.interpolate({
inputRange: [0, 1],
outputRange: [origin.height, WINDOW_HEIGHT],
outputRange: [origin.height, deviceHeight],
}),
},
];
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-lightbox-v2",
"version": "0.9.1",
"version": "0.9.2",
"description": "Images etc in Full Screen Lightbox Popovers for React Native",
"main": "dist/Lightbox.js",
"types": "dist/Lightbox.d.ts",
Expand Down Expand Up @@ -40,7 +40,7 @@
},
"homepage": "https://github.com/cbbfcd/react-native-lightbox",
"devDependencies": {
"@babel/runtime": "7.7.4",
"@babel/runtime": "7.25.6",
"@types/react": "16.9.13",
"@types/react-native": "0.69.3",
"react": "16.12.0",
Expand Down
Loading

0 comments on commit aad22b6

Please sign in to comment.