Skip to content

Custom Scrollbar API Review (#4073) - #4221

Merged
Diana Qu (dianaqu) merged 7 commits into
mainfrom
user/xiaqu/scrollbar-reviiew
Jan 18, 2024
Merged

Diana Qu (dianaqu) merged 7 commits into
mainfrom
user/xiaqu/scrollbar-reviiew

Conversation

@dianaqu

Copy link
Copy Markdown

Custom Scrollbar API review

* Custom scrollbar feature

* Update .net section

* Update doc

* Enum naming fix

Co-authored-by: David Risney <[email protected]>

* Update doc and naming

* Fix typo. Remove default style since user won't toggle it once style is set

* Still provide default value

* Update background section

Co-authored-by: David Risney <[email protected]>

* Update Naming

Co-authored-by: David Risney <[email protected]>

* Update .NET naming

Co-authored-by: David Risney <[email protected]>

* Update enum naming to exclude windows since its windows only feature/enum

* Update doc with link to fluent ui

* Update API naming

---------

Co-authored-by: Diana Qu <[email protected]>
Co-authored-by: David Risney <[email protected]>
@dianaqu Diana Qu (dianaqu) changed the title Custom Scrollbar API Draft Review (#4073) Custom Scrollbar API Review (#4073) Dec 9, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved with suggestions

Comment thread specs/CustomScrollbar.md Resolved
Comment thread specs/CustomScrollbar.md Resolved
Comment thread specs/CustomScrollbar.md Resolved
Comment thread specs/CustomScrollbar.md Resolved
Comment thread specs/CustomScrollbar.md Resolved
Comment thread specs/CustomScrollbar.md Resolved
Comment thread specs/CustomScrollbar.md Resolved

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please update per feedback. Thanks!

Comment thread specs/CustomScrollbar.md Resolved
Comment thread specs/CustomScrollbar.md Resolved
Comment thread specs/CustomScrollbar.md Resolved
Comment thread specs/CustomScrollbar.md Resolved
Comment thread specs/CustomScrollbar.md Resolved
Comment thread specs/CustomScrollbar.md Resolved
Comment thread specs/CustomScrollbar.md Resolved
Comment thread specs/CustomScrollbar.md Resolved
@softworkz

Copy link
Copy Markdown

I have a couple of questions and remarks on this proposal.

What is "FluentOverlay"?

As far as I know, there is no such thing like a "Fluent Background". Part of the Fluent design are two kinds of background "materials":

WinUI3 provides built-in support for using all three variants as backdrop material in an application.

So I wonder what the intended behavior of setting ScrollbarStyle.FluentOverlay would be - which of the materials is it supposed to resemble?

Light and Dark Styles?

An application may offer its own selection for light and dark style. It does not need to follow the system setting.
How will WebVierw2 "know" whether to use the light or dark version of the background material?

Window Position Dependency

This is more of a technical question regarding the implementation: The background material content is different on depending on the window position on screen. How is that supposed to be implemented, i.e. how will the WebView2 know its position relatiove to the desktop?

Or is it just about making scrollbars transparent (see my next post)? In that case, it should probably just named "TransparentOverlay" or similar.

@softworkz

softworkz commented Jan 20, 2024 •

Copy link
Copy Markdown

Transparent Scrollbars

I have already been able to achieve this effect with WebView2:

image

The ingredients for making it work like this:

  • WinUI3 application with Mica backdrop material
  • A custom hWnd-based WebView2 control
    (currently the only way to achieve a transparent WebView2 overlay - unfortunately)
  • Web content where html and body elements are transparent
  • Using the WebView2 from the Edge Dev channel (or anything >= 121)
  • Applying the new scrollbar-color CSS property
    (which is available in Chrome since 121)

This all works fine. IMO, there's much more value in being able to make (the original) scrollbars transparent and show the background that exists underneath than to have them use a fixed backdrop material which might not always be "the right" background.
Also, sometimes, you may want to blend some content over the Mica background and have the scrollbar rendered above that:

image

There's just a major flaw in the spec for scrollbar-color: It only lets you specify both, background and element color (for thumb and buttons), but often you do not know the right element color - you just want to make the background transparent.
The spec requires to supply both values like this (MDN):

.scroller {
  overflow-y: scroll;
  scrollbar-color: #007 transparent;
}

The first is the thumb color, the second is the background. The spec allow to specify scrollbar-color: auto; only, but not scrollbar-color: auto transparent;

I wonder whether there's any keyword that can be used for the first color to use the original system color for the scrollbar elements?

Another unfortunate behavior is that using scrollbar-overlay also disables the hover-effect on scrollbars.

@dianaqu

Copy link
Copy Markdown
Author

softworkz
Hi,

Thanks for providing your feedback. The API is designed to be extendable to support new scrollbar styles that developers want. The currently supporting one is not transparent scrollbar, but more a windows style overlay scrollbar which is hidden when no user action and appears "transparent" when user is scrolling.

If you have more styles that you want to support, feel free to submit a feature request. If you have your own customized scrollbar style, I believe those can be achieved by CSS.

Your suggestions sounds like a different API, so feel free to make it as feature request as well and we will look into it.

@softworkz

softworkz commented Jan 23, 2024 •

Copy link
Copy Markdown

The name "Fluent Overlay" has brought on a wrong track. I assumed it would about having scrollbars showing the Mica background of a window backdrop.
Accidentally, I had read through the Fluent UI guidelines the past few days and I don't remember any mention of something like "Fluent Overlay". So is this API about this - what they are calling "panning indicator"..?


image

Ref: https://learn.microsoft.com/en-us/windows/apps/design/controls/scroll-controls?tabs=scrollview

@dianaqu

Diana Qu (dianaqu) commented Jan 23, 2024 •

Copy link
Copy Markdown
Author

Partially yes. This COREWEBVIEW2_SCROLLBAR_STYLE_FLUENT_OVERLAY style allow the scrollbar to represent in the left picture way when scrolling and right picture way when hover over. This API allow developers to chose what the scrollbar style. It just that only one style is currently supported and more will be added in the future

@softworkz

Copy link
Copy Markdown

There's also an OS setting to control scrollbar behavior (Accessibility >> Visual Effects: Always show scrollbars). It might need consideration which setting will take precedence.

Regarding the API spec, I'm wondering whether it shouldn't be defined as Flags (having values like 1, 2, 4, 8, -- and the C# enum attributed with [Flags[. This would provide more flexibility as it allows to combine multiple flags and thus to control multiple possibly independent aspects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants