UI: better modal backdrop opacity fading (#26328)

The fading should now be function of the swipe position. We should also correctly instantly remove the fading when closing the modal.
This commit is contained in:
Joffrey JAFFEUX 2024-03-22 22:49:01 +01:00 committed by GitHub
parent 0ed1b4537b
commit 9855b794e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 26 additions and 4 deletions

View File

@ -161,6 +161,9 @@ export default class DModal extends Component {
if (this.site.mobileView) {
this.animating = true;
this.#animateBackdropOpacity(window.innerHeight);
await this.wrapperElement.animate(
[
// hidding first ms to avoid flicker
@ -228,7 +231,27 @@ export default class DModal extends Component {
}
}
#animateBackdropOpacity(position) {
const backdrop = this.wrapperElement.nextElementSibling;
if (!backdrop) {
return;
}
// 85vh is the max height of the modal
const opacity = 1 - position / (window.innerHeight * 0.85);
requestAnimationFrame(() => {
backdrop.style.setProperty(
"opacity",
Math.max(0, Math.min(opacity, 0.6)),
"important"
);
});
}
async #animateWrapperPosition(position) {
this.#animateBackdropOpacity(position);
await this.wrapperElement.animate(
[{ transform: `translateY(${position}px)` }],
{

View File

@ -103,10 +103,6 @@
animation-duration: 0s;
}
}
&.is-closing + .d-modal__backdrop {
display: none;
}
}
//legacy

View File

@ -86,6 +86,7 @@ module PageObjects
def bookmark_message(message)
if page.has_css?("html.mobile-view", wait: 0)
click_message_action_mobile(message, "bookmark")
expect(page).to have_css(".d-modal:not(.is-animating)")
else
hover_message(message)
find(".bookmark-btn").click

View File

@ -161,6 +161,8 @@ module PageObjects
click_button(class: "sidebar-section-header-button", visible: false)
end
expect(page).to have_css(".d-modal:not(.is-animating)")
PageObjects::Modals::SidebarEditTags.new
end