Skip to content

Commit

Permalink
Bugfix window not available error handled when using in node. v2.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
avcs06 committed Aug 4, 2018
1 parent e2766d3 commit 480ff41
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 20 deletions.
7 changes: 4 additions & 3 deletions dist/SVGPanZoom.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/SVGPanZoom.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/SVGPanZoom.min.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions docs/SVGPanZoom.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/SVGPanZoom.js.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions es/Animation.js
@@ -1,14 +1,15 @@
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

//Polyfill for AnimationFrame
var requestAnimationFrame = window.requestAnimationFrame;
var cancelAnimationFrame = window.cancelAnimationFrame;
var GLOBAL = typeof window !== 'undefined' ? window : global;
var requestAnimationFrame = GLOBAL.requestAnimationFrame;
var cancelAnimationFrame = GLOBAL.cancelAnimationFrame;
if (!requestAnimationFrame || !cancelAnimationFrame) {
var lastTime = 0;
requestAnimationFrame = function requestAnimationFrame(callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function () {
var id = GLOBAL.setTimeout(function () {
callback(currTime + timeToCall);
}, timeToCall);

Expand Down
9 changes: 5 additions & 4 deletions lib/Animation.js
@@ -1,4 +1,4 @@
"use strict";
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
Expand All @@ -7,14 +7,15 @@ Object.defineProperty(exports, "__esModule", {
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

//Polyfill for AnimationFrame
var requestAnimationFrame = window.requestAnimationFrame;
var cancelAnimationFrame = window.cancelAnimationFrame;
var GLOBAL = typeof window !== 'undefined' ? window : global;
var requestAnimationFrame = GLOBAL.requestAnimationFrame;
var cancelAnimationFrame = GLOBAL.cancelAnimationFrame;
if (!requestAnimationFrame || !cancelAnimationFrame) {
var lastTime = 0;
requestAnimationFrame = function requestAnimationFrame(callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function () {
var id = GLOBAL.setTimeout(function () {
callback(currTime + timeToCall);
}, timeToCall);

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@avcs/svgpanzoom",
"version": "2.0.3",
"version": "2.0.4",
"description": "A Javascript plugin to pan and zoom SVG images either programatically or through mouse/touch events",
"main": "lib/SVGPanZoom.js",
"repository": "git@github.com:avcs06/SVGPanZoom.git",
Expand Down
7 changes: 4 additions & 3 deletions src/Animation.js
@@ -1,12 +1,13 @@
//Polyfill for AnimationFrame
let requestAnimationFrame = window.requestAnimationFrame;
let cancelAnimationFrame = window.cancelAnimationFrame;
const GLOBAL = typeof window !== 'undefined' ? window : global;
let requestAnimationFrame = GLOBAL.requestAnimationFrame;
let cancelAnimationFrame = GLOBAL.cancelAnimationFrame;
if (!requestAnimationFrame || !cancelAnimationFrame) {
let lastTime = 0;
requestAnimationFrame = function(callback, element) {
const currTime = new Date().getTime();
const timeToCall = Math.max(0, 16 - (currTime - lastTime));
const id = window.setTimeout(function() {
const id = GLOBAL.setTimeout(function() {
callback(currTime + timeToCall);
}, timeToCall);

Expand Down

0 comments on commit 480ff41

Please sign in to comment.