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:
parent
0ed1b4537b
commit
9855b794e9
|
@ -161,6 +161,9 @@ export default class DModal extends Component {
|
||||||
|
|
||||||
if (this.site.mobileView) {
|
if (this.site.mobileView) {
|
||||||
this.animating = true;
|
this.animating = true;
|
||||||
|
|
||||||
|
this.#animateBackdropOpacity(window.innerHeight);
|
||||||
|
|
||||||
await this.wrapperElement.animate(
|
await this.wrapperElement.animate(
|
||||||
[
|
[
|
||||||
// hidding first ms to avoid flicker
|
// 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) {
|
async #animateWrapperPosition(position) {
|
||||||
|
this.#animateBackdropOpacity(position);
|
||||||
|
|
||||||
await this.wrapperElement.animate(
|
await this.wrapperElement.animate(
|
||||||
[{ transform: `translateY(${position}px)` }],
|
[{ transform: `translateY(${position}px)` }],
|
||||||
{
|
{
|
||||||
|
|
|
@ -103,10 +103,6 @@
|
||||||
animation-duration: 0s;
|
animation-duration: 0s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.is-closing + .d-modal__backdrop {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//legacy
|
//legacy
|
||||||
|
|
|
@ -86,6 +86,7 @@ module PageObjects
|
||||||
def bookmark_message(message)
|
def bookmark_message(message)
|
||||||
if page.has_css?("html.mobile-view", wait: 0)
|
if page.has_css?("html.mobile-view", wait: 0)
|
||||||
click_message_action_mobile(message, "bookmark")
|
click_message_action_mobile(message, "bookmark")
|
||||||
|
expect(page).to have_css(".d-modal:not(.is-animating)")
|
||||||
else
|
else
|
||||||
hover_message(message)
|
hover_message(message)
|
||||||
find(".bookmark-btn").click
|
find(".bookmark-btn").click
|
||||||
|
|
|
@ -161,6 +161,8 @@ module PageObjects
|
||||||
click_button(class: "sidebar-section-header-button", visible: false)
|
click_button(class: "sidebar-section-header-button", visible: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
expect(page).to have_css(".d-modal:not(.is-animating)")
|
||||||
|
|
||||||
PageObjects::Modals::SidebarEditTags.new
|
PageObjects::Modals::SidebarEditTags.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue