Skip to content

feat(segment-view): adds support for new ion-segment-view component #29969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
bc2fb37
fix(segment): animate the highlight with value changes
brandyscarney Sep 17, 2024
6833092
feat(segment): add segment view and content components
brandyscarney Sep 17, 2024
bf3a503
style: lint
brandyscarney Sep 17, 2024
2ddfab7
refactor(segment): link the button and content with content-id and id
brandyscarney Sep 18, 2024
4e48562
refactor(segment): remove uneccessary function
brandyscarney Sep 18, 2024
4e9c3ec
feat(segment-view): support disabled
brandyscarney Sep 19, 2024
e5323bd
fix(segment): only call updateSegmentView when gesture ends or button…
brandyscarney Sep 23, 2024
97c486b
fix(segment): set the view to the initial value without scrolling
brandyscarney Sep 23, 2024
d46b3bf
test(segment-view): add a test for the proper content being displayed
brandyscarney Sep 23, 2024
370a57a
style: lint
brandyscarney Sep 23, 2024
d60d54b
docs(segment-view): document setContent method and add example
brandyscarney Sep 23, 2024
4bb4a8c
test(segment-view): fix test
brandyscarney Sep 23, 2024
8b4fa83
test(segment-view): update function for clearing segment value
brandyscarney Sep 23, 2024
4b27738
feat(segment-content): add disabled prop and hide the content
brandyscarney Sep 23, 2024
0ecf886
test(segment-view): split out disabled segment view / content test
brandyscarney Sep 23, 2024
a76477c
fix(segment-view): split opacity by mode vars to match segment
brandyscarney Sep 23, 2024
6da1cdd
fix(segment-view): don't query for disabled contents
brandyscarney Sep 23, 2024
8e17797
test(segment-view): remove toolbars
brandyscarney Sep 24, 2024
1c3f7ab
test(segment-view): add tests for disabled content scrolling
brandyscarney Sep 24, 2024
e68f55f
chore(): add updated snapshots
brandyscarney Sep 24, 2024
6aa694b
test: remove only
brandyscarney Sep 24, 2024
6d24224
feat(segment): move indicator with scroll
brandyscarney Sep 24, 2024
3d53f71
fix(segment): properly move the indicator when direction starts out o…
brandyscarney Sep 24, 2024
10acd9e
style: lint
brandyscarney Sep 24, 2024
7b83b45
fix(segment-view): allow moving the indicator left on scroll without …
brandyscarney Sep 25, 2024
510ae39
fix(segment-view): always check the scrollLeft against the initial to…
brandyscarney Sep 25, 2024
c8b765a
fix(segment): properly bound indicator transform for more than 2 cont…
brandyscarney Sep 25, 2024
3e66a38
fix(segment): move indicator as a percentage of the width on scroll
brandyscarney Sep 25, 2024
b751f04
fix(segment): clear transform styles on scroll end
Sep 27, 2024
f81a613
fix(segment): handle change of direction scrolling
Sep 27, 2024
0a7f4ba
fix(segment): don't trigger scroll listener on segment button click
Sep 29, 2024
6635c84
fix(segment): only handle events for correct instance
Sep 29, 2024
43845c2
fix(segment): scroll segment button into view if appropriate
Sep 29, 2024
1fbddf8
chore: build
brandyscarney Sep 30, 2024
2069f7e
style: naming
brandyscarney Sep 30, 2024
a91a5a4
refactor(segment-content): use opacity for disabled content
brandyscarney Oct 1, 2024
35337ed
test(segment-view): remove not disabled styles
brandyscarney Oct 2, 2024
b58f9a7
fix(segment): update segment view to scroll past disabled content
brandyscarney Oct 8, 2024
a9adb82
fix(segment): update segment content to disabled when button is
brandyscarney Oct 9, 2024
9494d43
fix(segment-view): continue to search through segment contents for en…
brandyscarney Oct 10, 2024
f74f154
feat(segment, segment-view): remove percentage based indicator effect…
tanner-reits Oct 25, 2024
ef5bdc7
fix: PR feedback
Oct 29, 2024
2e484c0
fix(): more PR feedback
Oct 30, 2024
f5e910a
fix: regenerate api & proxies
Oct 30, 2024
ab5d4e5
refactor(segment-content): remove mode specific files
brandyscarney Oct 30, 2024
8429322
fix(segment-button): revert disabled reflection
Oct 31, 2024
f6376e8
Merge remote-tracking branch 'origin/feature-8.4' into ROU-10971
Oct 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(segment-view): always check the scrollLeft against the initial to…
… get scrollDistance
  • Loading branch information
brandyscarney authored and tanner-reits committed Oct 25, 2024
commit 510ae395c88d6fe98b3c1ab92bebd132f33d19d1
6 changes: 3 additions & 3 deletions core/src/components/segment-view/segment-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export class SegmentView implements ComponentInterface {
this.initialScrollLeft = scrollLeft;
}

// Determine the scroll direction based on the previous scroll position
const scrollDirection = scrollLeft > previousScrollLeft ? 'right' : 'left';
this.previousScrollLeft = scrollLeft;

// If the scroll direction is left then we need to calculate where we started and subtract
// the current scrollLeft to get the distance scrolled. Otherwise, we use the scrollLeft.
const scrollDistance = scrollDirection === 'left' ? initialScrollLeft! - scrollLeft : scrollLeft;
// Calculate the distance scrolled based on the initial scroll position
const scrollDistance = scrollLeft - initialScrollLeft!;

// Emit the scroll direction and distance
this.ionSegmentViewScroll.emit({
Expand Down
5 changes: 1 addition & 4 deletions core/src/components/segment/segment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,12 @@ export class Segment implements ComponentInterface {
const segmentRect = segmentEl.getBoundingClientRect();
const buttonRect = current.getBoundingClientRect();

// Calculate the potential transform value based on scroll direction
const transformValue = scrollDirection === 'left' ? -scrollDistance : scrollDistance;

// Calculate the max and min allowed transformations based on the scroll direction
const maxTransform = scrollDirection === 'left' ? 0 : segmentRect.width - buttonRect.width;
const minTransform = scrollDirection === 'left' ? -(segmentRect.width - buttonRect.width) : 0;

// Clamp the transform value to ensure it doesn't go out of bounds
const clampedTransform = Math.max(minTransform, Math.min(transformValue, maxTransform));
const clampedTransform = Math.max(minTransform, Math.min(scrollDistance, maxTransform));

// Apply the clamped transform value to the indicator element
const transform = `translate3d(${clampedTransform}px, 0, 0)`;
Expand Down