diff --git a/README.md b/README.md index dcfa665..b49ba33 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,17 @@ What is it? A jQuery plugin from GSGD to give advanced easing options. More info [here](http://gsgd.co.uk/sandbox/jquery/easing) -For CDN please use CloudFlare [`http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js`](http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js) to help my host. Thank you. \ No newline at end of file +For CDN please use CloudFlare [`http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js`](http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js) to help my host. Thank you. + +# AMD or CommonJS usage + +```js +// CommonJS +var jQuery = require('jquery'); +require('jquery.easing')(jQuery); + +// AMD +define(['jquery', 'jquery.easing'], function (jQuery, easing) { + easing(jQuery) +}) +``` diff --git a/jquery.easing.js b/jquery.easing.js index d07d508..e7fdf06 100755 --- a/jquery.easing.js +++ b/jquery.easing.js @@ -7,7 +7,17 @@ */ // t: current time, b: begInnIng value, c: change In value, d: duration -(function($){$.easing['jswing'] = $.easing['swing']; +(function (factory) { + if (typeof define === "function" && define.amd) { + define(function () { + return factory; + }); + } else if (typeof module === "object" && typeof module.exports === "object") { + exports = factory; + } else { + factory(jQuery); + } +})(function($){$.easing['jswing'] = $.easing['swing']; $.extend( $.easing, { @@ -140,4 +150,4 @@ $.extend( $.easing, if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b; return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; } -});})(jQuery); +});});