Skip to content

Commit

Permalink
fix(ComponentExample): show controls on mouse move
Browse files Browse the repository at this point in the history
  • Loading branch information
levithomason committed Oct 22, 2017
1 parent 3de7577 commit eea1e98
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ class ComponentExample extends Component {
copyToClipboard(location.href)
}

handleMouseEnter = () => this.setState({ controlsVisible: true })
handleMouseMove = _.throttle(() => {
const { controlsVisible } = this.state
if (controlsVisible) return

this.setState({ controlsVisible: true })
}, 200)

handleMouseLeave = () => this.setState({ controlsVisible: false })

Expand Down Expand Up @@ -414,7 +419,7 @@ class ComponentExample extends Component {
<Grid
className='docs-example'
id={this.anchorName}
onMouseEnter={this.handleMouseEnter}
onMouseMove={this.handleMouseMove}
onMouseLeave={this.handleMouseLeave}
style={exampleStyle}
>
Expand Down

0 comments on commit eea1e98

Please sign in to comment.