Skip to content

Commit

Permalink
Merge pull request #153 from maxwellito/build-fix
Browse files Browse the repository at this point in the history
Patch build for universal environments
  • Loading branch information
maxwellito authored Jun 7, 2017
2 parents 214f8b6 + 115e88f commit f016dbb
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 42 deletions.
4 changes: 2 additions & 2 deletions src/_build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

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

//import("pathformer.js");
//import("vivus.js");
Expand All @@ -20,4 +20,4 @@
window.Vivus = Vivus;
}

}(window, document));
}());
90 changes: 50 additions & 40 deletions src/vivus.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ var requestAnimFrame, cancelAnimFrame, parsePositiveInt;
*/
function Vivus (element, options, callback) {

setupEnv();

// Setup
this.isReady = false;
this.setElement(element, options);
Expand Down Expand Up @@ -685,12 +687,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 @@ -718,41 +714,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);
}
);
})();
var 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

0 comments on commit f016dbb

Please sign in to comment.