File tree Expand file tree Collapse file tree 2 files changed +4
-7
lines changed Expand file tree Collapse file tree 2 files changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -41,12 +41,12 @@ export class SegmentView implements ComponentInterface {
4141 this . initialScrollLeft = scrollLeft ;
4242 }
4343
44+ // Determine the scroll direction based on the previous scroll position
4445 const scrollDirection = scrollLeft > previousScrollLeft ? 'right' : 'left' ;
4546 this . previousScrollLeft = scrollLeft ;
4647
47- // If the scroll direction is left then we need to calculate where we started and subtract
48- // the current scrollLeft to get the distance scrolled. Otherwise, we use the scrollLeft.
49- const scrollDistance = scrollDirection === 'left' ? initialScrollLeft ! - scrollLeft : scrollLeft ;
48+ // Calculate the distance scrolled based on the initial scroll position
49+ const scrollDistance = scrollLeft - initialScrollLeft ! ;
5050
5151 // Emit the scroll direction and distance
5252 this . ionSegmentViewScroll . emit ( {
Original file line number Diff line number Diff line change @@ -369,15 +369,12 @@ export class Segment implements ComponentInterface {
369369 const segmentRect = segmentEl . getBoundingClientRect ( ) ;
370370 const buttonRect = current . getBoundingClientRect ( ) ;
371371
372- // Calculate the potential transform value based on scroll direction
373- const transformValue = scrollDirection === 'left' ? - scrollDistance : scrollDistance ;
374-
375372 // Calculate the max and min allowed transformations based on the scroll direction
376373 const maxTransform = scrollDirection === 'left' ? 0 : segmentRect . width - buttonRect . width ;
377374 const minTransform = scrollDirection === 'left' ? - ( segmentRect . width - buttonRect . width ) : 0 ;
378375
379376 // Clamp the transform value to ensure it doesn't go out of bounds
380- const clampedTransform = Math . max ( minTransform , Math . min ( transformValue , maxTransform ) ) ;
377+ const clampedTransform = Math . max ( minTransform , Math . min ( scrollDistance , maxTransform ) ) ;
381378
382379 // Apply the clamped transform value to the indicator element
383380 const transform = `translate3d(${ clampedTransform } px, 0, 0)` ;
You can’t perform that action at this time.
0 commit comments