mirror of
https://github.com/photonstorm/phaser
synced 2024-11-15 17:28:18 +00:00
Merge pull request #6300 from EmilSV/spread_step_fix
fixed Phaser.Actions.Spread step value so the last element is equal max
This commit is contained in:
commit
d44db46253
1 changed files with 15 additions and 1 deletions
|
@ -32,8 +32,22 @@
|
|||
var Spread = function (items, property, min, max, inc)
|
||||
{
|
||||
if (inc === undefined) { inc = false; }
|
||||
if (items.length === 0) { return items; }
|
||||
if (items.length === 1) // if only one item put it at the center
|
||||
{
|
||||
if (inc)
|
||||
{
|
||||
items[0][property] += (max + min) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
items[0][property] = (max + min) / 2;
|
||||
}
|
||||
|
||||
var step = Math.abs(max - min) / items.length;
|
||||
return items;
|
||||
}
|
||||
|
||||
var step = Math.abs(max - min) / (items.length - 1);
|
||||
var i;
|
||||
|
||||
if (inc)
|
||||
|
|
Loading…
Reference in a new issue