Skip to content

Commit 32bc492

Browse files
committed
Camera won't scroll out of bounds if bounds smaller than camera size. Fix phaserjs#3133.
1 parent 30e9699 commit 32bc492

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

v3/src/camera/2d/inc/PreRender.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,25 @@ var PreRender = function ()
2121
{
2222
var bounds = this._bounds;
2323

24-
// width = bounds.width;
25-
// height = bounds.height;
26-
27-
// var boundsX = bounds.x;
28-
// var boundsY = bounds.y;
29-
// var boundsR = Math.max(bounds.right - width, width);
30-
// var boundsB = Math.max(bounds.bottom - height, height);
24+
var bw = Math.max(0, bounds.right - width);
25+
var bh = Math.max(0, bounds.bottom - height);
3126

3227
if (this.scrollX < bounds.x)
3328
{
3429
this.scrollX = bounds.x;
3530
}
36-
else if (this.scrollX > bounds.right)
31+
else if (this.scrollX > bw)
3732
{
38-
this.scrollX = bounds.right;
33+
this.scrollX = bw;
3934
}
4035

4136
if (this.scrollY < bounds.y)
4237
{
4338
this.scrollY = bounds.y;
4439
}
45-
else if (this.scrollY > bounds.bottom)
40+
else if (this.scrollY > bh)
4641
{
47-
this.scrollY = bounds.bottom;
42+
this.scrollY = bh;
4843
}
4944
}
5045

0 commit comments

Comments
 (0)