{"size": 1204, "ext": "js", "max_stars_repo_path": "src/components/competence.js", "max_stars_repo_name": "yassinya/my-website", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/competence.js", "max_issues_repo_name": "yassinya/my-website", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/competence.js", "max_forks_repo_name": "yassinya/my-website", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.7555555556, "max_line_length": 219, "alphanum_fraction": 0.5880398671}
import React from 'react';

class Competence extends React.Component{

    state = {
        show: false,
        randPos: {
            top: 0,
            left: 0,
          }
    };

    componentDidMount(){
        setInterval(this.getRandamPoint, this.props.interval)
    }

    render(){
        return <span style={{position: 'absolute', left: this.state.randPos.left, top: this.state.randPos.top }} className={ this.state.show ? "competence show" : "competence hidden" }>{this.props.competenceName}</span>
    }

    fadeIn = () => {
        this.setState({show: true})
    }

    fadeOut = () => {
        this.setState({show: false})
    }

    getRandamPoint = () => {
        const windowWidth = window.innerWidth
        const windowHeight = window.innerHeight
        const maxLeft = windowWidth - 100
        const maxTop = windowHeight - 100
    
        var leftPos = Math.floor(Math.random() * (maxLeft + 1))
        var topPos = Math.floor(Math.random() * (maxTop + 1))
        this.setState({randPos: {top:topPos, left:leftPos}, show: true})
        this.fadeIn()
        setTimeout(this.fadeOut, 3000)
      }
}

Competence.defaultProps  = {interval: 6000}

export default Competence