import React from 'react';
import inViewport from 'in-viewport';





class Widget extends React.Component {
	constructor(props) {
		super(props);

		this.viewportHandler = this.viewportHandler.bind(this);
	}
	componentDidMount(){
		this.watcher = new inViewport(this.widget, { offset: 1000, debounce: 300 }, this.viewportHandler);
	}
	viewportHandler(){
		this.props.viewportHandler(this.widget.id);
		this.watcher.watch();
	}

	render() {
		return (
			<div ref={ widget => { this.widget = widget } } id="widget" className="header">
				<div className="container">
					<a href="/">Evalotta</a>
				</div>
			</div>
		);
	}
}

export default Widget;
