Skip to content

A platform for community discussion. Free, open, simple.

UX: lightbox expand btn smooth transition (#35765)

David Battersby8c2a2f2f9c46
diff --git a/app/assets/stylesheets/common/base/lightbox.scss b/app/assets/stylesheets/common/base/lightbox.scss
index 75d33f984cd..3255bc8366b 100644
--- a/app/assets/stylesheets/common/base/lightbox.scss
+++ b/app/assets/stylesheets/common/base/lightbox.scss
@@ -35,29 +35,34 @@
* {
outline: 0;
}
-}
-
-.meta {
- --meta-element-margin: 0.375em;
- position: absolute;
- bottom: 0;
- width: 100%;
- color: var(--secondary);
- background: var(--primary);
- opacity: 0;
- transition: opacity 0.2s;
- display: flex;
- align-items: center;
- @media (pointer: coarse) {
- align-items: center;
- background: var(--secondary);
- color: var(--primary-high);
- height: 25px;
- width: 25px;
+ .lightbox .meta {
+ --meta-element-margin: 0.375em;
+ position: absolute;
bottom: 0;
- right: 0;
- opacity: 0.8;
+ width: 100%;
+ color: var(--secondary);
+ background: var(--primary);
+ opacity: 0;
+ transition: opacity 0.2s;
+ display: flex;
+ align-items: center;
+
+ @media (pointer: coarse) {
+ align-items: center;
+ background: var(--secondary);
+ color: var(--primary-high);
+ height: 25px;
+ width: 25px;
+ bottom: 0;
+ right: 0;
+ opacity: 0.8;
+ transition: opacity 500ms;
+
+ &.open {
+ opacity: 0;
+ }
+ }
}
.filename {
diff --git a/frontend/discourse/app/lib/lightbox.js b/frontend/discourse/app/lib/lightbox.js
index 43c0dd46660..c1ccc13d3ec 100644
--- a/frontend/discourse/app/lib/lightbox.js
+++ b/frontend/discourse/app/lib/lightbox.js
@@ -45,6 +45,16 @@ export default async function lightbox(elem, siteSettings) {
appendToEl: isTesting() && document.getElementById("ember-testing"),
});
+ lightboxEl.on("afterInit", () => {
+ const el = lightboxEl.pswp.currSlide.data.element;
+ el.querySelector(".meta").classList.add("open");
+ });
+
+ lightboxEl.on("destroy", () => {
+ const el = lightboxEl.pswp.currSlide.data.element;
+ el.querySelector(".meta").classList.remove("open");
+ });
+
lightboxEl.on("uiRegister", function () {
// adds a custom caption to lightbox
lightboxEl.pswp.ui.registerElement({