Skip to content

Commit 4e1ea5f

Browse files
committed
v0.4.1
1 parent f016dbb commit 4e1ea5f

File tree

4 files changed

+60
-50
lines changed

4 files changed

+60
-50
lines changed

dist/vivus.js

+54-44
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/**
22
* vivus - JavaScript library to make drawing animation on SVG
3-
* @version v0.4.0
3+
* @version v0.4.1
44
* @link https://github.com/maxwellito/vivus
55
* @license MIT
66
*/
77

88
'use strict';
99

10-
(function (window, document) {
10+
(function () {
1111

1212
'use strict';
1313

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

269269
'use strict';
270270

271-
var requestAnimFrame, cancelAnimFrame, parsePositiveInt;
271+
var setupEnv, requestAnimFrame, cancelAnimFrame, parsePositiveInt;
272272

273273
/**
274274
* Vivus
@@ -320,6 +320,8 @@ var requestAnimFrame, cancelAnimFrame, parsePositiveInt;
320320
*/
321321
function Vivus (element, options, callback) {
322322

323+
setupEnv();
324+
323325
// Setup
324326
this.isReady = false;
325327
this.setElement(element, options);
@@ -953,12 +955,6 @@ Vivus.prototype.isInViewport = function (el, h) {
953955
return (elTop + elHeight * h) <= viewed && (elBottom) >= scrolled;
954956
};
955957

956-
/**
957-
* Alias for document element
958-
*
959-
* @type {DOMelement}
960-
*/
961-
Vivus.prototype.docElem = window.document.documentElement;
962958

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

989-
/**
990-
* Alias for `requestAnimationFrame` or
991-
* `setTimeout` function for deprecated browsers.
992-
*
993-
*/
994-
requestAnimFrame = (function () {
995-
return (
996-
window.requestAnimationFrame ||
997-
window.webkitRequestAnimationFrame ||
998-
window.mozRequestAnimationFrame ||
999-
window.oRequestAnimationFrame ||
1000-
window.msRequestAnimationFrame ||
1001-
function(/* function */ callback){
1002-
return window.setTimeout(callback, 1000 / 60);
1003-
}
1004-
);
1005-
})();
985+
setupEnv = function () {
1006986

1007-
/**
1008-
* Alias for `cancelAnimationFrame` or
1009-
* `cancelTimeout` function for deprecated browsers.
1010-
*
1011-
*/
1012-
cancelAnimFrame = (function () {
1013-
return (
1014-
window.cancelAnimationFrame ||
1015-
window.webkitCancelAnimationFrame ||
1016-
window.mozCancelAnimationFrame ||
1017-
window.oCancelAnimationFrame ||
1018-
window.msCancelAnimationFrame ||
1019-
function(id){
1020-
return window.clearTimeout(id);
1021-
}
1022-
);
1023-
})();
987+
if (Vivus.prototype.docElem) {
988+
return;
989+
}
990+
991+
/**
992+
* Alias for document element
993+
*
994+
* @type {DOMelement}
995+
*/
996+
Vivus.prototype.docElem = window.document.documentElement;
997+
998+
/**
999+
* Alias for `requestAnimationFrame` or
1000+
* `setTimeout` function for deprecated browsers.
1001+
*
1002+
*/
1003+
requestAnimFrame = (function () {
1004+
return (
1005+
window.requestAnimationFrame ||
1006+
window.webkitRequestAnimationFrame ||
1007+
window.mozRequestAnimationFrame ||
1008+
window.oRequestAnimationFrame ||
1009+
window.msRequestAnimationFrame ||
1010+
function(/* function */ callback){
1011+
return window.setTimeout(callback, 1000 / 60);
1012+
}
1013+
);
1014+
})();
1015+
1016+
/**
1017+
* Alias for `cancelAnimationFrame` or
1018+
* `cancelTimeout` function for deprecated browsers.
1019+
*
1020+
*/
1021+
cancelAnimFrame = (function () {
1022+
return (
1023+
window.cancelAnimationFrame ||
1024+
window.webkitCancelAnimationFrame ||
1025+
window.mozCancelAnimationFrame ||
1026+
window.oCancelAnimationFrame ||
1027+
window.msCancelAnimationFrame ||
1028+
function(id){
1029+
return window.clearTimeout(id);
1030+
}
1031+
);
1032+
})();
1033+
};
10241034

10251035
/**
10261036
* Parse string to integer.
@@ -1054,4 +1064,4 @@ parsePositiveInt = function (value, defaultValue) {
10541064
window.Vivus = Vivus;
10551065
}
10561066

1057-
}(window, document));
1067+
}());

0 commit comments

Comments
 (0)