mirror of
https://github.com/konvajs/konva.git
synced 2025-09-19 02:37:59 +08:00
global & UMD cleaning
This commit is contained in:
88
konva.js
88
konva.js
@@ -31,28 +31,13 @@
|
||||
// runtime check for already included Konva
|
||||
(function(){
|
||||
'use strict';
|
||||
var global =
|
||||
typeof window !== 'undefined' ? window :
|
||||
typeof global !== 'undefined' ? global :
|
||||
typeof WorkerGlobalScope !== 'undefined' ? self : {};
|
||||
|
||||
if (global.Konva) {
|
||||
console.error(
|
||||
'Konva instance is already exist in current eviroment. ' +
|
||||
'Please use only one instance.'
|
||||
);
|
||||
}
|
||||
})();
|
||||
|
||||
/**
|
||||
/**
|
||||
* @namespace Konva
|
||||
*/
|
||||
var Konva = {};
|
||||
(function(root) {
|
||||
'use strict';
|
||||
|
||||
var PI_OVER_180 = Math.PI / 180;
|
||||
|
||||
Konva = {
|
||||
var Konva = {
|
||||
// public
|
||||
version: '0.11.0',
|
||||
|
||||
@@ -215,31 +200,25 @@ var Konva = {};
|
||||
UA: undefined
|
||||
};
|
||||
|
||||
Konva.UA = Konva._parseUA((root.navigator && root.navigator.userAgent) || '');
|
||||
var global =
|
||||
typeof window !== 'undefined' ? window :
|
||||
typeof global !== 'undefined' ? global :
|
||||
typeof WorkerGlobalScope !== 'undefined' ? self : {};
|
||||
|
||||
})(this);
|
||||
|
||||
// Uses Node, AMD or browser globals to create a module.
|
||||
Konva.UA = Konva._parseUA((global.navigator && global.navigator.userAgent) || '');
|
||||
|
||||
// If you want something that will work in other stricter CommonJS environments,
|
||||
// or if you need to create a circular dependency, see commonJsStrict.js
|
||||
if (global.Konva) {
|
||||
console.error(
|
||||
'Konva instance is already exist in current eviroment. ' +
|
||||
'Please use only one instance.'
|
||||
);
|
||||
}
|
||||
global.Konva = Konva;
|
||||
Konva.global = global;
|
||||
|
||||
// Defines a module "returnExports" that depends another module called "b".
|
||||
// Note that the name of the module is implied by the file name. It is best
|
||||
// if the file name and the exported global have matching names.
|
||||
|
||||
// If the 'b' module also uses this type of boilerplate, then
|
||||
// in the browser, it will create a global .b that is used below.
|
||||
|
||||
// If you do not want to support the browser global path, then you
|
||||
// can remove the `root` use and the passing `this` as the first arg to
|
||||
// the top function.
|
||||
|
||||
// if the module has no dependencies, the above pattern can be simplified to
|
||||
( function(root, factory) {
|
||||
'use strict';
|
||||
if( typeof exports === 'object') {
|
||||
var KonvaJS = factory();
|
||||
// runtime-check for browserify and nw.js (node-webkit)
|
||||
if(global.window && global.window.document) {
|
||||
Konva.document = global.window.document;
|
||||
@@ -256,25 +235,18 @@ var Konva = {};
|
||||
Konva.window.Image = Canvas.Image;
|
||||
Konva._nodeCanvas = Canvas;
|
||||
}
|
||||
|
||||
Konva.root = root;
|
||||
module.exports = KonvaJS;
|
||||
module.exports = Konva;
|
||||
return;
|
||||
}
|
||||
else if( typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(factory);
|
||||
define(function() {
|
||||
return Konva;
|
||||
});
|
||||
}
|
||||
Konva.document = document;
|
||||
Konva.window = window;
|
||||
Konva.root = root;
|
||||
}(this, function() {
|
||||
'use strict';
|
||||
// Just return a value to define the module export.
|
||||
// This example returns an object, but the module
|
||||
// can return a function as the exported value.
|
||||
return Konva;
|
||||
}));
|
||||
})();
|
||||
|
||||
/*eslint-disable eqeqeq, no-cond-assign, no-empty*/
|
||||
(function() {
|
||||
@@ -1123,7 +1095,7 @@ var Konva = {};
|
||||
* IE9 on Windows7 64bit will throw a JS error
|
||||
* if we don't use window.console in the conditional
|
||||
*/
|
||||
if(Konva.root.console && console.warn && Konva.showWarnings) {
|
||||
if(Konva.global.console && console.warn && Konva.showWarnings) {
|
||||
console.warn(KONVA_WARNING + str);
|
||||
}
|
||||
},
|
||||
@@ -10029,9 +10001,9 @@ var Konva = {};
|
||||
var BATCH_DRAW_STOP_TIME_DIFF = 500;
|
||||
|
||||
var now = (function() {
|
||||
if (Konva.root.performance && Konva.root.performance.now) {
|
||||
if (Konva.global.performance && Konva.global.performance.now) {
|
||||
return function() {
|
||||
return Konva.root.performance.now();
|
||||
return Konva.global.performance.now();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10045,18 +10017,18 @@ var Konva = {};
|
||||
}
|
||||
|
||||
var RAF = (function(){
|
||||
return Konva.root.requestAnimationFrame
|
||||
|| Konva.root.webkitRequestAnimationFrame
|
||||
|| Konva.root.mozRequestAnimationFrame
|
||||
|| Konva.root.oRequestAnimationFrame
|
||||
|| Konva.root.msRequestAnimationFrame
|
||||
return Konva.global.requestAnimationFrame
|
||||
|| Konva.global.webkitRequestAnimationFrame
|
||||
|| Konva.global.mozRequestAnimationFrame
|
||||
|| Konva.global.oRequestAnimationFrame
|
||||
|| Konva.global.msRequestAnimationFrame
|
||||
|| FRAF;
|
||||
})();
|
||||
|
||||
|
||||
|
||||
function requestAnimFrame() {
|
||||
return RAF.apply(Konva.root, arguments);
|
||||
return RAF.apply(Konva.global, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
|
8
konva.min.js
vendored
8
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -3,9 +3,9 @@
|
||||
var BATCH_DRAW_STOP_TIME_DIFF = 500;
|
||||
|
||||
var now = (function() {
|
||||
if (Konva.root.performance && Konva.root.performance.now) {
|
||||
if (Konva.global.performance && Konva.global.performance.now) {
|
||||
return function() {
|
||||
return Konva.root.performance.now();
|
||||
return Konva.global.performance.now();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -19,18 +19,18 @@
|
||||
}
|
||||
|
||||
var RAF = (function(){
|
||||
return Konva.root.requestAnimationFrame
|
||||
|| Konva.root.webkitRequestAnimationFrame
|
||||
|| Konva.root.mozRequestAnimationFrame
|
||||
|| Konva.root.oRequestAnimationFrame
|
||||
|| Konva.root.msRequestAnimationFrame
|
||||
return Konva.global.requestAnimationFrame
|
||||
|| Konva.global.webkitRequestAnimationFrame
|
||||
|| Konva.global.mozRequestAnimationFrame
|
||||
|| Konva.global.oRequestAnimationFrame
|
||||
|| Konva.global.msRequestAnimationFrame
|
||||
|| FRAF;
|
||||
})();
|
||||
|
||||
|
||||
|
||||
function requestAnimFrame() {
|
||||
return RAF.apply(Konva.root, arguments);
|
||||
return RAF.apply(Konva.global, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -31,28 +31,13 @@
|
||||
// runtime check for already included Konva
|
||||
(function(){
|
||||
'use strict';
|
||||
var global =
|
||||
typeof window !== 'undefined' ? window :
|
||||
typeof global !== 'undefined' ? global :
|
||||
typeof WorkerGlobalScope !== 'undefined' ? self : {};
|
||||
|
||||
if (global.Konva) {
|
||||
console.error(
|
||||
'Konva instance is already exist in current eviroment. ' +
|
||||
'Please use only one instance.'
|
||||
);
|
||||
}
|
||||
})();
|
||||
|
||||
/**
|
||||
/**
|
||||
* @namespace Konva
|
||||
*/
|
||||
var Konva = {};
|
||||
(function(root) {
|
||||
'use strict';
|
||||
|
||||
var PI_OVER_180 = Math.PI / 180;
|
||||
|
||||
Konva = {
|
||||
var Konva = {
|
||||
// public
|
||||
version: '@@version',
|
||||
|
||||
@@ -215,31 +200,25 @@ var Konva = {};
|
||||
UA: undefined
|
||||
};
|
||||
|
||||
Konva.UA = Konva._parseUA((root.navigator && root.navigator.userAgent) || '');
|
||||
var global =
|
||||
typeof window !== 'undefined' ? window :
|
||||
typeof global !== 'undefined' ? global :
|
||||
typeof WorkerGlobalScope !== 'undefined' ? self : {};
|
||||
|
||||
})(this);
|
||||
|
||||
// Uses Node, AMD or browser globals to create a module.
|
||||
Konva.UA = Konva._parseUA((global.navigator && global.navigator.userAgent) || '');
|
||||
|
||||
// If you want something that will work in other stricter CommonJS environments,
|
||||
// or if you need to create a circular dependency, see commonJsStrict.js
|
||||
if (global.Konva) {
|
||||
console.error(
|
||||
'Konva instance is already exist in current eviroment. ' +
|
||||
'Please use only one instance.'
|
||||
);
|
||||
}
|
||||
global.Konva = Konva;
|
||||
Konva.global = global;
|
||||
|
||||
// Defines a module "returnExports" that depends another module called "b".
|
||||
// Note that the name of the module is implied by the file name. It is best
|
||||
// if the file name and the exported global have matching names.
|
||||
|
||||
// If the 'b' module also uses this type of boilerplate, then
|
||||
// in the browser, it will create a global .b that is used below.
|
||||
|
||||
// If you do not want to support the browser global path, then you
|
||||
// can remove the `root` use and the passing `this` as the first arg to
|
||||
// the top function.
|
||||
|
||||
// if the module has no dependencies, the above pattern can be simplified to
|
||||
( function(root, factory) {
|
||||
'use strict';
|
||||
if( typeof exports === 'object') {
|
||||
var KonvaJS = factory();
|
||||
// runtime-check for browserify and nw.js (node-webkit)
|
||||
if(global.window && global.window.document) {
|
||||
Konva.document = global.window.document;
|
||||
@@ -256,22 +235,15 @@ var Konva = {};
|
||||
Konva.window.Image = Canvas.Image;
|
||||
Konva._nodeCanvas = Canvas;
|
||||
}
|
||||
|
||||
Konva.root = root;
|
||||
module.exports = KonvaJS;
|
||||
module.exports = Konva;
|
||||
return;
|
||||
}
|
||||
else if( typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(factory);
|
||||
define(function() {
|
||||
return Konva;
|
||||
});
|
||||
}
|
||||
Konva.document = document;
|
||||
Konva.window = window;
|
||||
Konva.root = root;
|
||||
}(this, function() {
|
||||
'use strict';
|
||||
// Just return a value to define the module export.
|
||||
// This example returns an object, but the module
|
||||
// can return a function as the exported value.
|
||||
return Konva;
|
||||
}));
|
||||
})();
|
||||
|
@@ -845,7 +845,7 @@
|
||||
* IE9 on Windows7 64bit will throw a JS error
|
||||
* if we don't use window.console in the conditional
|
||||
*/
|
||||
if(Konva.root.console && console.warn && Konva.showWarnings) {
|
||||
if(Konva.global.console && console.warn && Konva.showWarnings) {
|
||||
console.warn(KONVA_WARNING + str);
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user