mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-05 20:34:45 +00:00
Fix few bracketless statements. Down to 257 failures on JSCS.
This commit is contained in:
parent
eb75f4b491
commit
2acdc7e85b
8 changed files with 121 additions and 41 deletions
|
|
@ -309,11 +309,21 @@
|
|||
* @return {Number}
|
||||
*/
|
||||
function hue2rgb(p, q, t){
|
||||
if (t < 0) t += 1;
|
||||
if (t > 1) t -= 1;
|
||||
if (t < 1/6) return p + (q - p) * 6 * t;
|
||||
if (t < 1/2) return q;
|
||||
if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;
|
||||
if (t < 0) {
|
||||
t += 1;
|
||||
}
|
||||
if (t > 1) {
|
||||
t -= 1;
|
||||
}
|
||||
if (t < 1/6) {
|
||||
return p + (q - p) * 6 * t;
|
||||
}
|
||||
if (t < 1/2) {
|
||||
return q;
|
||||
}
|
||||
if (t < 2/3) {
|
||||
return p + (q - p) * (2/3 - t) * 6;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -628,7 +628,9 @@
|
|||
var oStyle = { },
|
||||
style = element.getAttribute('style');
|
||||
|
||||
if (!style) return oStyle;
|
||||
if (!style) {
|
||||
return oStyle;
|
||||
}
|
||||
|
||||
if (typeof style === 'string') {
|
||||
parseStyleString(style, oStyle);
|
||||
|
|
|
|||
|
|
@ -133,11 +133,18 @@ fabric.Pattern = fabric.util.createClass(/** @lends fabric.Pattern.prototype */
|
|||
* @return {CanvasPattern}
|
||||
*/
|
||||
toLive: function(ctx) {
|
||||
var source = typeof this.source === 'function' ? this.source() : this.source;
|
||||
var source = typeof this.source === 'function'
|
||||
? this.source()
|
||||
: this.source;
|
||||
|
||||
// if an image
|
||||
if (typeof source.src !== 'undefined') {
|
||||
if (!source.complete) return '';
|
||||
if (source.naturalWidth === 0 || source.naturalHeight === 0) return '';
|
||||
if (!source.complete) {
|
||||
return '';
|
||||
}
|
||||
if (source.naturalWidth === 0 || source.naturalHeight === 0) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
return ctx.createPattern(source, this.repeat);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -651,10 +651,14 @@
|
|||
val;
|
||||
|
||||
val = parseInt(xy.x, 10);
|
||||
if (!isNaN(val)) aX.push(val);
|
||||
if (!isNaN(val)) {
|
||||
aX.push(val);
|
||||
}
|
||||
|
||||
val = parseInt(xy.y, 10);
|
||||
if (!isNaN(val)) aY.push(val);
|
||||
if (!isNaN(val)) {
|
||||
aY.push(val);
|
||||
}
|
||||
},
|
||||
|
||||
_getXY: function(item, isLowerCase, previous) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,13 @@
|
|||
(function() {
|
||||
|
||||
function normalize(a, c, p, s) {
|
||||
if (a < Math.abs(c)) { a = c; s = p / 4; }
|
||||
else s = p / (2 * Math.PI) * Math.asin(c / a);
|
||||
if (a < Math.abs(c)) {
|
||||
a = c;
|
||||
s = p / 4;
|
||||
}
|
||||
else {
|
||||
s = p / (2 * Math.PI) * Math.asin(c / a);
|
||||
}
|
||||
return { a: a, c: c, p: p, s: s };
|
||||
}
|
||||
|
||||
|
|
@ -26,7 +31,9 @@
|
|||
*/
|
||||
function easeInOutCubic(t, b, c, d) {
|
||||
t /= d/2;
|
||||
if (t < 1) return c / 2 * t * t * t + b;
|
||||
if (t < 1) {
|
||||
return c / 2 * t * t * t + b;
|
||||
}
|
||||
return c / 2 * ((t -= 2) * t * t + 2) + b;
|
||||
}
|
||||
|
||||
|
|
@ -52,7 +59,9 @@
|
|||
*/
|
||||
function easeInOutQuart(t, b, c, d) {
|
||||
t /= d / 2;
|
||||
if (t < 1) return c / 2 * t * t * t * t + b;
|
||||
if (t < 1) {
|
||||
return c / 2 * t * t * t * t + b;
|
||||
}
|
||||
return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +87,9 @@
|
|||
*/
|
||||
function easeInOutQuint(t, b, c, d) {
|
||||
t /= d / 2;
|
||||
if (t < 1) return c / 2 * t * t * t * t * t + b;
|
||||
if (t < 1) {
|
||||
return c / 2 * t * t * t * t * t + b;
|
||||
}
|
||||
return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
|
||||
}
|
||||
|
||||
|
|
@ -127,10 +138,16 @@
|
|||
* @memberOf fabric.util.ease
|
||||
*/
|
||||
function easeInOutExpo(t, b, c, d) {
|
||||
if (t === 0) return b;
|
||||
if (t === d) return b + c;
|
||||
if (t === 0) {
|
||||
return b;
|
||||
}
|
||||
if (t === d) {
|
||||
return b + c;
|
||||
}
|
||||
t /= d / 2;
|
||||
if (t < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
|
||||
if (t < 1) {
|
||||
return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
|
||||
}
|
||||
return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
|
||||
}
|
||||
|
||||
|
|
@ -156,7 +173,9 @@
|
|||
*/
|
||||
function easeInOutCirc(t, b, c, d) {
|
||||
t /= d / 2;
|
||||
if (t < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
|
||||
if (t < 1) {
|
||||
return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
|
||||
}
|
||||
return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
|
||||
}
|
||||
|
||||
|
|
@ -166,10 +185,16 @@
|
|||
*/
|
||||
function easeInElastic(t, b, c, d) {
|
||||
var s = 1.70158, p = 0, a = c;
|
||||
if (t === 0) return b;
|
||||
if (t === 0) {
|
||||
return b;
|
||||
}
|
||||
t /= d;
|
||||
if (t === 1) return b + c;
|
||||
if (!p) p = d * 0.3;
|
||||
if (t === 1) {
|
||||
return b + c;
|
||||
}
|
||||
if (!p) {
|
||||
p = d * 0.3;
|
||||
}
|
||||
var opts = normalize(a, c, p, s);
|
||||
return -elastic(opts, t, d) + b;
|
||||
}
|
||||
|
|
@ -180,10 +205,16 @@
|
|||
*/
|
||||
function easeOutElastic(t, b, c, d) {
|
||||
var s = 1.70158, p = 0, a = c;
|
||||
if (t === 0) return b;
|
||||
if (t === 0) {
|
||||
return b;
|
||||
}
|
||||
t /= d;
|
||||
if (t === 1) return b + c;
|
||||
if (!p) p = d * 0.3;
|
||||
if (t === 1) {
|
||||
return b + c;
|
||||
}
|
||||
if (!p) {
|
||||
p = d * 0.3;
|
||||
}
|
||||
var opts = normalize(a, c, p, s);
|
||||
return opts.a * Math.pow(2, -10 * t) * Math.sin((t * d - opts.s) * (2 * Math.PI) / opts.p ) + opts.c + b;
|
||||
}
|
||||
|
|
@ -194,12 +225,20 @@
|
|||
*/
|
||||
function easeInOutElastic(t, b, c, d) {
|
||||
var s = 1.70158, p = 0, a = c;
|
||||
if (t === 0) return b;
|
||||
if (t === 0) {
|
||||
return b;
|
||||
}
|
||||
t /= d / 2;
|
||||
if (t === 2) return b + c;
|
||||
if (!p) p = d * (0.3 * 1.5);
|
||||
if (t === 2) {
|
||||
return b + c;
|
||||
}
|
||||
if (!p) {
|
||||
p = d * (0.3 * 1.5);
|
||||
}
|
||||
var opts = normalize(a, c, p, s);
|
||||
if (t < 1) return -0.5 * elastic(opts, t, d) + b;
|
||||
if (t < 1) {
|
||||
return -0.5 * elastic(opts, t, d) + b;
|
||||
}
|
||||
return opts.a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - opts.s) * (2 * Math.PI) / opts.p ) * 0.5 + opts.c + b;
|
||||
}
|
||||
|
||||
|
|
@ -208,7 +247,9 @@
|
|||
* @memberOf fabric.util.ease
|
||||
*/
|
||||
function easeInBack(t, b, c, d, s) {
|
||||
if (s === undefined) s = 1.70158;
|
||||
if (s === undefined) {
|
||||
s = 1.70158;
|
||||
}
|
||||
return c * (t /= d) * t * ((s + 1) * t - s) + b;
|
||||
}
|
||||
|
||||
|
|
@ -217,7 +258,9 @@
|
|||
* @memberOf fabric.util.ease
|
||||
*/
|
||||
function easeOutBack(t, b, c, d, s) {
|
||||
if (s === undefined) s = 1.70158;
|
||||
if (s === undefined) {
|
||||
s = 1.70158;
|
||||
}
|
||||
return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
|
||||
}
|
||||
|
||||
|
|
@ -226,9 +269,13 @@
|
|||
* @memberOf fabric.util.ease
|
||||
*/
|
||||
function easeInOutBack(t, b, c, d, s) {
|
||||
if (s === undefined) s = 1.70158;
|
||||
if (s === undefined) {
|
||||
s = 1.70158;
|
||||
}
|
||||
t /= d / 2;
|
||||
if (t < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
|
||||
if (t < 1) {
|
||||
return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
|
||||
}
|
||||
return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
|
||||
}
|
||||
|
||||
|
|
@ -264,8 +311,10 @@
|
|||
* @memberOf fabric.util.ease
|
||||
*/
|
||||
function easeInOutBounce(t, b, c, d) {
|
||||
if (t < d / 2) return easeInBounce (t * 2, 0, c, d) * 0.5 + b;
|
||||
return easeOutBounce (t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;
|
||||
if (t < d / 2) {
|
||||
return easeInBounce (t * 2, 0, c, d) * 0.5 + b;
|
||||
}
|
||||
return easeOutBounce(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -297,7 +346,9 @@
|
|||
*/
|
||||
easeInOutQuad: function(t, b, c, d) {
|
||||
t /= (d / 2);
|
||||
if (t < 1) return c / 2 * t * t + b;
|
||||
if (t < 1) {
|
||||
return c / 2 * t * t + b;
|
||||
}
|
||||
return -c / 2 * ((--t) * (t - 2) - 1) + b;
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -21,10 +21,14 @@
|
|||
|
||||
sfactorSq = 1 / d - 0.25;
|
||||
|
||||
if (sfactorSq < 0) sfactorSq = 0;
|
||||
if (sfactorSq < 0) {
|
||||
sfactorSq = 0;
|
||||
}
|
||||
|
||||
var sfactor = Math.sqrt(sfactorSq);
|
||||
if (sweep === large) sfactor = -sfactor;
|
||||
if (sweep === large) {
|
||||
sfactor = -sfactor;
|
||||
}
|
||||
|
||||
var xc = 0.5 * (coords.x0 + coords.x1) - sfactor * (coords.y1 - coords.y0),
|
||||
yc = 0.5 * (coords.y0 + coords.y1) + sfactor * (coords.x1 - coords.x0),
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@
|
|||
* @private
|
||||
*/
|
||||
function find(array, byProperty, condition) {
|
||||
if (!array || array.length === 0) return undefined;
|
||||
if (!array || array.length === 0) return;
|
||||
|
||||
var i = array.length - 1,
|
||||
result = byProperty ? array[i][byProperty] : array[i];
|
||||
|
|
|
|||
|
|
@ -123,7 +123,9 @@
|
|||
* @return {Object} Object for given namespace (default fabric)
|
||||
*/
|
||||
resolveNamespace: function(namespace) {
|
||||
if (!namespace) return fabric;
|
||||
if (!namespace) {
|
||||
return fabric;
|
||||
}
|
||||
|
||||
var parts = namespace.split('.'),
|
||||
len = parts.length,
|
||||
|
|
|
|||
Loading…
Reference in a new issue