-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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(top-app-bar): add default scroll behavior #2417
Changes from 12 commits
3f3a9f9
1d8113f
3f325ec
9783de2
283352d
7fd0ad9
18c8dda
6a97eac
3fb07bc
236eb64
4de6af2
9f51fb5
4b9ce43
6544484
f7d3a46
e0004c0
92a0718
fb858df
e2288ab
b6fd60c
c66923c
d2ef63d
8ce12e9
1e04327
8f5327f
ce71bba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,19 @@ class MDCTopAppBarAdapter { | |
*/ | ||
hasClass(className) {} | ||
|
||
/** | ||
* Adds the specified attribute and value to the root Element. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Update comment to something like:
|
||
* @param {string} attribute | ||
* @param {string} value | ||
*/ | ||
setStyle(attribute, value) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Rename |
||
|
||
/** | ||
* Gets the height of the top app bar. | ||
* @return {number} | ||
*/ | ||
getTopAppBarHeight() {} | ||
|
||
/** | ||
* Registers an event handler on the navigation icon element for a given event. | ||
* @param {string} type | ||
|
@@ -72,6 +85,12 @@ class MDCTopAppBarAdapter { | |
/** @param {function(!Event)} handler */ | ||
deregisterScrollHandler(handler) {} | ||
|
||
/** @param {function(!Event)} handler */ | ||
registerResizeHandler(handler) {} | ||
|
||
/** @param {function(!Event)} handler */ | ||
deregisterResizeHandler(handler) {} | ||
|
||
/** @return {number} */ | ||
getViewportScrollY() {} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,10 @@ const cssClasses = { | |
SHORT_COLLAPSED_CLASS: 'mdc-top-app-bar--short-collapsed', | ||
}; | ||
|
||
export {strings, cssClasses}; | ||
/** @enum {number} */ | ||
const numbers = { | ||
MAX_TOP_APP_BAR_HEIGHT: 128, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. swap these for alpha order |
||
DEBOUNCE_THROTTLE_RESIZE_TIME: 100, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For time values stored as integers, it's usually a good idea to include the unit of measurement in the variable name. E.g., |
||
}; | ||
|
||
export {strings, cssClasses, numbers}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,14 +15,14 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
import {strings, cssClasses} from './constants'; | ||
import {strings, cssClasses, numbers} from './constants'; | ||
import MDCTopAppBarAdapter from './adapter'; | ||
import MDCFoundation from '@material/base/foundation'; | ||
|
||
/** | ||
* @extends {MDCFoundation<!MDCTopAppBarAdapter>} | ||
*/ | ||
class MDCTopAppBarFoundation extends MDCFoundation { | ||
class MDCTopAppBarBaseFoundation extends MDCFoundation { | ||
/** @return enum {string} */ | ||
static get strings() { | ||
return strings; | ||
|
@@ -33,6 +33,11 @@ class MDCTopAppBarFoundation extends MDCFoundation { | |
return cssClasses; | ||
} | ||
|
||
/** @return enum {number} */ | ||
static get numbers() { | ||
return numbers; | ||
} | ||
|
||
/** | ||
* {@see MDCTopAppBarAdapter} for typing information on parameters and return | ||
* types. | ||
|
@@ -43,11 +48,15 @@ class MDCTopAppBarFoundation extends MDCFoundation { | |
hasClass: (/* className: string */) => {}, | ||
addClass: (/* className: string */) => {}, | ||
removeClass: (/* className: string */) => {}, | ||
setStyle: (/* attribute: string, value: string */) => {}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Rename |
||
getTopAppBarHeight: () => {}, | ||
registerNavigationIconInteractionHandler: (/* type: string, handler: EventListener */) => {}, | ||
deregisterNavigationIconInteractionHandler: (/* type: string, handler: EventListener */) => {}, | ||
notifyNavigationIconClicked: () => {}, | ||
registerScrollHandler: (/* handler: EventListener */) => {}, | ||
deregisterScrollHandler: (/* handler: EventListener */) => {}, | ||
registerResizeHandler: (/* handler: EventListener */) => {}, | ||
deregisterResizeHandler: (/* handler: EventListener */) => {}, | ||
getViewportScrollY: () => /* number */ 0, | ||
getTotalActionItems: () => /* number */ 0, | ||
}); | ||
|
@@ -56,8 +65,8 @@ class MDCTopAppBarFoundation extends MDCFoundation { | |
/** | ||
* @param {!MDCTopAppBarAdapter} adapter | ||
*/ | ||
constructor(adapter) { | ||
super(Object.assign(MDCTopAppBarFoundation.defaultAdapter, adapter)); | ||
constructor(/** @type {!MDCTopAppBarAdapter} */ adapter) { | ||
super(Object.assign(MDCTopAppBarBaseFoundation.defaultAdapter, adapter)); | ||
|
||
this.navClickHandler_ = () => this.adapter_.notifyNavigationIconClicked(); | ||
} | ||
|
@@ -71,4 +80,4 @@ class MDCTopAppBarFoundation extends MDCFoundation { | |
} | ||
} | ||
|
||
export default MDCTopAppBarFoundation; | ||
export default MDCTopAppBarBaseFoundation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be a good case for a
layout
method or something to reset the scrolling? I can't think of a use case outside of the demo pages for it though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only required for the demo page since we're showcasing several different toolbars on a single page.