@@ -35,6 +35,7 @@ internal partial class SfHorizontalContent : SfTabViewExt, ITouchListener, ITapG
35
35
bool _isPreviousItemVisible ;
36
36
bool _isNextItemVisible ;
37
37
SelectionChangingEventArgs ? _selectionChangingEventArgs ;
38
+ bool _isSelectionProcessed ;
38
39
#if WINDOWS
39
40
bool _isItemRemoved ;
40
41
#endif
@@ -246,16 +247,14 @@ protected override Microsoft.Maui.Graphics.Size ArrangeContent(Microsoft.Maui.Gr
246
247
/// <returns>It returns the size</returns>
247
248
protected override Size MeasureContent ( double widthConstraint , double heightConstraint )
248
249
{
249
- if ( widthConstraint > 0 && widthConstraint != double . PositiveInfinity && MinimumWidthRequest != widthConstraint )
250
+ if ( widthConstraint > 0 && widthConstraint != double . PositiveInfinity )
250
251
{
251
- MinimumWidthRequest = widthConstraint ;
252
252
ContentWidth = widthConstraint ;
253
253
UpdateTabItemContentSize ( ) ;
254
254
UpdateTabItemContentPosition ( ) ;
255
255
}
256
- if ( heightConstraint > 0 && heightConstraint != double . PositiveInfinity && MinimumHeightRequest != heightConstraint )
256
+ if ( heightConstraint > 0 && heightConstraint != double . PositiveInfinity )
257
257
{
258
- MinimumHeightRequest = heightConstraint ;
259
258
UpdateTabItemContentSize ( ) ;
260
259
UpdateTabItemContentPosition ( ) ;
261
260
}
@@ -373,6 +372,7 @@ void ClearTabContent(SfTabItem tabItem, int index)
373
372
374
373
void UpdateSelectedIndex ( )
375
374
{
375
+ _isSelectionProcessed = true ;
376
376
UpdateTabItemContentPosition ( ) ;
377
377
}
378
378
@@ -576,12 +576,30 @@ void UpdateTabItemContentPositionWithTemplate()
576
576
{
577
577
xPosition = ContentWidth * SelectedIndex ;
578
578
#if WINDOWS
579
- _horizontalStackLayout ? . TranslateTo ( - xPosition , 0 , ( uint ) ContentTransitionDuration , Easing . Linear ) ;
580
- #else
581
- if ( ( ( this as IVisualElementController ) . EffectiveFlowDirection & EffectiveFlowDirection . RightToLeft ) != EffectiveFlowDirection . RightToLeft )
579
+ if ( _isSelectionProcessed )
580
+ {
582
581
_horizontalStackLayout ? . TranslateTo ( - xPosition , 0 , ( uint ) ContentTransitionDuration , Easing . Linear ) ;
582
+ _isSelectionProcessed = false ;
583
+ }
583
584
else
584
- _horizontalStackLayout ? . TranslateTo ( xPosition , 0 , ( uint ) ContentTransitionDuration , Easing . Linear ) ;
585
+ {
586
+ if ( _horizontalStackLayout is not null )
587
+ {
588
+ _horizontalStackLayout . TranslationX = - xPosition ;
589
+ }
590
+ }
591
+ #else
592
+ double targetX = ( ( this as IVisualElementController ) . EffectiveFlowDirection & EffectiveFlowDirection . RightToLeft ) is not EffectiveFlowDirection . RightToLeft ? - xPosition : xPosition ;
593
+ if ( _isSelectionProcessed )
594
+ {
595
+ _horizontalStackLayout ? . TranslateTo ( targetX , 0 , ( uint ) ContentTransitionDuration , Easing . Linear ) ;
596
+ _isSelectionProcessed = false ;
597
+ }
598
+ else
599
+ {
600
+ if ( _horizontalStackLayout is not null )
601
+ _horizontalStackLayout . TranslationX = targetX ;
602
+ }
585
603
#endif
586
604
}
587
605
}
@@ -601,13 +619,31 @@ void UpdateTabItemContentPositionWithoutTemplate()
601
619
}
602
620
else
603
621
{
604
- _horizontalStackLayout ? . TranslateTo ( - xPosition , 0 , ( uint ) ContentTransitionDuration , Easing . Linear ) ;
622
+ if ( _isSelectionProcessed )
623
+ {
624
+ _horizontalStackLayout ? . TranslateTo ( - xPosition , 0 , ( uint ) ContentTransitionDuration , Easing . Linear ) ;
625
+ _isSelectionProcessed = false ;
626
+ }
627
+ else
628
+ {
629
+ if ( _horizontalStackLayout is not null )
630
+ {
631
+ _horizontalStackLayout . TranslationX = - xPosition ;
632
+ }
633
+ }
605
634
}
606
635
#else
607
- if ( ( ( this as IVisualElementController ) . EffectiveFlowDirection & EffectiveFlowDirection . RightToLeft ) != EffectiveFlowDirection . RightToLeft )
608
- _horizontalStackLayout ? . TranslateTo ( - xPosition , 0 , ( uint ) ContentTransitionDuration , Easing . Linear ) ;
636
+ double targetX = ( ( this as IVisualElementController ) . EffectiveFlowDirection & EffectiveFlowDirection . RightToLeft ) is not EffectiveFlowDirection . RightToLeft ? - xPosition : xPosition ;
637
+ if ( _isSelectionProcessed )
638
+ {
639
+ _horizontalStackLayout ? . TranslateTo ( targetX , 0 , ( uint ) ContentTransitionDuration , Easing . Linear ) ;
640
+ _isSelectionProcessed = false ;
641
+ }
609
642
else
610
- _horizontalStackLayout ? . TranslateTo ( xPosition , 0 , ( uint ) ContentTransitionDuration , Easing . Linear ) ;
643
+ {
644
+ if ( _horizontalStackLayout is not null )
645
+ _horizontalStackLayout . TranslationX = targetX ;
646
+ }
611
647
#endif
612
648
}
613
649
0 commit comments