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