Skip to content

Commit

Permalink
[PullToRefresh] Add DragThreshold
Browse files Browse the repository at this point in the history
* #1845: Add DragThreshold to PullToRefresh

* fix Whitespace noise + Default value

---------

Co-authored-by: Vincent Baaij <[email protected]>
  • Loading branch information
f4n0 and vnbaaij authored Apr 16, 2024
1 parent 9a7353e commit 6dd43e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6744,6 +6744,11 @@
Default is 750
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentPullToRefresh.DragThreshold">
<summary>
Gets or sets the threshold distance the <see cref="P:Microsoft.FluentUI.AspNetCore.Components.FluentPullToRefresh.ChildContent"/> needs to be pulled (in pixels) to start the tip pull action.
</summary>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentPullToRefresh.OnAfterRenderAsync(System.Boolean)">
<summary />
</member>
Expand Down
13 changes: 10 additions & 3 deletions src/Core/Components/PullToRefresh/FluentPullToRefresh.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ public partial class FluentPullToRefresh : FluentComponentBase
[Parameter]
public int StatusUpdateMessageTimeout { get; set; } = 750;

/// <summary>
/// Gets or sets the threshold distance the <see cref="ChildContent"/> needs to be pulled (in pixels) to start the tip pull action.
/// </summary>
[Parameter]
public int DragThreshold { get; set; } = 0;

protected override void OnInitialized()
{
_originalShowStaticTip = _internalShowStaticTip = ShowStaticTip;
Expand Down Expand Up @@ -207,7 +213,6 @@ private async Task OnTouchMoveAsync(TouchEventArgs e)
{
if (Disabled) { return; }

_internalShowStaticTip = true;
if (_pullStatus == PullStatus.Pulling || _pullStatus == PullStatus.WaitingForRelease)
{
if (Direction == PullDirection.Down)
Expand All @@ -232,21 +237,23 @@ private async Task OnTouchMoveDownAsync(TouchEventArgs e)
return;
}

var move = e.TargetTouches[0].ClientY - _startY;
var move = e.TargetTouches[0].ClientY - (_startY + DragThreshold);

if (move > 0)
{
_internalShowStaticTip = true;
SetDistance(CalcMoveDistance(move));
}
}
}

private Task OnTouchMoveUpAsync(TouchEventArgs e)
{
var move = _startY - e.TargetTouches[0].ClientY;
var move = _startY - (e.TargetTouches[0].ClientY + DragThreshold);

if (move > 0)
{
_internalShowStaticTip = true;
SetDistance(CalcMoveDistance(move));
}
return Task.CompletedTask;
Expand Down

0 comments on commit 6dd43e1

Please sign in to comment.