Skip to content

Instantly share code, notes, and snippets.

View elliottkember's full-sized avatar
💭
software

Elliott Kember elliottkember

💭
software
View GitHub Profile

A farmer is looking for some extra help on the farm, so he hires a farmhand. On the first day he puts him to work pounding in fence posts, it's absolutely grueling work under the hot sun, but the farmhand excels at this. He sets up more fence posts than any other farmhand ever has in a day, more than the farmer ever could. The farmer is astounded at how fast the hand worked.

So, the next day, the farmer sets the farmhand up harvesting corn. It's tedious work, there are rows and rows and rows of corn and all day the farmhand is plucking ears of corn in an endlessly monotonous task. At the end of the day, the farmhand delivers a massive collection of corn. He's done it again - he's worked harder and better than anyone could ever do. At this rate the farmer is going to run out of work!

So on the third day, the farmer is trusting the farmhand to make decisions. He leads him into the root cellar and shows him the potatoes. There's a whole heap of them, a weeks worth of work. The farmer says, "I want you to sort

@elliottkember
elliottkember / imageSwappingLayer.coffee
Created October 13, 2014 18:39
A layer that fades between images depending on its state
class ImageSwappingLayer extends Layer
images: {}
imageSubLayer: false
imageTransitionTime: 0.5
constructor: (options={}) ->
super options
@imageTransitionTime = options.imageTransitionTime if options.imageTransitionTime
@elliottkember
elliottkember / stateAnimationOptions.coffee
Last active March 14, 2019 14:11
Framer.js per-transition animationOptions!
myLayer.states.stateAnimationOptions =
'a-b':
time: 0.1
'b-c':
time: 0.8
'c-d':
time: 0.5
myLayer.states.add
a: opacity: 1
@elliottkember
elliottkember / Configurator.coffee
Last active August 29, 2015 14:04
A configurator for specifying properties on Framer layers! Example: http://elliott-prototypes.s3.amazonaws.com/Configurator.framer/index.html
Layer.prototype.destroyRecursively = ->
layer.destroyRecursively() for layer in @subLayers
@destroy()
class Configurator
constructor: (options) ->
@values = {}
@options = options
@callbacks = {}
@elliottkember
elliottkember / load.coffee
Created July 23, 2014 18:04
Load in CoffeeScript files with Framer
load = (scripts...) ->
for script in scripts
script = "#{script}.coffee" if script.indexOf '.' == -1
eval CoffeeScript.compile(Utils.domLoadDataSync(script))
load 'finderWindow', 'appStateMachine'
@elliottkember
elliottkember / AppStateMachine.coffee
Last active August 9, 2018 14:32
A simple application framework for Framer
EventEmitter = (require?("./EventEmitter") || Framer).EventEmitter
class AppStateMachine extends EventEmitter
constructor: ->
@states = []
# Start the state machine with the document's hash, or the given route
start: (name) ->
@go if document.location.hash then document.location.hash[1..-1] else name
@elliottkember
elliottkember / layerbrowser.coffee
Last active December 14, 2021 12:49
Layer browser for imported Sketch / PSD files in Framer
class LayerBrowser
constructor: (options) ->
@objects = []
@restore = options.restore
@_setup()
@add options.import if options.import
add: (object) ->
@objects.push object
@elliottkember
elliottkember / framer-alternate-states.coffee
Last active August 29, 2015 14:03
When clicked, a layer can have an alternate image, an alternate background color, or an overlay!
Layer.define "alternateBackgroundColor",
exportable: true
default: ""
get: ->
@_getPropertyValue "alternateBackgroundColor"
set: (alternateBackgroundColor) ->
return if alternateBackgroundColor == @_getPropertyValue "alternateBackgroundColor"
@_setPropertyValue "alternateBackgroundColor", alternateBackgroundColor
originalBackgroundColor = @backgroundColor
App.SpinnerView = Ember.View.extend
shadow: false
color: '#000'
tagName: 'span'
classNameBindings: [':loading-spinner', 'isButton:button', 'centered:centered']
didInsertElement: ->
opts =
lines: 13, # The number of lines to draw
length: 4, # The length of each line
width: 2, # The line thickness
App.ApplicationSerializer = DS.ActiveModelSerializer.extend
serialize: (record, options) ->
json = @_super record, options
record.eachAttribute (name, attribute) ->
if attribute.options.readOnly
delete json.name
json
App.Object = Ember.Model.extend
name: DS.attr 'string', readOnly: true