diff --git a/src/Components/Core/Presentation/Babylon/LearningElements/LearningElementController.ts b/src/Components/Core/Presentation/Babylon/LearningElements/LearningElementController.ts index 5d8e825d1..10be75958 100644 --- a/src/Components/Core/Presentation/Babylon/LearningElements/LearningElementController.ts +++ b/src/Components/Core/Presentation/Babylon/LearningElements/LearningElementController.ts @@ -14,6 +14,8 @@ export default class LearningElementController implements ILearningElementController { private bottomTooltipPresenter: IBottomTooltipPresenter; + private proximityToolTipId: number = -1; + private hoverToolTipId: number = -1; constructor(private viewModel: LearningElementViewModel) { this.bottomTooltipPresenter = CoreDIContainer.get( @@ -25,14 +27,19 @@ export default class LearningElementController @bind pointerOver(): void { - this.displayTooltip(); - this.scaleUpIcon(); + if (this.proximityToolTipId === -1 && this.hoverToolTipId === -1) { + this.proximityToolTipId = this.displayTooltip(); + this.scaleUpIcon(); + } } @bind pointerOut(): void { - this.bottomTooltipPresenter.hide(); - this.resetIconScale(); + if (this.hoverToolTipId !== -1) { + this.resetIconScale(); + this.bottomTooltipPresenter.hide(this.hoverToolTipId); + this.hoverToolTipId = -1; + } } @bind @@ -49,16 +56,16 @@ export default class LearningElementController @bind private onAvatarInteractableChange(isInteractable: boolean): void { if (isInteractable) { - this.displayTooltip(); + this.proximityToolTipId = this.displayTooltip(); this.scaleUpIcon(); - } else { - this.bottomTooltipPresenter.hide(); + } else if (this.proximityToolTipId !== -1) { + this.bottomTooltipPresenter.hide(this.proximityToolTipId); this.resetIconScale(); } } - private displayTooltip(): void { - this.bottomTooltipPresenter.display( + private displayTooltip(): number { + return this.bottomTooltipPresenter.display( this.viewModel.name, this.viewModel.type, this.viewModel.value, diff --git a/src/Components/Core/Presentation/Babylon/LearningElements/LearningElementPresenter.ts b/src/Components/Core/Presentation/Babylon/LearningElements/LearningElementPresenter.ts index 32363279c..295898310 100644 --- a/src/Components/Core/Presentation/Babylon/LearningElements/LearningElementPresenter.ts +++ b/src/Components/Core/Presentation/Babylon/LearningElements/LearningElementPresenter.ts @@ -31,7 +31,6 @@ export default class LearningElementPresenter if (distance <= interactionRadius) this.viewModel.isInteractable.Value = true; - else if (this.viewModel.isInteractable.Value) - this.viewModel.isInteractable.Value = false; + else this.viewModel.isInteractable.Value = false; } }