Last active
October 9, 2015 23:10
-
-
Save TylorS/fa0ac0cd59c97851e4b2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** @jsx hJSX */ | |
import { run, Rx } from '@cycle/core' | |
import { makeDOMDriver, hJSX } from '@cycle/dom' | |
function intent(DOM) { | |
const click$ = Rx.Observable.fromEvent(document, 'click') | |
return click$ | |
} | |
function model(actions) { | |
const position$ = actions.map(ev => { | |
return { x: ev.pageX, y: ev.pageY } | |
}).toArray() | |
return position$ | |
} | |
function view(item$) { | |
return item$.map(positions => { | |
const src = './assets/image.gif' | |
return positions.map(position => { | |
const style = { | |
width: '50px', | |
top: String(position.y+'px'), | |
left: String(position.x+'px'), | |
position: 'absolute' | |
} | |
return <img src={src} style={style} /> | |
); | |
}) | |
} | |
function main(sources) { | |
return { | |
DOM: view(model(intent(sources.DOM))) | |
} | |
} | |
run(main, { | |
DOM: makeDOMDriver('#app') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment