gpt4 book ai didi

javascript - (gs.left != (t = left + "px") && (gs.left = t);) 是做什么的?

转载 作者:行者123 更新时间:2023-11-30 06:48:51 26 4
gpt4 key购买 nike

IE 似乎在来自未压缩的 raphaeljs 1.4.7 的以下第 2207 行(当然,在我的代码的上下文中):

gs.left != (t = left + "px") && (gs.left = t);

我不熟悉这种情况下的 != 语法,所以我发现很难弄清楚发生了什么或者为什么 IE 可能对此不满意。我已经在 IE6 和 IE8 以及 OSX 上的 Chrome 和 Firefox 中进行了测试。当然,如果在 FF 中出现问题,我会逐步使用 Firebug ...

你能告诉我这条线试图达到什么目的吗,更好的是,你能看出为什么 IE 可能会出现问题吗?

对于您的上下文,这是包含该行的完整方法:

    Element[proto].setBox = function (params, cx, cy) {
if (this.removed) {
return this;
}
var gs = this.Group.style,
os = (this.shape && this.shape.style) || this.node.style;
params = params || {};
for (var i in params) if (params[has](i)) {
this.attrs[i] = params[i];
}
cx = cx || this._.rt.cx;
cy = cy || this._.rt.cy;
var attr = this.attrs,
x,
y,
w,
h;
switch (this.type) {
case "circle":
x = attr.cx - attr.r;
y = attr.cy - attr.r;
w = h = attr.r * 2;
break;
case "ellipse":
x = attr.cx - attr.rx;
y = attr.cy - attr.ry;
w = attr.rx * 2;
h = attr.ry * 2;
break;
case "image":
x = +attr.x;
y = +attr.y;
w = attr.width || 0;
h = attr.height || 0;
break;
case "text":
this.textpath.v = ["m", round(attr.x), ", ", round(attr.y - 2), "l", round(attr.x) + 1, ", ", round(attr.y - 2)][join](E);
x = attr.x - round(this.W / 2);
y = attr.y - this.H / 2;
w = this.W;
h = this.H;
break;
case "rect":
case "path":
if (!this.attrs.path) {
x = 0;
y = 0;
w = this.paper.width;
h = this.paper.height;
} else {
var dim = pathDimensions(this.attrs.path);
x = dim.x;
y = dim.y;
w = dim.width;
h = dim.height;
}
break;
default:
x = 0;
y = 0;
w = this.paper.width;
h = this.paper.height;
break;
}
cx = (cx == null) ? x + w / 2 : cx;
cy = (cy == null) ? y + h / 2 : cy;
var left = cx - this.paper.width / 2,
top = cy - this.paper.height / 2, t;
gs.left != (t = left + "px") && (gs.left = t);
gs.top != (t = top + "px") && (gs.top = t);
this.X = pathlike[has](this.type) ? -left : x;
this.Y = pathlike[has](this.type) ? -top : y;
this.W = w;
this.H = h;
if (pathlike[has](this.type)) {
os.left != (t = -left * zoom + "px") && (os.left = t);
os.top != (t = -top * zoom + "px") && (os.top = t);
} else if (this.type == "text") {
os.left != (t = -left + "px") && (os.left = t);
os.top != (t = -top + "px") && (os.top = t);
} else {
gs.width != (t = this.paper.width + "px") && (gs.width = t);
gs.height != (t = this.paper.height + "px") && (gs.height = t);
os.left != (t = x - left + "px") && (os.left = t);
os.top != (t = y - top + "px") && (os.top = t);
os.width != (t = w + "px") && (os.width = t);
os.height != (t = h + "px") && (os.height = t);
}
};

最佳答案

这行代码没有任何问题——假设定义了 gs.leftleft。它相当于:

t = left + 'px';
if (gs.left != t) gs.left = t;

“窒息”到底是什么意思?

关于javascript - (gs.left != (t = left + "px") && (gs.left = t);) 是做什么的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3254407/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com