Skip to content

Instantly share code, notes, and snippets.

@jeremyckahn
jeremyckahn / tweeny.md
Created May 19, 2011 13:47
A rough, incomplete README

Tweeny

Tweeny is a tweening engine for JavaScript. That's it. Tweeny is meant to be a low level tool that can be encapsulated by higher-level tools. It does:

  • Tweening.
  • Extensibility hooks for the tweening.

Tweeny doesn't do:

Manager

An organizational tool for your JavaScript!

Manager lets you organize your JavaScript code into predictable patterns. It also provides a super easy publish/subscribe mechanism.

##Setup##

Just drop manager.js into your page. This creates the global manager object.

Twactors should inherit from Tweeny. An actor's step functionality should somehow wrap the tweeny.tween's step parameter.

How I'm going to do this...

First things first, window.tweeny needs to be a function so it can correctly start the prototype chain. - Done.

Tweeny also needs a hook function that can be called for every invocation of tweeny.tween(). Basically like step, but runs for every call to tween() implicitly. Twactor can hook into that and update the actor state for every tween, queued tween, etc. The setup of this hook will be done in the Twactor constructor. This will let me actually inherit all of the properties, instead of pretend-inheriting them.

Note to self: The Tweeny constructor needs to set up methods to access the hooks (setHook and removeHook, or something similar). The hooks themselves will be stored as private vars inside the Actor constructor.

@jeremyckahn
jeremyckahn / osx.sh
Created June 6, 2011 01:46
Useful OS X BASH commands
# Disable Spaces animation
# /via http://hints.macworld.com/article.php?story=20110214074550501
defaults write com.apple.dock workspaces-swoosh-animation-off -bool YES && killall Dock
# ... And re-enable.
defaults delete com.apple.dock workspaces-swoosh-animation-off && killall Dock
@jeremyckahn
jeremyckahn / tldr.js
Created June 24, 2011 15:19
Your comments need tl;dr
// This whole function breaks event.preventDefault() for `a`
// tags inside of the `li`s that this click handler binds to.
// In fact, I'm not even sure why this code needs to be here.
// Regardless, this `if` checks to see the contained `a` tag's href ends
// in "#", in which case the default behavior _must_ be prevented.
// tl;dr: Only update the URL if the href does NOT end in "#".
if (/#$/.test(targetHref) === false) {
window.location = $a[0].href;
}
@jeremyckahn
jeremyckahn / interview.html
Created July 13, 2011 15:30
A good interview question
<html>
<head></head>
<body>
<button id="mybutton">hello</button>
<div id="output"></div>
<script type="text/javascript" charset="utf-8">
@jeremyckahn
jeremyckahn / forceLayoutUpdate
Created July 21, 2011 15:01
$.fn.forceLayoutUpdate
// Fixes random IE 6/7 issues.
// Use case: JavaScript restyles parts of the DOM and certain elements don't reflow correctly.
// This basically pokes those elements with a stick and reflows them.
(function ($) {
$.fn.forceLayoutUpdate = function () {
return this
.css({
'zoom': 1
})
.css({
// "noop" is short for "[no-op](http://en.wikipedia.org/wiki/NOP)." But it's more fun to say "noop."
function noop () {
return;
}
/**
Mifty - A custom build of Shifty for use with Morf.js.
By Jeremy Kahn - jeremyckahn@gmail.com
v0.4.1
For instructions on how to use Shifty, please consult the README: https://github.com/jeremyckahn/shifty/blob/master/README.md
MIT Lincense. This code free to use, modify, distribute and enjoy.
*/