-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated playback with procrastinate, improved pen rendering system by…
… starting at 90 degree vertical
- Loading branch information
Hunter Loftis
committed
Mar 28, 2011
1 parent
ee030e3
commit 24f024d
Showing
14 changed files
with
203 additions
and
71 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* Procrastinate - to delay execution of a function (server or browser) | ||
* | ||
* - node.js | ||
* eg: DrawProject updates project thumbnail when pages are added. CPU intensive. | ||
* With sequential adds (multi-upload form), DrawProject runs each time, wasting the last thumbnail. | ||
* We delay DrawProject for 5 seconds after each 'add' to see if another 'add' will happen soon. | ||
* To avoid starving DrawProject, we set an upper limit of 30 seconds. | ||
* | ||
* var Procratinate = require('procrastinate'); | ||
* Procrastinate.start('projectname', 5000, 30000, function() { DrawProject('projectname'); }); | ||
* | ||
* - Browser | ||
* | ||
* <script src='procrastinate.js'></script> | ||
* Procrastinate.start('someUniqueTag', 1000, 8000, function() { ... }); | ||
* | ||
* Procrastinate.start('anotherTag', 500, 5000, this.method(), this); // "method" called using "this" context | ||
*/ | ||
|
||
(function() { | ||
|
||
var pending = {}, | ||
exporter = {}; | ||
|
||
function queue(fn, context, tag, start, min, max) { | ||
pending[tag] = { | ||
fn: fn, | ||
context: context, | ||
start: start, | ||
max: max, | ||
timeout: setTimeout(run, min, fn, context, tag) | ||
}; | ||
} | ||
|
||
function run(fn, context, tag) { | ||
fn.call(context); | ||
delete pending[tag]; | ||
} | ||
|
||
function start(tag, min, max, fn, context) { | ||
var queued = pending[tag], | ||
now = new Date().getTime(); | ||
|
||
context = context || this; | ||
|
||
if (typeof queued !== 'undefined') { | ||
clearTimeout(queued.timeout); | ||
if (now - queued.start > queued.max) run(fn, context, tag); | ||
else queue(fn, context, tag, queued.start, min, max); | ||
} | ||
else queue(fn, context, tag, now, min, max); | ||
} | ||
|
||
// commonJS export | ||
|
||
if (typeof module !== 'undefined' && ('exports' in module)) { | ||
exporter = module.exports; | ||
} | ||
|
||
// browser export | ||
|
||
else if (typeof window !== 'undefined') { | ||
exporter = window.Procrastinate = {}; | ||
} | ||
|
||
exporter.start = start; | ||
|
||
})(); |
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
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
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
Oops, something went wrong.