Universal module pattern (for browserify support)
This commit is contained in:
parent
4480a8e3ff
commit
6716fab883
50
springy.js
50
springy.js
|
@ -24,22 +24,24 @@
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
* OTHER DEALINGS IN THE SOFTWARE.
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
(function (root, factory) {
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
// AMD. Register as an anonymous module.
|
||||||
|
define(['b'], function (b) {
|
||||||
|
return (root.returnExportsGlobal = factory());
|
||||||
|
});
|
||||||
|
} else if (typeof exports === 'object') {
|
||||||
|
// Node. Does not work with strict CommonJS, but
|
||||||
|
// only CommonJS-like enviroments that support module.exports,
|
||||||
|
// like Node.
|
||||||
|
module.exports = factory();
|
||||||
|
} else {
|
||||||
|
// Browser globals
|
||||||
|
root.Springy = factory();
|
||||||
|
}
|
||||||
|
}(this, function() {
|
||||||
|
|
||||||
(function() {
|
var Springy = {};
|
||||||
// Enable strict mode for EC5 compatible browsers
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
// Establish the root object, `window` in the browser, or `global` on the server.
|
|
||||||
var root = this;
|
|
||||||
|
|
||||||
// The top-level namespace. All public Springy classes and modules will
|
|
||||||
// be attached to this. Exported for both CommonJS and the browser.
|
|
||||||
var Springy;
|
|
||||||
if (typeof exports !== 'undefined') {
|
|
||||||
Springy = exports;
|
|
||||||
} else {
|
|
||||||
Springy = root.Springy = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
var Graph = Springy.Graph = function() {
|
var Graph = Springy.Graph = function() {
|
||||||
this.nodeSet = {};
|
this.nodeSet = {};
|
||||||
|
@ -474,14 +476,14 @@
|
||||||
|
|
||||||
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; // stolen from coffeescript, thanks jashkenas! ;-)
|
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; // stolen from coffeescript, thanks jashkenas! ;-)
|
||||||
|
|
||||||
Springy.requestAnimationFrame = __bind(root.requestAnimationFrame ||
|
Springy.requestAnimationFrame = __bind(this.requestAnimationFrame ||
|
||||||
root.webkitRequestAnimationFrame ||
|
this.webkitRequestAnimationFrame ||
|
||||||
root.mozRequestAnimationFrame ||
|
this.mozRequestAnimationFrame ||
|
||||||
root.oRequestAnimationFrame ||
|
this.oRequestAnimationFrame ||
|
||||||
root.msRequestAnimationFrame ||
|
this.msRequestAnimationFrame ||
|
||||||
(function(callback, element) {
|
(function(callback, element) {
|
||||||
root.setTimeout(callback, 10);
|
this.setTimeout(callback, 10);
|
||||||
}), root);
|
}), this);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -720,4 +722,6 @@
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
}).call(this);
|
|
||||||
|
return Springy;
|
||||||
|
}));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user