This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Tween extends Component { | |
static defaultProps = { | |
duration: 1000, | |
} | |
constructor(props) { | |
super(props); | |
this.state = { | |
timeStart: +new Date(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MousePosition extends Component { | |
constructor(props) { | |
super(props); | |
this.onMouseMove = this._onMouseMove.bind(this); | |
this.state = { x: 0, y: 0 }; | |
} | |
componentDidMount() { | |
document.addEventListener('mousemove', this.onMouseMove); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App extends Component { | |
render() { | |
return ( | |
<MousePosition> | |
{({ x, y }) => ( | |
<Tween func={linear} defaultStart={centerX} end={x}> | |
{({ current: cx }) => ( | |
<Tween func={linear} defaultStart={centerY} end={y}> | |
{({ current: cy }) => ( | |
<Rectangle x={cx} y={cy} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Rectangle = ({ x, y }) => ( | |
<div style={{ position: 'fixed', top: `${y}px`, left: `${x}px`, height: '10px', width: '10px', backgroundColor: 'black' }} /> | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App extends Component { | |
render() { | |
return ( | |
<SimpleTween start={0} end={600}> | |
{({ current }) => ( | |
<Rectangle x={current} y={600} /> | |
)} | |
</SimpleTween> | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SimpleTween extends Component { | |
static defaultProps = { duration: 1000 } | |
constructor(props) { | |
super(props); | |
this.state = { | |
timeStart: +new Date(), | |
current: props.start, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function linear(diff, start, change, duration) { | |
return change * (diff /= duration) + start; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const centerX = Math.floor(window.innerWidth / 2); | |
const centerY = Math.floor(window.innerHeight / 2); | |
class App extends Component { | |
render() { | |
return ( | |
<MousePosition> | |
{({ x, y }) => ( | |
<Tween func={easeOutQuad} defaultStart={centerX} end={x}> | |
{({ current: cx }) => ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Add this file to your bash path | |
# Make sure to chmod 755 it | |
# Example useage: | |
# MY_COMMAND; beep | |
if [ "$?" = "0" ]; then | |
afplay /System/Library/Sounds/Submarine.aiff -v 8 | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Crazy, but consistent method: --> | |
<style> | |
body { display: none; } | |
</style> | |
<script> | |
if (self === top) { | |
documents.getElementsByTagName("body")[0].style.display = 'block'; | |
} else { | |
top.location = self.location; |