Skip to content

Commit

Permalink
v0.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwellito committed Jun 7, 2017
1 parent f016dbb commit 4e1ea5f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 50 deletions.
98 changes: 54 additions & 44 deletions dist/vivus.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* vivus - JavaScript library to make drawing animation on SVG
* @version v0.4.0
* @version v0.4.1
* @link https://github.com/maxwellito/vivus
* @license MIT
*/

'use strict';

(function (window, document) {
(function () {

'use strict';

Expand Down Expand Up @@ -268,7 +268,7 @@ Pathformer.prototype.parseAttr = function (element) {

'use strict';

var requestAnimFrame, cancelAnimFrame, parsePositiveInt;
var setupEnv, requestAnimFrame, cancelAnimFrame, parsePositiveInt;

/**
* Vivus
Expand Down Expand Up @@ -320,6 +320,8 @@ var requestAnimFrame, cancelAnimFrame, parsePositiveInt;
*/
function Vivus (element, options, callback) {

setupEnv();

// Setup
this.isReady = false;
this.setElement(element, options);
Expand Down Expand Up @@ -953,12 +955,6 @@ Vivus.prototype.isInViewport = function (el, h) {
return (elTop + elHeight * h) <= viewed && (elBottom) >= scrolled;
};

/**
* Alias for document element
*
* @type {DOMelement}
*/
Vivus.prototype.docElem = window.document.documentElement;

/**
* Get the viewport height in pixels
Expand Down Expand Up @@ -986,41 +982,55 @@ Vivus.prototype.scrollY = function () {
return window.pageYOffset || this.docElem.scrollTop;
};

/**
* Alias for `requestAnimationFrame` or
* `setTimeout` function for deprecated browsers.
*
*/
requestAnimFrame = (function () {
return (
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(/* function */ callback){
return window.setTimeout(callback, 1000 / 60);
}
);
})();
setupEnv = function () {

/**
* Alias for `cancelAnimationFrame` or
* `cancelTimeout` function for deprecated browsers.
*
*/
cancelAnimFrame = (function () {
return (
window.cancelAnimationFrame ||
window.webkitCancelAnimationFrame ||
window.mozCancelAnimationFrame ||
window.oCancelAnimationFrame ||
window.msCancelAnimationFrame ||
function(id){
return window.clearTimeout(id);
}
);
})();
if (Vivus.prototype.docElem) {
return;
}

/**
* Alias for document element
*
* @type {DOMelement}
*/
Vivus.prototype.docElem = window.document.documentElement;

/**
* Alias for `requestAnimationFrame` or
* `setTimeout` function for deprecated browsers.
*
*/
requestAnimFrame = (function () {
return (
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(/* function */ callback){
return window.setTimeout(callback, 1000 / 60);
}
);
})();

/**
* Alias for `cancelAnimationFrame` or
* `cancelTimeout` function for deprecated browsers.
*
*/
cancelAnimFrame = (function () {
return (
window.cancelAnimationFrame ||
window.webkitCancelAnimationFrame ||
window.mozCancelAnimationFrame ||
window.oCancelAnimationFrame ||
window.msCancelAnimationFrame ||
function(id){
return window.clearTimeout(id);
}
);
})();
};

/**
* Parse string to integer.
Expand Down Expand Up @@ -1054,4 +1064,4 @@ parsePositiveInt = function (value, defaultValue) {
window.Vivus = Vivus;
}

}(window, document));
}());
Loading

0 comments on commit 4e1ea5f

Please sign in to comment.