Skip to content

Commit 57290ec

Browse files
committed
fix swipes
1 parent df76a67 commit 57290ec

File tree

2 files changed

+35
-13
lines changed

2 files changed

+35
-13
lines changed

src/BlazorUI/Bit.BlazorUI/Scripts/Swipes.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122

123123
if (touchOnScrollContainer) {
124124
const isScrollAtLeft = Math.abs(scrollContainer!.scrollLeft) <= 2;
125-
const isScrollAtRight = scrollContainer!.scrollLeft + scrollContainer!.clientWidth >= (scrollContainer!.scrollWidth - 2);
125+
const isScrollAtRight = Math.abs(scrollContainer!.scrollLeft) + scrollContainer!.clientWidth >= (scrollContainer!.scrollWidth - 2);
126126

127127
if (diffX < 0 && (isRtl ? isScrollAtRight : isScrollAtLeft)) return;
128128
if (diffX > 0 && (isRtl ? isScrollAtLeft : isScrollAtRight)) return;
@@ -186,13 +186,11 @@
186186
scrollContainer.addEventListener('touchstart', e => {
187187
touchOnScrollContainer = true;
188188

189-
console.log(scrollContainer.scrollLeft, scrollContainer.scrollWidth, scrollContainer.clientWidth);
190-
191-
//const edge = (isRtl && position === BitSwipePosition.Start || !isRtl && position === BitSwipePosition.End) ? Math.abs(scrollContainer.scrollLeft)
192-
// : (isRtl && position === BitSwipePosition.Start || !isRtl && position === BitSwipePosition.End) ? Math.abs(scrollContainer.scrollLeft)
193-
// : 0;
189+
const isScrollAtLeft = Math.abs(scrollContainer!.scrollLeft) <= 2;
190+
const isScrollAtRight = Math.abs(scrollContainer!.scrollLeft) + scrollContainer!.clientWidth >= (scrollContainer!.scrollWidth - 2);
194191

195-
//if (edge <= 2) return;
192+
if ((isRtl && position === BitSwipePosition.End) || (!isRtl && position === BitSwipePosition.End)) { if (isScrollAtLeft) return; }
193+
if ((isRtl && position === BitSwipePosition.Start) || (!isRtl && position === BitSwipePosition.Start)) { if (isScrollAtRight) return; }
196194

197195
e.stopPropagation();
198196
});

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Navs/DropMenu/BitDropMenuDemo.razor

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,23 @@
5353

5454
<DemoExample Title="Responsive" RazorCode="@example3RazorCode" Id="example3">
5555
<div>Rendering the callout in responsive mode on small screens.</div><br />
56-
<BitDropMenu Text="Responsive" Responsive ScrollContainerId="sc-con" PanelPosition="BitPanelPosition.Start">
57-
<div style="max-width:200px;overflow:auto" id="sc-con">
58-
<BitStack Gap="1rem" Style="padding:0.5rem">
56+
57+
<BitDropMenu Text="Responsive" Responsive ScrollContainerId="sc-con1" PanelPosition="BitPanelPosition.End">
58+
<div style="max-width:200px;overflow:auto" id="sc-con1">
59+
<BitStack FitWidth Gap="1rem" Style="padding:0.5rem">
60+
<BitText Typography="BitTypography.Subtitle1" NoWrap>This is the content This is the content This is the content</BitText>
61+
<BitText Typography="BitTypography.Subtitle1" NoWrap>This is the content</BitText>
62+
<BitText Typography="BitTypography.Subtitle1" NoWrap>This is the content</BitText>
63+
<BitText Typography="BitTypography.Subtitle1" NoWrap>This is the content</BitText>
64+
</BitStack>
65+
</div>
66+
</BitDropMenu>
67+
68+
<br /><br />
69+
70+
<BitDropMenu Text="Responsive" Responsive ScrollContainerId="sc-con2" PanelPosition="BitPanelPosition.Start">
71+
<div style="max-width:200px;overflow:auto" id="sc-con2">
72+
<BitStack FitWidth Gap="1rem" Style="padding:0.5rem">
5973
<BitText Typography="BitTypography.Subtitle1" NoWrap>This is the content This is the content This is the content</BitText>
6074
<BitText Typography="BitTypography.Subtitle1" NoWrap>This is the content</BitText>
6175
<BitText Typography="BitTypography.Subtitle1" NoWrap>This is the content</BitText>
@@ -142,15 +156,25 @@
142156
</BitStack>
143157
</BitDropMenu>
144158
<br />
145-
@* <BitDropMenu Text="ریسپانسیو منو" Dir="BitDir.Rtl" Responsive ScrollContainerId="sc-con-rtl">
146-
<div style="max-width:200px;overflow:auto" id="sc-con-rtl">
159+
<BitDropMenu Text="ریسپانسیو منو" Dir="BitDir.Rtl" Responsive ScrollContainerId="sc-con-rtl1">
160+
<div style="max-width:200px;overflow:auto" id="sc-con-rtl1">
161+
<BitStack Gap="1rem" Style="padding:0.5rem">
162+
<BitText Typography="BitTypography.Subtitle1" NoWrap>این یک محتوای تستی می باشد این یک محتوای تستی می باشد این یک محتوای تستی می باشد</BitText>
163+
<BitText Typography="BitTypography.Subtitle1" NoWrap>این یک محتوای تستی می باشد</BitText>
164+
<BitText Typography="BitTypography.Subtitle1" NoWrap>این یک محتوای تستی می باشد</BitText>
165+
</BitStack>
166+
</div>
167+
</BitDropMenu>
168+
<br />
169+
<BitDropMenu Text="ریسپانسیو منو" Dir="BitDir.Rtl" Responsive ScrollContainerId="sc-con-rtl2" PanelPosition="BitPanelPosition.Start">
170+
<div style="max-width:200px;overflow:auto" id="sc-con-rtl2">
147171
<BitStack Gap="1rem" Style="padding:0.5rem">
148172
<BitText Typography="BitTypography.Subtitle1" NoWrap>این یک محتوای تستی می باشد این یک محتوای تستی می باشد این یک محتوای تستی می باشد</BitText>
149173
<BitText Typography="BitTypography.Subtitle1" NoWrap>این یک محتوای تستی می باشد</BitText>
150174
<BitText Typography="BitTypography.Subtitle1" NoWrap>این یک محتوای تستی می باشد</BitText>
151175
</BitStack>
152176
</div>
153-
</BitDropMenu> *@
177+
</BitDropMenu>
154178
</div>
155179
</DemoExample>
156180
</DemoPage>

0 commit comments

Comments
 (0)