Investigate adding flexible variant to mdc-top-app-bar
Our existing mdc-toolbar component has a flexible variant (changes the height as the user scrolls). However this functionality was never specified in the material design guidelines. Given that people in the community want this flexible feature, we think we should add it to the new mdc-top-app-bar component...but we need to first work with our designers to specify this flexible feature in the material design guidelines.
If you want to influence the specifications of this flexible variant of mdc-top-app-bar, please leave comments on this thread about how you would like to use this feature in your website.
Yes! A "fixed last row" feature would be nice. It's not that hard to do it on the developer side, but it would be a small and useful addition that would simplify devs' work. I personally use it to show a welcoming title then for content that should always be at the top, on scroll. Please check #3945 for future reference.
This what I've done:
var topAppBar = document.querySelector('.mdc-top-app-bar');
var calculatedPeekHeight = topAppBar.clientHeight - document.querySelector('.mdc-top-app-bar .mdc-top-app-bar__row:last-of-type').clientHeight;
window.onscroll = function() {
var peekHeight = Math.min(scrollY, calculatedPeekHeight);
document.querySelector(".mdc-top-app-bar").style.transform = 'translateY(' + peekHeight * -1 + 'px)';
}
calculatedPeekHeightis the (height of the top app bar) - (height of the last/fixed row): for instance 56pxpeekHeightis the scroll value, at max 56px- apply those two variables to the top app bar on scroll
I hope this small piece of code will be useful :smiley:
We have used the mdc-toolbar mdc-toolbar--fixed mdc-toolbar--waterfall mdc-toolbar--flexible mdc-toolbar--flexible-default-behavior classes. The behavior is found on: material.io/design/components/app-bars-top.html#behavior
We would like to remain this look and feel when using the new mdc-top-app-bar component.
Something new on the mdc-top-app-bar with scrollable prominent header? The header is scrolling outside the window in the current implementation. As @kvdheuvel mentioned, the docs keeps the prominent app-bar in window all the time. mdc-toolbar had that feature enabled.