Skip to content

Commit ebaed60

Browse files
authored
[dev-v5] MultiSplitter - Add the Touch mode (#4358)
* Update the Splitter to use Touch screens * Update Tests frameworks
1 parent 42efc9a commit ebaed60

File tree

6 files changed

+32
-6
lines changed

6 files changed

+32
-6
lines changed

examples/Demo/FluentUI.Demo/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"https": {
55
"commandName": "Project",
66
"dotnetRunMessages": true,
7-
"launchBrowser": true,
7+
"launchBrowser": false,
88
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
99
"applicationUrl": "https://localhost:7197;http://localhost:5219",
1010
"environmentVariables": {

src/Core.Scripts/src/Components/Splitter/FluentMultiSplitter.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,16 @@ export namespace Microsoft.FluentUI.Blazor.Components.MultiSplitter {
173173
},
174174

175175
touchMoveHandler: (e: TouchEvent) => {
176+
if (e.touches.length < 1) {
177+
return;
178+
}
179+
180+
if (e.cancelable) {
181+
e.preventDefault(); // Prevent scrolling while dragging
182+
}
183+
176184
const splitteDataElement = ((document as any).splitter as SplitterData)?.Data.get(el);
177-
const touch = e.changedTouches[0]
185+
const touch = e.touches[0]
178186

179187
const eventArgs = new MouseEvent("mouseup", {
180188
bubbles: true,
@@ -198,8 +206,8 @@ export namespace Microsoft.FluentUI.Blazor.Components.MultiSplitter {
198206
if (splitterDataElement) {
199207
document.addEventListener('mousemove', splitterDataElement.mouseMoveHandler);
200208
document.addEventListener('mouseup', splitterDataElement.mouseUpHandler);
201-
document.addEventListener('touchmove', splitterDataElement.touchMoveHandler, { passive: true });
202-
document.addEventListener('touchend', splitterDataElement.mouseUpHandler, { passive: true });
209+
document.addEventListener('touchmove', splitterDataElement.touchMoveHandler, { passive: false });
210+
document.addEventListener('touchend', splitterDataElement.mouseUpHandler, { passive: false });
203211
}
204212
}
205213

src/Core/Components/Splitter/FluentMultiSplitter.razor.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,23 @@ internal async Task ExpandExecAsync(int paneIndex)
295295
StateHasChanged();
296296
}
297297

298+
/// <summary />
299+
internal Task ResizeExecAsync(TouchEventArgs args, int paneIndex)
300+
{
301+
if (args.Touches.Length < 1)
302+
{
303+
return Task.CompletedTask;
304+
}
305+
306+
var mouseArgs = new MouseEventArgs
307+
{
308+
ClientX = args.Touches[0].ClientX,
309+
ClientY = args.Touches[0].ClientY,
310+
};
311+
312+
return ResizeExecAsync(mouseArgs, paneIndex);
313+
}
314+
298315
/// <summary />
299316
internal async Task ResizeExecAsync(MouseEventArgs args, int paneIndex)
300317
{

src/Core/Components/Splitter/FluentMultiSplitterPane.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<div class="fluent-multi-splitter-bar"
1717
status="@GetClassStatus()"
1818
@onmousedown="@(e => Splitter?.ResizeExecAsync(e, Index) ?? Task.CompletedTask)"
19+
@ontouchstart="@(e => Splitter?.ResizeExecAsync(e, Index) ?? Task.CompletedTask)"
1920
@onclick:preventDefault="true"
2021
@onclick:stopPropagation="true">
2122

tests/Core/Components.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<TargetFramework>net10.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<OutputType>Exe</OutputType>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>

tests/Integration/Components.IntegrationTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net10.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<OutputType>Exe</OutputType>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>

0 commit comments

Comments
 (0)