_positionBubble (target) {
        const bubbleState = this._getBubbleState(target);
        const [bubbleWidth, bubbleHeight] = this.runtime.renderer.getSkinSize(bubbleState.drawableId);
        const targetBounds = target.getBounds();
        const stageBounds = this.runtime.getTargetForStage().getBounds();
        if (bubbleState.onSpriteRight && bubbleWidth + targetBounds.right > stageBounds.right &&
            (targetBounds.left - bubbleWidth > stageBounds.left)) { // Only flip if it would fit
            bubbleState.onSpriteRight = false;
            this._renderBubble(target);
        } else if (!bubbleState.onSpriteRight && targetBounds.left - bubbleWidth < stageBounds.left &&
            (bubbleWidth + targetBounds.right < stageBounds.right)) { // Only flip if it would fit
            bubbleState.onSpriteRight = true;
            this._renderBubble(target);
        } else {
            this.runtime.renderer.updateDrawableProperties(bubbleState.drawableId, {
                position: [
                    bubbleState.onSpriteRight ? (
                        Math.min(stageBounds.right - bubbleWidth, targetBounds.right)
                    ) : (
                        Math.max(stageBounds.left, targetBounds.left - bubbleWidth)
                    ),
                    Math.min(stageBounds.top, targetBounds.top + bubbleHeight)
                ]
            });
            this.runtime.requestRedraw();
        }
    }
/**
     * Position the bubble of a target. If it doesn't fit on the specified side, flip and rerender.
     * @param {!Target} target Target whose bubble needs positioning.
     * @private
     */
Position the bubble of a target. If it doesn't fit on the specified side, flip and rerender.
@param {!Target} target Target whose bubble needs positioning.
@private
Position the bubble of a target . If it doesn ' t fit on the specified side flip and rerender . @param { !Target } target Target whose bubble needs positioning . @private
_positionBubble (target) {
        const bubbleState = this._getBubbleState(target);
        const [bubbleWidth, bubbleHeight] = this.runtime.renderer.getSkinSize(bubbleState.drawableId);
        const targetBounds = target.getBounds();
        const stageBounds = this.runtime.getTargetForStage().getBounds();
        if (bubbleState.onSpriteRight && bubbleWidth + targetBounds.right > stageBounds.right &&
            (targetBounds.left - bubbleWidth > stageBounds.left)) { 
            bubbleState.onSpriteRight = false;
            this._renderBubble(target);
        } else if (!bubbleState.onSpriteRight && targetBounds.left - bubbleWidth < stageBounds.left &&
            (bubbleWidth + targetBounds.right < stageBounds.right)) { 
            bubbleState.onSpriteRight = true;
            this._renderBubble(target);
        } else {
            this.runtime.renderer.updateDrawableProperties(bubbleState.drawableId, {
                position: [
                    bubbleState.onSpriteRight ? (
                        Math.min(stageBounds.right - bubbleWidth, targetBounds.right)
                    ) : (
                        Math.max(stageBounds.left, targetBounds.left - bubbleWidth)
                    ),
                    Math.min(stageBounds.top, targetBounds.top + bubbleHeight)
                ]
            });
            this.runtime.requestRedraw();
        }
    }
_positionBubble ( target ) { const bubbleState = this . _getBubbleState ( target ) ; const [ bubbleWidth , bubbleHeight ] = this . runtime . renderer . getSkinSize ( bubbleState . drawableId ) ; const targetBounds = target . getBounds ( ) ; const stageBounds = this . runtime . getTargetForStage ( ) . getBounds ( ) ; if ( bubbleState . onSpriteRight && bubbleWidth + targetBounds . right > stageBounds . right && ( targetBounds . left - bubbleWidth > stageBounds . left ) ) { bubbleState . onSpriteRight = false ; this . _renderBubble ( target ) ; } else if ( ! bubbleState . onSpriteRight && targetBounds . left - bubbleWidth < stageBounds . left && ( bubbleWidth + targetBounds . right < stageBounds . right ) ) { bubbleState . onSpriteRight = true ; this . _renderBubble ( target ) ; } else { this . runtime . renderer . updateDrawableProperties ( bubbleState . drawableId , { position : [ bubbleState . onSpriteRight ? ( Math . min ( stageBounds . right - bubbleWidth , targetBounds . right ) ) : ( Math . max ( stageBounds . left , targetBounds . left - bubbleWidth ) ) , Math . min ( stageBounds . top , targetBounds . top + bubbleHeight ) ] } ) ; this . runtime . requestRedraw ( ) ; } }
Position the bubble of a target.
Position the bubble of a target .
// Only flip if it would fit // Only flip if it would fit