Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

✂️ React-Native component to cut a touch-through holes anywhere you want. Perfect solution for tutorial overlay

NotificationsYou must be signed in to change notification settings

ibitcy/react-native-hole-view

Repository files navigation

Screenshot

npmnpmMaintainers Wanted

Attention! Maintainers Wanted

Our company is not using this library and does not plan to in the near future, so we currently lack the resources to maintain it regularly.If you are interested in becoming a maintainer, please contact me at: newonxp [at] gmail [dot] com.

How it works

drawing

code
import{RNHoleView}from'react-native-hole-view';<Viewstyle={{flex:1,alignItems:'center',justifyContent:'center'}}><Textstyle={{flexGrow:0,flex:0,padding:10}}>{"Wow! I'm a text inside a hole!"}</Text><TouchableOpacityonPress={()=>{}}style={{backgroundColor:'pink',padding:10,borderRadius:5}}><Text>{"Wow! I'm a button inside a hole!"}</Text></TouchableOpacity><ScrollViewstyle={{flexGrow:0,flex:0,padding:10}}horizontal={true}><TextnumberOfLines={1}>{"Wow! I'm a ScrollView inside a hole! Wow! I'm a ScrollView inside a hole! Wow! I'm a ScrollView inside a hole!"}</Text></ScrollView><RNHoleViewstyle={{position:'absolute',width:'100%',height:'100%',backgroundColor:'rgba(34,146,231,0.4)'}}holes={[{x:150,y:390,width:120,height:120,borderRadius:60}]}></RNHoleView></View>

Works with any nested views:

drawing

code
import{RNHoleView}from'react-native-hole-viewimportVideofrom 'react-native-video';<Viewstyle={{flex:1,alignItems:'center',justifyContent:'center'}}><Textstyle={{flexGrow:0,flex:0,padding:10}}>{"Wow! I'm a text inside a hole!"}</Text><TouchableOpacityonPress={()=>{}}style={{backgroundColor:'pink',padding:10,borderRadius:5}}><Text>{"Wow! I'm a button inside a hole!"}</Text></TouchableOpacity><ScrollViewstyle={{flexGrow:0,flex:0,padding:10}}horizontal={true}><TextnumberOfLines={1}>{"Wow! I'm a ScrollView inside a hole! Wow! I'm a ScrollView inside a hole! Wow! I'm a ScrollView inside a hole!"}</Text></ScrollView><RNHoleViewstyle={{position:'absolute',width:'100%',height:'100%',backgroundColor:'rgba(34,146,231,0.4)'}}holes={[{x:150,y:390,width:120,height:120,borderRadius:60}]}><Videosource={{uri:'http://clips.vorwaerts-gmbh.de/VfE_html5.mp4'}}style={{flex:1}}/></RNHoleView></View>

Can be animated:

drawing

code
import{RNHole,RNHoleView,ERNHoleViewTimingFunction,IRNHoleViewAnimation}from"react-native-hole-view";importVideofrom'react-native-video';constfirstHole:RNHole={x:150,y:390,width:120,height:120,borderRadius:60};constsecondHole:RNHole={x:150,y:40,width:120,height:120,borderRadius:60};constanimationSettings:IRNHoleViewAnimation={timingFunction:ERNHoleViewTimingFunction.EASE_IN_OUT,duration:200};constApp=()=>{const[holes,setHoles]=useState<RNHole[]>([]);const[animated,setAnimated]=useState<boolean>(false);const[animation,setAnimation]=useState<IRNHoleViewAnimation|undefined>(undefined);constonPress=useCallback(()=>{if(animated){setHoles([firstHole]);}else{setHoles([secondHole])}setAnimation({...animationSettings});setAnimated(!animated);},[animated,animation])useEffect(()=>{onPress();},[]);return(<Viewstyle={{flex:1,alignItems:'center',justifyContent:'center'}}><Textstyle={{flexGrow:0,flex:0,padding:10}}>{"Wow! I'm a text inside a hole!"}</Text><TouchableOpacityonPress={()=>{}}style={{backgroundColor:'pink',padding:10,borderRadius:5}}><Text>{"Wow! I'm a button inside a hole!"}</Text></TouchableOpacity><ScrollViewstyle={{flexGrow:0,flex:0,padding:10}}horizontal={true}><TextnumberOfLines={1}>{"Wow! I'm a ScrollView inside a hole! Wow! I'm a ScrollView inside a hole! Wow! I'm a ScrollView inside a hole!"}</Text></ScrollView><RNHoleViewstyle={{position:'absolute',width:'100%',height:'100%',backgroundColor:'rgba(34,146,231,0.4)'}}animation={animation}holes={holes}onAnimationFinished={()=>{setAnimation(undefined);}}><Videosource={{uri:'http://clips.vorwaerts-gmbh.de/VfE_html5.mp4'}}resizeMode={"contain"}style={{flex:1}}/></RNHoleView><ViewpointerEvents={'box-none'}style={{position:'absolute',flex:1,width:'100%',height:'100%',alignItems:'flex-end',flexDirection:'row',justifyContent:'center'}}><TouchableOpacityonPress={onPress}style={{backgroundColor:'pink',padding:10,borderRadius:5,bottom:50}}><Text>{"Animate!"}</Text></TouchableOpacity></View></View>);};

Getting started

Install the library using either Yarn:

yarn add react-native-hole-view

or npm:

npm install --save react-native-hole-view

Linking

This library fully supports RN's autolinking

iOS

cd ios && pod install

Android

By default RN doesn't support click through views on Android. The solution weuse is quite dirty, so please support our PR to FB's react-native repofacebook/react-native#28956

Troubleshooting

If you have any diffuculties - please take a look onexample/ app first.

In case you have xcode build error poining on this line

#import"RCTBridgeModule.h"

please use version 2.0.*

Running the example:

  1. Clone the repo
  2. cd example
  3. yarn
  4. cd ios
  5. pod install
  6. cd ..
  7. yarn run android oryarn run ios

About

✂️ React-Native component to cut a touch-through holes anywhere you want. Perfect solution for tutorial overlay

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp