mirror of
https://github.com/konvajs/konva.git
synced 2025-09-19 10:47:59 +08:00
lots of jshinting
This commit is contained in:
@@ -131,6 +131,9 @@ module.exports = function(grunt) {
|
|||||||
build: ['dist/*']
|
build: ['dist/*']
|
||||||
},
|
},
|
||||||
jshint: {
|
jshint: {
|
||||||
|
options: {
|
||||||
|
laxbreak: true
|
||||||
|
},
|
||||||
all: ['src/**/*.js']
|
all: ['src/**/*.js']
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -132,8 +132,8 @@
|
|||||||
try {
|
try {
|
||||||
return this.element.toDataURL();
|
return this.element.toDataURL();
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(err) {
|
||||||
Kinetic.Util.warn('Unable to get data URL. ' + e.message)
|
Kinetic.Util.warn('Unable to get data URL. ' + err.message);
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,7 @@
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
drawScene: function(canvas) {
|
drawScene: function(canvas) {
|
||||||
var canvas = canvas || this.getCanvas();
|
canvas = canvas || this.getCanvas();
|
||||||
|
|
||||||
if(this.getClearBeforeDraw()) {
|
if(this.getClearBeforeDraw()) {
|
||||||
canvas.clear();
|
canvas.clear();
|
||||||
|
11
src/Node.js
11
src/Node.js
@@ -128,7 +128,7 @@
|
|||||||
off: function(typesStr) {
|
off: function(typesStr) {
|
||||||
var types = typesStr.split(SPACE),
|
var types = typesStr.split(SPACE),
|
||||||
len = types.length,
|
len = types.length,
|
||||||
n, type, event, parts, baseEvent;
|
n, type, t, event, parts, baseEvent;
|
||||||
|
|
||||||
for(n = 0; n < len; n++) {
|
for(n = 0; n < len; n++) {
|
||||||
type = types[n];
|
type = types[n];
|
||||||
@@ -143,8 +143,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(var type in this.eventListeners) {
|
for(t in this.eventListeners) {
|
||||||
this._off(type, parts[1]);
|
this._off(t, parts[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -868,8 +868,9 @@
|
|||||||
* is very high quality
|
* is very high quality
|
||||||
*/
|
*/
|
||||||
toDataURL: function(config) {
|
toDataURL: function(config) {
|
||||||
var config = config || {},
|
config = config || {};
|
||||||
mimeType = config.mimeType || null,
|
|
||||||
|
var mimeType = config.mimeType || null,
|
||||||
quality = config.quality || null,
|
quality = config.quality || null,
|
||||||
stage = this.getStage(),
|
stage = this.getStage(),
|
||||||
x = config.x || 0,
|
x = config.x || 0,
|
||||||
|
@@ -179,8 +179,9 @@
|
|||||||
delete Kinetic.Global.shapes[this.colorKey];
|
delete Kinetic.Global.shapes[this.colorKey];
|
||||||
},
|
},
|
||||||
drawScene: function(canvas) {
|
drawScene: function(canvas) {
|
||||||
|
canvas = canvas || this.getLayer().getCanvas();
|
||||||
|
|
||||||
var drawFunc = this.getDrawFunc(),
|
var drawFunc = this.getDrawFunc(),
|
||||||
canvas = canvas || this.getLayer().getCanvas(),
|
|
||||||
context = canvas.getContext();
|
context = canvas.getContext();
|
||||||
|
|
||||||
if(drawFunc && this.isVisible()) {
|
if(drawFunc && this.isVisible()) {
|
||||||
|
10
src/Stage.js
10
src/Stage.js
@@ -5,7 +5,6 @@
|
|||||||
PX = 'px',
|
PX = 'px',
|
||||||
MOUSEOUT = 'mouseout',
|
MOUSEOUT = 'mouseout',
|
||||||
MOUSELEAVE = 'mouseleave',
|
MOUSELEAVE = 'mouseleave',
|
||||||
MOUSEOUT = 'mouseout',
|
|
||||||
MOUSEOVER = 'mouseover',
|
MOUSEOVER = 'mouseover',
|
||||||
MOUSEENTER = 'mouseenter',
|
MOUSEENTER = 'mouseenter',
|
||||||
MOUSEMOVE = 'mousemove',
|
MOUSEMOVE = 'mousemove',
|
||||||
@@ -13,8 +12,8 @@
|
|||||||
MOUSEUP = 'mouseup',
|
MOUSEUP = 'mouseup',
|
||||||
CLICK = 'click',
|
CLICK = 'click',
|
||||||
DBL_CLICK = 'dblclick',
|
DBL_CLICK = 'dblclick',
|
||||||
TOUCHSTART = 'touchstart'
|
TOUCHSTART = 'touchstart',
|
||||||
TOUCHEND = 'touchend'
|
TOUCHEND = 'touchend',
|
||||||
TAP = 'tap',
|
TAP = 'tap',
|
||||||
DBL_TAP = 'dbltap',
|
DBL_TAP = 'dbltap',
|
||||||
TOUCHMOVE = 'touchmove',
|
TOUCHMOVE = 'touchmove',
|
||||||
@@ -191,8 +190,9 @@
|
|||||||
* is very high quality
|
* is very high quality
|
||||||
*/
|
*/
|
||||||
toDataURL: function(config) {
|
toDataURL: function(config) {
|
||||||
var config = config || {},
|
config = config || {};
|
||||||
mimeType = config.mimeType || null,
|
|
||||||
|
var mimeType = config.mimeType || null,
|
||||||
quality = config.quality || null,
|
quality = config.quality || null,
|
||||||
x = config.x || 0,
|
x = config.x || 0,
|
||||||
y = config.y || 0,
|
y = config.y || 0,
|
||||||
|
27
src/Util.js
27
src/Util.js
@@ -13,8 +13,8 @@
|
|||||||
this[i] = args[i];
|
this[i] = args[i];
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
};
|
||||||
Kinetic.Collection.prototype = new Array();
|
Kinetic.Collection.prototype = [];
|
||||||
/**
|
/**
|
||||||
* iterate through node array and run a function for each node.
|
* iterate through node array and run a function for each node.
|
||||||
* The node and index is passed into the function
|
* The node and index is passed into the function
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
*/
|
*/
|
||||||
Kinetic.Transform = function() {
|
Kinetic.Transform = function() {
|
||||||
this.m = [1, 0, 0, 1, 0, 0];
|
this.m = [1, 0, 0, 1, 0, 0];
|
||||||
}
|
};
|
||||||
|
|
||||||
Kinetic.Transform.prototype = {
|
Kinetic.Transform.prototype = {
|
||||||
/**
|
/**
|
||||||
@@ -449,18 +449,22 @@
|
|||||||
* an array of point objects
|
* an array of point objects
|
||||||
*/
|
*/
|
||||||
_getPoints: function(arg) {
|
_getPoints: function(arg) {
|
||||||
|
var arr = [],
|
||||||
|
n, len;
|
||||||
|
|
||||||
if(arg === undefined) {
|
if(arg === undefined) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
len = arg.length;
|
||||||
|
|
||||||
// an array of arrays
|
// an array of arrays
|
||||||
if(this._isArray(arg[0])) {
|
if(this._isArray(arg[0])) {
|
||||||
/*
|
/*
|
||||||
* convert array of arrays into an array
|
* convert array of arrays into an array
|
||||||
* of objects containing x, y
|
* of objects containing x, y
|
||||||
*/
|
*/
|
||||||
var arr = [];
|
for(n = 0; n < len; n++) {
|
||||||
for(var n = 0; n < arg.length; n++) {
|
|
||||||
arr.push({
|
arr.push({
|
||||||
x: arg[n][0],
|
x: arg[n][0],
|
||||||
y: arg[n][1]
|
y: arg[n][1]
|
||||||
@@ -479,8 +483,7 @@
|
|||||||
* convert array of numbers into an array
|
* convert array of numbers into an array
|
||||||
* of objects containing x, y
|
* of objects containing x, y
|
||||||
*/
|
*/
|
||||||
var arr = [];
|
for(n = 0; n < len; n += 2) {
|
||||||
for(var n = 0; n < arg.length; n += 2) {
|
|
||||||
arr.push({
|
arr.push({
|
||||||
x: arg[n],
|
x: arg[n],
|
||||||
y: arg[n + 1]
|
y: arg[n + 1]
|
||||||
@@ -511,7 +514,7 @@
|
|||||||
imageObj = new Image();
|
imageObj = new Image();
|
||||||
imageObj.onload = function() {
|
imageObj.onload = function() {
|
||||||
callback(imageObj);
|
callback(imageObj);
|
||||||
}
|
};
|
||||||
imageObj.src = arg;
|
imageObj.src = arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,7 +529,7 @@
|
|||||||
imageObj = new Image();
|
imageObj = new Image();
|
||||||
imageObj.onload = function() {
|
imageObj.onload = function() {
|
||||||
callback(imageObj);
|
callback(imageObj);
|
||||||
}
|
};
|
||||||
imageObj.src = dataUrl;
|
imageObj.src = dataUrl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -587,9 +590,9 @@
|
|||||||
else if (color.substr(0, 4) === RGB_PAREN) {
|
else if (color.substr(0, 4) === RGB_PAREN) {
|
||||||
rgb = RGB_REGEX.exec(color.replace(/ /g,''));
|
rgb = RGB_REGEX.exec(color.replace(/ /g,''));
|
||||||
return {
|
return {
|
||||||
r: parseInt(rgb[1]),
|
r: parseInt(rgb[1], 10),
|
||||||
g: parseInt(rgb[2]),
|
g: parseInt(rgb[2], 10),
|
||||||
b: parseInt(rgb[3])
|
b: parseInt(rgb[3], 10)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// default
|
// default
|
||||||
|
@@ -37,16 +37,18 @@
|
|||||||
|
|
||||||
// tension
|
// tension
|
||||||
if(tension !== 0 && length > 2) {
|
if(tension !== 0 && length > 2) {
|
||||||
var ap = this.allPoints, len = ap.length;
|
var ap = this.allPoints,
|
||||||
var n = 0;
|
len = ap.length,
|
||||||
|
n, point;
|
||||||
|
|
||||||
while(n < len-1) {
|
while(n < len-1) {
|
||||||
context.bezierCurveTo(ap[n].x, ap[n++].y, ap[n].x, ap[n++].y, ap[n].x, ap[n++].y);
|
context.bezierCurveTo(ap[n].x, ap[n++].y, ap[n].x, ap[n++].y, ap[n].x, ap[n++].y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// no tension
|
// no tension
|
||||||
else {
|
else {
|
||||||
for(var n = 1; n < length; n++) {
|
for(n = 1; n < length; n++) {
|
||||||
var point = points[n];
|
point = points[n];
|
||||||
context.lineTo(point.x, point.y);
|
context.lineTo(point.x, point.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user