0.0.3 • Published 6 years ago

focus-tracker v0.0.3

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

focus-tracker

Track focus events on fields, the currently active field and call blur functions automatically when switching active fields.

React/RN implementation:

Focus Tracker is implemented as a Singleton.

Example React Native

import FocusTracker from "focus-tracker";

class Example extends React.Component<{},{}>{
	constructor(){
    //set this._refID to a unique
	}
	componentDidMount(){
	  FocusTracker.registerListener({
		  lostFocus: this.blur,
		  hasFocus: false,
		  reference: this._refID //Unique ID
		});
	}
	blur(){
		//Blur focus
	}
	onFocus(){
		FocusTracker.registerListener({
		  lostFocus: this.blur,
		  hasFocus: true,
		  reference: this._refID
		});
	}
	componentWillUnmount(){
		FocusTracker.unregisterListener(this._refID);
	}
}
0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago