Skip to content

Instantly share code, notes, and snippets.

View mplatts's full-sized avatar

Matt Platts mplatts

View GitHub Profile
@mplatts
mplatts / blockhelper.html
Last active September 19, 2015 04:47
templates - spacebar helpers
<template name="headingWrapper">
<h1>{{> UI.contentBlock}}</h1>
<h4>{{this.subheading}}</h4>
</template>
<template name="main">
{{#headingWrapper subheading="My Subheading"}}
My Heading
{{/headingWrapper}}
</template>
@mplatts
mplatts / transitions.js
Last active August 29, 2015 14:13
animations 2 js version
var createHooks;
createHooks = function(options) {
options = _.defaults(options, {
alwaysClass: '',
onscreenClass: '',
offscreenClass: '',
removeClass: '',
removeTimeout: 500,
insertTimeout: 500
@mplatts
mplatts / mod.js
Created December 8, 2014 01:04
Famo.us modifier cheatsheet
var mod = new Modifier({
origin: [0.5, 0],
align: [0.5, 0],
opacity: 0.3,
transform: Transform.translate(0, 10, 1) // can be a function that runs every tick
})
mod.transformFrom(transform); // evaluated every tick
mod.opacityFrom(0.3);
mod.originFrom(0.5);
@mplatts
mplatts / myView.js
Last active August 29, 2015 14:10
Famo.us view template
var Engine = famous.core.Engine;
var Surface = famous.core.Surface;
var View = famous.core.View;
var Modifier = famous.core.Modifier;
var MyView = function(){
// Run View as constructor first
View.call(this, arguments);
this.rootMod = new Modifier({
// if we keep using Object.create(parent), we might want the parent to
// have a constructor function so all children turn out the same
parent = {
constructor: function(name) {
this._name = name;
}
}
child1 = Object.create(parent);
@mplatts
mplatts / inheritance.js
Created December 7, 2014 00:16
Standard inheritance in Javascript
function MyClass(){
}
MyClass.prototype.method = function(){}
function MySubClass(){
// use MyClass as the constructor
MyClass.call(this);
}
@mplatts
mplatts / game.coffee
Created November 27, 2014 03:38
templates 2 - edit games
# client/views/game.coffee
Template.game.events
"click .finish-game": (e, tpl) ->
e.preventDefault()
Games.update({_id: @_id}, {$set: {completed: true}})
"click .delete-game": (e, tpl) ->
Games.remove(@_id)
@mplatts
mplatts / games.coffee
Last active August 29, 2015 14:10
templates2 - create game method
# client/views/games.coffee
Template.games.helpers
teams: Teams.find()
games: Games.find()
creating: -> Session.get 'creating-game'
Template.games.events
"click .create": (e, tpl) ->
e.preventDefault()
@mplatts
mplatts / games.coffee
Last active April 10, 2016 20:31
templates2 - games.coffee
# client/views/games.coffee
Template.games.helpers
teams: -> Teams.find()
games: -> Games.find()
creating: -> Session.get 'creating-game'
Template.games.events
"click .create": (e, tpl) ->
e.preventDefault()
@mplatts
mplatts / games.html
Created November 27, 2014 02:19
templates2 - adding games
<!-- client/views/games.html -->
<template name="games">
<h3>Games</h3>
{{#if creating}}
<form class="form-create">
<select name="teamOne">
{{#each teams}}
<option value="{{_id}}">{{name}}</option>
{{/each}}