react-360-gaze-button
👀 Extension of React 360's
VrButton
. Gaze for {duration} ms to click the button!
Usage
- Install
npm i --save react-360-gaze-button
-
Import to your file add pass it
onClick
(function) andduration
(number, ms, defaults to 1000 ms) as props. Renders achildren
function prop that receives 3 arguments, in this order:remainingTime
: Remaining time to gaze in ms,isGazed
: boolean that indicates whether the button is being gazed, andgazeTimestamp
: the timestamp of the latest onEnter event,null
ifisGazed
isfalse
, and returns a component. You can also pass arender
prop with 1 argument, same as usingchildren
. -
You can pass any other props and it will be pased to the
VrButton
instance.
;; ; Component state = gazed: false ; { this; }; { const gazed = thisstate; return <View style=stylespanel> <GazeButton duration=3000 onClick=thissetGazed render= <View style=stylesgreetingBox> <Text style=stylesgreeting> gazed ? "You have gazed me" : isGazed ? remainingTime : "Gaze me" </Text> </View> /> </View> ; } const styles = StyleSheet; AppRegistry;
License
MIT. See LICENSE