2021-01-21 17:20:10 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
2020-05-29 00:33:49 +08:00
|
|
|
|
using AntDesign.Internal;
|
2021-01-21 17:20:10 +08:00
|
|
|
|
using Microsoft.AspNetCore.Components;
|
2020-05-21 12:21:22 +08:00
|
|
|
|
using OneOf;
|
2020-05-19 22:34:09 +08:00
|
|
|
|
|
2020-05-29 00:33:49 +08:00
|
|
|
|
namespace AntDesign
|
2020-05-19 22:34:09 +08:00
|
|
|
|
{
|
|
|
|
|
public partial class Tooltip : OverlayTrigger
|
|
|
|
|
{
|
|
|
|
|
[Parameter]
|
2020-07-24 23:05:38 +08:00
|
|
|
|
public OneOf<string, RenderFragment, MarkupString> Title { get; set; } = string.Empty;
|
2020-05-19 22:34:09 +08:00
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public bool ArrowPointAtCenter { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public double MouseEnterDelay { get; set; } = 0.1;
|
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public double MouseLeaveDelay { get; set; } = 0.1;
|
|
|
|
|
|
|
|
|
|
public Tooltip()
|
|
|
|
|
{
|
|
|
|
|
PrefixCls = "ant-tooltip";
|
2020-05-21 12:21:22 +08:00
|
|
|
|
Placement = PlacementType.Top;
|
2020-05-19 22:34:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-23 22:51:02 +08:00
|
|
|
|
internal override string GetOverlayEnterClass()
|
2020-05-19 22:34:09 +08:00
|
|
|
|
{
|
2020-05-21 12:21:22 +08:00
|
|
|
|
return "zoom-big-fast-enter zoom-big-fast-enter-active zoom-big-fast";
|
2020-05-19 22:34:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-23 22:51:02 +08:00
|
|
|
|
internal override string GetOverlayLeaveClass()
|
2020-05-19 22:34:09 +08:00
|
|
|
|
{
|
2020-05-21 12:21:22 +08:00
|
|
|
|
return "zoom-big-fast-leave zoom-big-fast-leave-active zoom-big-fast";
|
2020-05-19 22:34:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-23 22:51:02 +08:00
|
|
|
|
internal override async Task Show(int? overlayLeft = null, int? overlayTop = null)
|
2020-05-19 22:34:09 +08:00
|
|
|
|
{
|
|
|
|
|
if (Trigger.Contains(TriggerType.Hover))
|
|
|
|
|
{
|
|
|
|
|
await Task.Delay((int)(MouseEnterDelay * 1000));
|
|
|
|
|
}
|
2020-05-21 12:21:22 +08:00
|
|
|
|
|
2020-05-19 22:34:09 +08:00
|
|
|
|
await base.Show(overlayLeft, overlayTop);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-23 22:51:02 +08:00
|
|
|
|
internal override async Task Hide(bool force = false)
|
2020-05-19 22:34:09 +08:00
|
|
|
|
{
|
|
|
|
|
if (Trigger.Contains(TriggerType.Hover))
|
|
|
|
|
{
|
|
|
|
|
await Task.Delay((int)(MouseLeaveDelay * 1000));
|
|
|
|
|
}
|
2020-05-21 12:21:22 +08:00
|
|
|
|
|
2020-05-19 22:34:09 +08:00
|
|
|
|
await base.Hide(force);
|
|
|
|
|
}
|
2020-05-21 12:21:22 +08:00
|
|
|
|
|
2021-01-21 17:20:10 +08:00
|
|
|
|
internal async Task ChildElementMoved() =>await GetOverlayComponent().UpdatePosition();
|
|
|
|
|
|
2020-05-19 22:34:09 +08:00
|
|
|
|
}
|
|
|
|
|
}
|