Skip to content

Commit 772cfce

Browse files
committed
ver 1.1.7
1 parent 171de1b commit 772cfce

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ android: api 21+
44
ios : 10.0+
55
web: svg
66

7-
<img src="./src/demo.jpg" width="200">
7+
Example --> [Demo](https://github.com/Only-IceSoul/canal/tree/master/react-native/LiquidSwipe/ClipPath)
8+
<img src="./src/demo.jpg" width="300">
89

910
## Getting started
1011

11-
`$ npm install react-native-clippathview --save`
12+
`$ npm install react-native-clippathview --save`
1213
`$ react-native link react-native-clippathview`
1314

1415
### Yarn

index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Constructor, NativeMethods, ViewProps } from "react-native";
33

44

55
interface ClipPathViewProps extends ViewProps {
6-
svgKey:string // web
7-
d:string
6+
svgKey?:string // web
7+
d?:string
88
viewBox?:number[]
99
aspect?: 'meet' | 'slice' | 'none'
1010
align?:'xMinYMin'|

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-clippathview",
33
"title": "React Native ClipPath",
4-
"version": "1.1.6",
4+
"version": "1.1.7",
55
"description": "ClipPath Android Web IOS",
66
"main": "index.js",
77
"files": [

src/ClipPathWeb.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ const ClipPathWeb = React.forwardRef((props,ref) =>{
202202
const [bounds,setbounds] = useState({w:0,h:0})
203203

204204
const finalPath = useMemo(()=>{
205-
if(d.length > 0 && bounds.w > 0 && bounds.h > 0){
205+
206+
if(path.length > 0 && bounds.w > 0 && bounds.h > 0){
207+
206208
var vbLeft = vb[0]
207209
var vbTop = vb[1]
208210
var vbWidth = vb[2]
@@ -308,8 +310,8 @@ const ClipPathWeb = React.forwardRef((props,ref) =>{
308310
},[bounds,dx,dy,scaleY,scaleX,scaleOX,scaleOY,path,rotation,rotationOX,rotationOY,asp,alg,vb,scalePercent,transPercent,rotationPercent])
309311

310312
useLayoutEffect(()=>{
311-
let w = myRef.current.clientWidth
312-
let h = myRef.current.clientHeight
313+
let w = myRef.current?.clientWidth || 0
314+
let h = myRef.current?.clientHeight || 0
313315
if(w !== bounds.w || h !== bounds.h ){
314316
setbounds({w:w,h:h})
315317
}
@@ -319,7 +321,7 @@ const ClipPathWeb = React.forwardRef((props,ref) =>{
319321

320322
return(
321323
<>
322-
<div {...rest} ref={myRef} style={{...styleObject,clipPath:`${d.length > 0 ? `url(#${keyClip})` : ''}`, zIndex:zIndex}} >
324+
<div {...rest} ref={myRef} style={{...styleObject,clipPath:`${path.length > 0 ? `url(#${keyClip})` : ''}`, zIndex:zIndex}} >
323325

324326
</div>
325327
<svg style={{width:0,height:0}}>

src/demo.jpg

37.2 KB
Loading

0 commit comments

Comments
 (0)