Created
April 14, 2016 23:20
-
-
Save griffinmichl/30169b9d578fe682f2cdeb06fa4f7d1b to your computer and use it in GitHub Desktop.
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 mouseDowns$ = DOM.select('.handler').events('mousedown'); | |
const mouseUps$ = DOM.select('.tricycle').events('mouseup'); | |
const mouseMoves$ = DOM.select('.tricycle').events('mousemove'); | |
const mouseLeaves$ = DOM.select('.tricycle').events('mouseleave'); | |
const windowSizes$ = mouseDowns$ | |
.flatMap(mouseDown => mouseMoves$.takeUntil(mouseUps$.merge(mouseLeaves$))) | |
.map(mouseDrag => { | |
const clientWidth = document.querySelector('.tricycle').clientWidth; | |
const fraction = (clientWidth - mouseDrag.clientX) / clientWidth; | |
return fraction; | |
}) | |
.filter(fraction => fraction < 0.9 && fraction > 0.1) | |
.map(fraction => ({ | |
codeWidth: `${100*(1 - fraction)}%`, | |
resultWidth: `${100*fraction}%` | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment