0

我有以下代码:

this.resize2.intrface.transform(Raphael.format("t{0},{1},S{2},{3},{4},{5}{6}",
                                    this.resize2.intrface.ox,
                                    this.resize2.intrface.oy,                                                
                                    xmove,    
                                    ymove,
                                    this.resize2.bbx,
                                    this.resize2.bby,
                                    this.resize2.intrface.scale));
this.resize2.core.transform(Raphael.format("t{0},{1},S{2},{3},{4},{5}{6}",
                                    this.resize2.intrface.ox,
                                    this.resize2.intrface.oy,                                                
                                    xmove,    
                                    ymove,
                                    this.resize2.bbx,
                                    this.resize2.bby,
                                    this.resize2.intrface.scale));

我想将变换函数应用于一行中的两个对象。这可能吗?为了说明我打算做什么,请参见下面的以下(不工作)示例:

$(this.resize2.intrface, this.resize2.core).transform(Raphael.format("t{0},{1},S{2},{3},{4},{5}{6}",
                                    this.resize2.intrface.ox,
                                    this.resize2.intrface.oy,                                                
                                    xmove,    
                                    ymove,
                                    this.resize2.bbx,
                                    this.resize2.bby,
                                    this.resize2.intrface.scale));

谢谢!

4

1 回答 1

0

这是关于一些重复的代码重构。

function transform(factoryMethod) {
    factoryMethod(Raphael.format("t{0},{1},S{2},{3},{4},{5}{6}",
                    this.resize2.intrface.ox,
                    this.resize2.intrface.oy,
                    xmove,    
                    ymove,
                    this.resize2.bbx,
                    this.resize2.bby,
                    this.resize2.intrface.scale));
}

使用它来调用:

transform.apply(this, [this.resize2.intrface.transform]);
transform.apply(this, [this.resize2.core.transform]);
于 2012-09-17T15:56:52.467 回答