Skip to content

Instantly share code, notes, and snippets.

View griffinmichl's full-sized avatar

Griffin Michl griffinmichl

View GitHub Profile
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;
function myTest {
return 'test'
}
@griffinmichl
griffinmichl / tricycle.js
Created April 15, 2016 03:34
A saved Tricycle Program
This is my Content
@griffinmichl
griffinmichl / tricycle.js
Created April 15, 2016 03:51
A saved Tricycle Program
{"code":"\nconst Cycle = require('@cycle/core');\nconst {makeDOMDriver, div, button} = require('@cycle/dom');\nconst _ = require('lodash');\nconst {Observable} = require('rx');\nconst {restartable} = require('cycle-restart');\n\nfunction main ({DOM}) {\n const add$ = DOM\n .select('.add')\n .events('click')\n .map(ev => 1);\n\n const count$ = add$\n .startWith(0)\n .scan((total, change) => total + change)\n\n return {\n DOM: count$.map(count =>\n div('.counter', [\n 'Count: ' + count,\n button('.add', 'Add')\n ])\n )\n };\n}\n\n// This looks a little different than normal. It's to enable support for cycle-restart,\n// which automatically plays back your actions when the code reloads.\n// See https://github.com/Widdershin/cycle-restart for more info\nconst sources = {\n DOM: restartable(makeDOMDriver('.app'), {pauseSinksWhileReplaying: false})\n}\n\n// Normally you need to call Cycle.run, but Tricycle handles that for you!\n// If you want to try this out locall
@griffinmichl
griffinmichl / tricycle.js
Created April 15, 2016 03:52
A saved Tricycle Program
"\nconst Cycle = require('@cycle/core');\nconst {makeDOMDriver, div, button} = require('@cycle/dom');\nconst _ = require('lodash');\nconst {Observable} = require('rx');\nconst {restartable} = require('cycle-restart');\n\nfunction main ({DOM}) {\n const add$ = DOM\n .select('.add')\n .events('click')\n .map(ev => 1);\n\n const count$ = add$\n .startWith(0)\n .scan((total, change) => total + change)\n\n return {\n DOM: count$.map(count =>\n div('.counter', [\n 'Count: ' + count,\n button('.add', 'Add')\n ])\n )\n };\n}\n\n// This looks a little different than normal. It's to enable support for cycle-restart,\n// which automatically plays back your actions when the code reloads.\n// See https://github.com/Widdershin/cycle-restart for more info\nconst sources = {\n DOM: restartable(makeDOMDriver('.app'), {pauseSinksWhileReplaying: false})\n}\n\n// Normally you need to call Cycle.run, but Tricycle handles that for you!\n// If you want to try this out locally, just
@griffinmichl
griffinmichl / tricycle.js
Created April 15, 2016 03:57
A saved Tricycle Program
"\nconst Cycle = require('@cycle/core');\nconst {makeDOMDriver, div, button} = require('@cycle/dom');\nconst _ = require('lodash');\nconst {Observable} = require('rx');\nconst {restartable} = require('cycle-restart');\n\nfunction main ({DOM}) {\n const add$ = DOM\n .select('.add')\n .events('click')\n .map(ev => 1);\n\n const count$ = add$\n .startWith(0)\n .scan((total, change) => total + change)\n\n return {\n DOM: count$.map(count =>\n div('.counter', [\n 'Count: ' + count,\n button('.add', 'Add')\n ])\n )\n };\n}\n\n// This looks a little different than normal. It's to enable support for cycle-restart,\n// which automatically plays back your actions when the code reloads.\n// See https://github.com/Widdershin/cycle-restart for more info\nconst sources = {\n DOM: restartable(makeDOMDriver('.app'), {pauseSinksWhileReplaying: false})\n}\n\n// Normally you need to call Cycle.run, but Tricycle handles that for you!\n// If you want to try this out locally, just
@griffinmichl
griffinmichl / tricycle.js
Created April 15, 2016 04:06
A saved Tricycle Program
"\nconst Cycle = require('@cycle/core');\nconst {makeDOMDriver, div, button} = require('@cycle/dom');\nconst _ = require('lodash');\nconst {Observable} = require('rx');\nconst {restartable} = require('cycle-restart');\n\nfunction main ({DOM}) {\n const add$ = DOM\n .select('.add')\n .events('click')\n .map(ev => 1);\n\n const count$ = add$\n .startWith(0)\n .scan((total, change) => total + change)\n\n return {\n DOM: count$.map(count =>\n div('.counter', [\n 'Count: ' + count,\n button('.add', 'Add')\n ])\n )\n };\n}\n\n// This looks a little different than normal. It's to enable support for cycle-restart,\n// which automatically plays back your actions when the code reloads.\n// See https://github.com/Widdershin/cycle-restart for more info\nconst sources = {\n DOM: restartable(makeDOMDriver('.app'), {pauseSinksWhileReplaying: false})\n}\n\n// Normally you need to call Cycle.run, but Tricycle handles that for you!\n// If you want to try this out locally, just
@griffinmichl
griffinmichl / tricycle.js
Created April 15, 2016 04:06
A saved Tricycle Program
"\nconst Cycle = require('@cycle/core');\nconst {makeDOMDriver, div, button} = require('@cycle/dom');\nconst _ = require('lodash');\nconst {Observable} = require('rx');\nconst {restartable} = require('cycle-restart');\n\nfunction main ({DOM}) {\n const add$ = DOM\n .select('.add')\n .events('click')\n .map(ev => 1);\n\n const count$ = add$\n .startWith(0)\n .scan((total, change) => total + change)\n\n return {\n DOM: count$.map(count =>\n div('.counter', [\n 'Count: ' + count,\n button('.add', 'Add')\n ])\n )\n };\n}\n\n// This looks a little different than normal. It's to enable support for cycle-restart,\n// which automatically plays back your actions when the code reloads.\n// See https://github.com/Widdershin/cycle-restart for more info\nconst sources = {\n DOM: restartable(makeDOMDriver('.app'), {pauseSinksWhileReplaying: false})\n}\n\n// Normally you need to call Cycle.run, but Tricycle handles that for you!\n// If you want to try this out locally, just
@griffinmichl
griffinmichl / tricycle.js
Created April 15, 2016 04:07
A saved Tricycle Program
"\nconst Cycle = require('@cycle/core');\nconst {makeDOMDriver, div, button} = require('@cycle/dom');\nconst _ = require('lodash');\nconst {Observable} = require('rx');\nconst {restartable} = require('cycle-restart');\n\nfunction main ({DOM}) {\n const add$ = DOM\n .select('.add')\n .events('click')\n .map(ev => 1);\n\n const count$ = add$\n .startWith(0)\n .scan((total, change) => total + change)\n\n return {\n DOM: count$.map(count =>\n div('.counter', [\n 'Count: ' + count,\n button('.add', 'Add')\n ])\n )\n };\n}\n\n// This looks a little different than normal. It's to enable support for cycle-restart,\n// which automatically plays back your actions when the code reloads.\n// See https://github.com/Widdershin/cycle-restart for more info\nconst sources = {\n DOM: restartable(makeDOMDriver('.app'), {pauseSinksWhileReplaying: false})\n}\n\n// Normally you need to call Cycle.run, but Tricycle handles that for you!\n// If you want to try this out locally, just