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
EaseLookup = {} | |
EaseLookup.find = (effect) -> | |
({ | |
"linear": Linear.easeNone | |
"swing": Quad.easeOut | |
"easeIn": Linear.easeIn | |
"easeOut": Linear.easeOut | |
"easeInOut": Linear.easeInOut |
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
UserEvents = {foo:"foo", bar:"bar"} | |
for key, value of UserEvents | |
$.fn[key+"AsObservable"] = (eventData) -> | |
@bindAsObservable value, eventData |
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
activity = $(document).asEventStream "keyup mousemove" | |
inactivity = activity.skipDuplicates().map((x)->x.timeStamp).toProperty("") | |
activity.subscribe(-> $("#test").show()) | |
inactivity.combine(inactivity.delay(1500), (a, b) -> a is b) | |
.filter((x)->x).subscribe(-> $("#test").hide()) |
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
arrayEquals = (a,b) -> $(a).not(b).length == 0 && $(b).not(a).length == 0 | |
always = (value) -> (_) -> value | |
allKeyUps = $(document).asEventStream("keyup") | |
keyCodeIs = (keyCode) -> (event) -> event.keyCode is keyCode | |
keyUps = (keyCode) -> allKeyUps.filter keyCodeIs(keyCode) | |
keyState = (keyCode, value) -> keyUps(keyCode).map(always(value)) | |
arrowKeyState = Bacon.mergeAll([ |
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
arrayEquals = (a,b) -> $(a).not(b).length == 0 && $(b).not(a).length == 0 | |
always = (value) -> (_) -> value | |
allKeyUps = $(document).asEventStream("keyup") | |
keyCodeIs = (keyCode) -> (event) -> event.keyCode is keyCode | |
keyUps = (keyCode) -> allKeyUps.filter keyCodeIs(keyCode) | |
keyState = (keyCode, value) -> keyUps(keyCode).map(always(value)) | |
arrowKeyState = Bacon.mergeAll([ |
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
nonEmpty = (x) -> x and x.length > 0 | |
isChrome = navigator.userAgent.toLowerCase().indexOf("chrome") > -1 | |
Bacon.UI = {} | |
Bacon.UI.textFieldValue = (textfield, initValue) -> | |
getValue = -> | |
textfield.val() | |
autofillPoller = -> | |
if textfield.attr("type") is "password" | |
Bacon.interval 100 | |
else if isChrome |
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 () { | |
Bacon.UI = { | |
ajax: function (params) { | |
return Bacon.fromPromise($.ajax(params)) | |
}, | |
get: function (url, data, dataType) { | |
return this.ajax({ url: url, dataType: dataType, data: data }) | |
}, |
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
TIME_INTERVAL = 350 | |
clicked = Bacon.fromEventTarget(document.body, "click").toProperty() | |
clicked.combine(clicked.delay(TIME_INTERVAL), (a,b)-> | |
a isnt b and a.target is b.target and a.timeStamp - b.timeStamp <= TIME_INTERVAL | |
) | |
.filter((x)->x) | |
.assign((x)->console.log "DONE", x) |
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
TIME_INTERVAL = 350 | |
clicked = Bacon.fromEventTarget(document.body, "click") | |
clicked.bufferWithCount(2) | |
.map((x) -> x[1].timeStamp - x[0].timeStamp) | |
.filter((x) -> x <= TIME_INTERVAL) | |
.assign((x) -> console.log "Done in #{x}") |
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
$("body").asEventStream("mousemove") | |
.map((e)-> [e.screenX, e.screenY].join("")) | |
.toProperty() | |
.sample(100) | |
.skipDuplicates() | |
.map(->Date.now()) | |
.assign (x) -> | |
console.log x |
OlderNewer