mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 15:02:52 -05:00
Handle positioning bubbles for empty costumes
This commit is contained in:
parent
54d5be8bba
commit
393b5d54df
1 changed files with 13 additions and 1 deletions
|
@ -120,7 +120,19 @@ class Scratch3LooksBlocks {
|
||||||
if (!target.visible) return;
|
if (!target.visible) return;
|
||||||
const bubbleState = this._getBubbleState(target);
|
const bubbleState = this._getBubbleState(target);
|
||||||
const [bubbleWidth, bubbleHeight] = this.runtime.renderer.getCurrentSkinSize(bubbleState.drawableId);
|
const [bubbleWidth, bubbleHeight] = this.runtime.renderer.getCurrentSkinSize(bubbleState.drawableId);
|
||||||
const targetBounds = target.getBoundsForBubble();
|
let targetBounds;
|
||||||
|
try {
|
||||||
|
targetBounds = target.getBoundsForBubble();
|
||||||
|
} catch (error_) {
|
||||||
|
// Bounds calculation could fail (e.g. on empty costumes), in that case
|
||||||
|
// use the x/y position of the target.
|
||||||
|
targetBounds = {
|
||||||
|
left: target.x,
|
||||||
|
right: target.x,
|
||||||
|
top: target.y,
|
||||||
|
bottom: target.y
|
||||||
|
};
|
||||||
|
}
|
||||||
const stageBounds = this.runtime.getTargetForStage().getBounds();
|
const stageBounds = this.runtime.getTargetForStage().getBounds();
|
||||||
if (bubbleState.onSpriteRight && bubbleWidth + targetBounds.right > stageBounds.right &&
|
if (bubbleState.onSpriteRight && bubbleWidth + targetBounds.right > stageBounds.right &&
|
||||||
(targetBounds.left - bubbleWidth > stageBounds.left)) { // Only flip if it would fit
|
(targetBounds.left - bubbleWidth > stageBounds.left)) { // Only flip if it would fit
|
||||||
|
|
Loading…
Reference in a new issue