react-native-js-only-modal
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -16,2 +16,3 @@ import * as React from 'react'; | ||
const data = { | ||
updating: undefined, | ||
items: new Map(), | ||
@@ -48,6 +49,14 @@ update: () => { }, | ||
const ModalContainer = () => { | ||
const [_, setUpdater] = useState(0); | ||
const [updater, setUpdater] = useState(0); | ||
const [items] = useState(new Map()); | ||
const context = useContext(ContextProvider); | ||
context.update = () => setUpdater((x) => (x > 1000 ? 0 : x) + 1); | ||
useEffect(() => { | ||
context.updating = false; | ||
}, [updater]); | ||
context.update = () => { | ||
if (context.updating) | ||
return; | ||
context.updating = true; | ||
setUpdater((x) => (x > 1000 ? 0 : x) + 1); | ||
}; | ||
context.items = items; | ||
@@ -117,9 +126,9 @@ const rItem = []; | ||
const assignValue = (k, value) => { | ||
if (keys.find(x => x === k)) | ||
if (keys.find((x) => x === k)) | ||
styleSizeProps[k] = value; | ||
}; | ||
assignValue("width", stringSizeToNumber(style.width, size.width)); | ||
assignValue("minWidth", stringSizeToNumber(style.minWidth, size.width)); | ||
assignValue("minHeight", stringSizeToNumber(style.minHeight, size.height)); | ||
assignValue("height", stringSizeToNumber(style.height, size.height)); | ||
assignValue('width', stringSizeToNumber(style.width, size.width)); | ||
assignValue('minWidth', stringSizeToNumber(style.minWidth, size.width)); | ||
assignValue('minHeight', stringSizeToNumber(style.minHeight, size.height)); | ||
assignValue('height', stringSizeToNumber(style.height, size.height)); | ||
} | ||
@@ -151,5 +160,6 @@ }; | ||
else | ||
item.component.layoutData = { ...e.nativeEvent.layout, | ||
item.component.layoutData = { | ||
...e.nativeEvent.layout, | ||
width: Math.max(e.nativeEvent.layout.width ?? 0, e.nativeEvent.layout.width), | ||
height: Math.max(e.nativeEvent.layout.height ?? 0, e.nativeEvent.layout.height) | ||
height: Math.max(e.nativeEvent.layout.height ?? 0, e.nativeEvent.layout.height), | ||
}; | ||
@@ -190,3 +200,7 @@ }; | ||
}}> | ||
<View onLayout={onLayout} style={{ flexDirection: 'column', ...styleSizeProps, backgroundColor: "transparent" }}> | ||
<View onLayout={onLayout} style={{ | ||
flexDirection: 'column', | ||
...styleSizeProps, | ||
backgroundColor: 'transparent', | ||
}}> | ||
<View onLayout={onLayout} {...item.component.props} style={viewStyle()}/> | ||
@@ -193,0 +207,0 @@ </View> |
@@ -48,2 +48,3 @@ /// <reference types="react" /> | ||
zIndex: number; | ||
updating?: boolean; | ||
}; |
{ | ||
"name": "react-native-js-only-modal", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "An enhanced, animated, customizable Modal for React Native. This is a javascript only Modal", | ||
@@ -5,0 +5,0 @@ "author": "AlenToma", |
@@ -47,2 +47,3 @@ import { ViewStyle, StyleProp } from 'react-native'; | ||
zIndex: number; | ||
updating?: boolean; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
43617
761