Skip to content
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

feat(tabs): add automatic scrolling when holding down paginator #14632

Merged
merged 1 commit into from
Jan 23, 2019

Conversation

crisbeto
Copy link
Member

Adds some code that automatically keeps scrolling the tab header while holding down one of the paginator buttons. This is useful on long lists of tabs where the user might have to click a lot to reach the tab that they want.

Fixes #6510.

@crisbeto crisbeto added the target: minor This PR is targeted for the next minor release label Dec 25, 2018
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Dec 25, 2018
(click)="_scrollHeader('before')">
(click)="_handlePaginatorClick('before')"
(mousedown)="_handlePaginatorPress('before')"
(touchend)="_stopInterval()">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the mix of mousedown and touchend?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The touchend is there to clear the interval in case the mousedown doesn't fire since it behaves closer to a click on touch devices.

@@ -230,9 +271,25 @@ export class MatTabHeader extends _MatTabHeaderMixinBase
});
}

ngAfterViewInit() {
// We need to handle these events manually, because we want to bind passive event listeners.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expand the comment like

// Register event handlers for scrolling tabs while holding down the pagination buttons.
// We register these events manually because we want to bind *passive* event listeners.

@@ -469,4 +529,49 @@ export class MatTabHeader extends _MatTabHeaderMixinBase

this._inkBar.alignToElement(selectedLabelWrapper!);
}

/** Stops the currently-running paginator interval. */
_stopInterval() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_stopPaginationScrollInterval?

@crisbeto crisbeto force-pushed the 6510/tabs-auto-scroll branch 2 times, most recently from ff70154 to 9450e37 Compare January 10, 2019 20:24
@crisbeto
Copy link
Member Author

I've addressed the feedback @jelbourn.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Jan 11, 2019
@ngbot
Copy link

ngbot bot commented Jan 15, 2019

Hi @crisbeto! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@crisbeto crisbeto force-pushed the 6510/tabs-auto-scroll branch from 9450e37 to 0e795e8 Compare January 19, 2019 15:54
@andrewseguin
Copy link
Contributor

@crisbeto Looks like the API golden check failed - can you update the API

Adds some code that automatically keeps scrolling the tab header while holding down one of the paginator buttons. This is useful on long lists of tabs where the user might have to click a lot to reach the tab that they want.

Fixes angular#6510.
@crisbeto crisbeto force-pushed the 6510/tabs-auto-scroll branch from 0e795e8 to 8cf20da Compare January 23, 2019 19:27
@crisbeto
Copy link
Member Author

Updated the goldens.

@andrewseguin andrewseguin merged commit e661317 into angular:master Jan 23, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tabs] Long-click on pagination arrows should continue scrolling
4 participants