material icon indicating copy to clipboard operation
material copied to clipboard

md-button class="md-fab" don't change position with scroll

Open truyet opened this issue 12 years ago • 7 comments

I'm create tag . Position of button is right bottom. Page scroll down but button don't change position

truyet avatar Nov 21 '14 13:11 truyet

Hi I was just about to log an issue/ question with the "opposite" problem

I have issues where my fabs scroll when I do not expect them to. After some testing I see that fabs scroll when they are embedded inside md-content-tags (that scroll). However if I move the fab outside the md-content I do not see scrolli

I have created a plunker that demonstrates my issue. I was expecting all four fabs to stay put : http://plnkr.co/edit/v9mzICm4Lip2C1xxtvl3?p=preview

hkgrani avatar Nov 21 '14 13:11 hkgrani

Hi hkgrani, You move the fab outside the md-content => your fab don't in md-content => why the outside fab is dragged while md-content scroll?

truyet avatar Nov 21 '14 14:11 truyet

@hkgrani: The buttons on the left are placed within the <md-content> and not under <body> (as is the case for the buttons on the right). Since <md-content> is a positioned element, the fabs are positioned relatie to it (instead of relative to the body).

Updated demo

gkalpak avatar Nov 21 '14 14:11 gkalpak

@gkalpak - yes you are correct. They were placed that way intentionally to show the different behaviour. I am just wondering if this is by design or if indeed all four buttons in the original plunker should stay fixed. My understanding of the spec is that fabs should not scroll.

Whan making own components/ directives it may make more sense to put the button inside the md-content (or maybe-not?)

hkgrani avatar Nov 21 '14 14:11 hkgrani

If you want your buttons to not scroll, I can't see how putting them inside a (scrollable) <md-content> makes sense. That said, I am not sure if fabs should have a fixed position.

My understanding of the spec is that fabs should not scroll.

I couldn't find anything related to fixed-vs-absolute position of fabs. What part of the spec are you referring to ?

gkalpak avatar Nov 21 '14 16:11 gkalpak

I could swear that the spec said that the FAB is usually position:fixed. I also can't find this at google's spec today, either. http://www.google.com/design/spec/components/buttons.html#buttons-floating-action-button

I don't really have an opinion on whether it should be fixed or not by default, but either way, we should have a decorator class that switches the behavior - md-fab.fab-unanchored, md-fab.fab-anchored

On Fri, Nov 21, 2014 at 10:06 AM, Georgios Kalpakas < [email protected]> wrote:

If you want your buttons to not scroll, I can't see how putting them inside a (scrollable) makes sense. That said, I am not sure if fabs should have a fixed position.

My understanding of the spec is that fabs should not scroll.

I couldn't find anything related to fixed-vs-absolute position of fabs. What part of the spec are you referring to ?

— Reply to this email directly or view it on GitHub https://github.com/angular/material/issues/720#issuecomment-63991900.

plato-cambrian avatar Nov 21 '14 17:11 plato-cambrian

You can anchor FABs to toolbars or structural elements, it seems like they should stay relative to their parents in those scenarios.

From the spec:

A floating action button can be placed according to the keyline spacing rules or attached to an extended app bar.

And:

A floating action button shouldn’t float in a random location.

See this screenshot from the Placement section: FAB Placement Do's

In the image, there is one FAB anchored to the baseline of the app and one anchored to an app bar. In my opinion, the first FAB should be fixed so it will be visible on page load even if sits over a long list. In the second scenario, it seems like it should stay anchored to its parent--and if the parent scrolls, so should the FAB.

So I think it depends on the context. You're definitely on the right track by referring to the design spec, so keep doing that!

marcysutton avatar Nov 21 '14 18:11 marcysutton