Browse Source

Better media viewer caption transition

master
Eduard Kuzmenko 3 years ago
parent
commit
4b6a8ff056
  1. 21
      src/components/appMediaViewer.ts
  2. 15
      src/scss/partials/_mediaViewer.scss

21
src/components/appMediaViewer.ts

@ -657,6 +657,7 @@ class AppMediaViewerBase<ContentAdditionType extends string, ButtonsAdditionType
mover.classList.add('hiding'); mover.classList.add('hiding');
} }
this.wholeDiv.classList.add('backwards');
setTimeout(() => { setTimeout(() => {
this.wholeDiv.classList.remove('active'); this.wholeDiv.classList.remove('active');
}, 0); }, 0);
@ -1346,6 +1347,16 @@ export default class AppMediaViewer extends AppMediaViewerBase<'caption', 'delet
this.content.caption.classList.add(MEDIA_VIEWER_CLASSNAME + '-caption'/* , 'media-viewer-stub' */); this.content.caption.classList.add(MEDIA_VIEWER_CLASSNAME + '-caption'/* , 'media-viewer-stub' */);
let captionTimeout: number; let captionTimeout: number;
const setCaptionTimeout = () => {
if(captionTimeout) {
clearTimeout(captionTimeout);
}
captionTimeout = window.setTimeout(() => {
captionTimeout = undefined;
this.content.caption.classList.remove('is-focused');
}, 800);
};
this.content.caption.addEventListener('touchstart', () => { this.content.caption.addEventListener('touchstart', () => {
if(!mediaSizes.isMobile) return; if(!mediaSizes.isMobile) return;
@ -1356,15 +1367,11 @@ export default class AppMediaViewer extends AppMediaViewerBase<'caption', 'delet
captionTimeout = undefined; captionTimeout = undefined;
} }
document.addEventListener('touchend', () => { document.addEventListener('touchend', setCaptionTimeout, {once: true});
captionTimeout = window.setTimeout(() => {
captionTimeout = undefined;
this.content.caption.classList.remove('is-focused');
}, 500);
}, {once: true});
}); });
new Scrollable(this.content.caption); const captionScrollable = new Scrollable(this.content.caption);
captionScrollable.onAdditionalScroll = setCaptionTimeout;
//this.content.main.append(this.content.caption); //this.content.main.append(this.content.caption);
this.wholeDiv.append(this.content.caption); this.wholeDiv.append(this.content.caption);

15
src/scss/partials/_mediaViewer.scss

@ -130,11 +130,9 @@
line-height: var(--line-height); line-height: var(--line-height);
white-space: pre-wrap; white-space: pre-wrap;
background-color: transparent; background-color: transparent;
visibility: hidden;
@include animation-level(2) { @include animation-level(2) {
transition: transform var(--layer-transition), opacity var(--open-duration) ease-in-out, visibility 0s, background-color var(--open-duration) ease-in-out; transition: transform var(--layer-transition), opacity var(--open-duration) ease-in-out, background-color var(--open-duration) ease-in-out;
transition-delay: 0s, 0s, 0s, 0s;
} }
a { a {
@ -181,6 +179,10 @@
transform: translate3d(0, -69px, 0); transform: translate3d(0, -69px, 0);
} }
.media-viewer-whole.backwards & {
visibility: hidden;
}
@include hover() { @include hover() {
background-color: #000; background-color: #000;
opacity: 1 !important; opacity: 1 !important;
@ -506,12 +508,15 @@
> .btn-icon */ { > .btn-icon */ {
opacity: 1; opacity: 1;
visibility: visible; visibility: visible;
transition: opacity var(--open-duration) 0s, visibility 0s 0s;
@include animation-level(2) {
transition: opacity var(--open-duration) 0s, visibility 0s 0s;
}
} }
.media-viewer-caption { .media-viewer-caption {
visibility: visible; visibility: visible;
transition-delay: 0s, 0s, var(--open-duration), 0s; // transition-delay: 0s, 0s, var(--open-duration), 0s;
} }
} }

Loading…
Cancel
Save