PDA

View Full Version : [4.0.0] Ext.draw.Surface.add() - wrong return value when adding multiple sprites



LesJ
27 Apr 2011, 7:37 AM
The add() method allows to add multiple sprites in a single call... this is a nice feature... B)

... however, the return value (results) should be a CompositeSprite, not just an array.

I'd like to be able to add multiple sprites and chain the show(true) method.

surface.add[sprites].show(true);

Also, see this bug [FIXED-EXTJSIV-1502]:

http://www.sencha.com/forum/showthread.php?131050-FIXED-EXTJSIV-1502-B3-CompositeSprite-remove-unneeded-param-in-hide()-and-show()&p=593864#post593864



Ext.define('Ext.draw.Surface', {
...
add: function() {
var args = Array.prototype.slice.call(arguments),
sprite,
index;

var hasMultipleArgs = args.length > 1;
if (hasMultipleArgs || Ext.isArray(args[0])) {
var items = hasMultipleArgs ? args : args[0],
results = [],
i, ln, item;

for (i = 0, ln = items.length; i < ln; i++) {
item = items[i];
item = this.add(item);
results.push(item);
}

return results;
}
sprite = this.prepareItems(args[0], true)[0];
this.normalizeSpriteCollection(sprite);
this.onAdd(sprite);
return sprite;
}
...