Skip to content

Instantly share code, notes, and snippets.

@griffinmichl
Created April 14, 2016 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save griffinmichl/30169b9d578fe682f2cdeb06fa4f7d1b to your computer and use it in GitHub Desktop.
Save griffinmichl/30169b9d578fe682f2cdeb06fa4f7d1b to your computer and use it in GitHub Desktop.
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