Media viewer new caption (not so good)
This commit is contained in:
parent
065b4ba042
commit
ebda218096
@ -22,6 +22,7 @@ import { LazyLoadQueueBase } from "./lazyLoadQueue";
|
|||||||
import { renderImageFromUrl } from "./misc";
|
import { renderImageFromUrl } from "./misc";
|
||||||
import PopupForward from "./popupForward";
|
import PopupForward from "./popupForward";
|
||||||
import ProgressivePreloader from "./preloader";
|
import ProgressivePreloader from "./preloader";
|
||||||
|
import Scrollable from "./scrollable";
|
||||||
import appSidebarRight, { AppSidebarRight } from "./sidebarRight";
|
import appSidebarRight, { AppSidebarRight } from "./sidebarRight";
|
||||||
import SwipeHandler from "./swipeHandler";
|
import SwipeHandler from "./swipeHandler";
|
||||||
|
|
||||||
@ -206,6 +207,13 @@ class AppMediaViewerBase<ContentAdditionType extends string, ButtonsAdditionType
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}, (evt) => {
|
||||||
|
// * Fix for seek input
|
||||||
|
if((evt.target as HTMLElement).tagName == 'INPUT' || findUpClassName(evt.target, 'media-viewer-caption')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,7 +282,7 @@ class AppMediaViewerBase<ContentAdditionType extends string, ButtonsAdditionType
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mover: HTMLElement = null;
|
let mover: HTMLElement = null;
|
||||||
['media-viewer-mover', 'media-viewer-buttons', 'media-viewer-author'].find(s => {
|
['media-viewer-mover', 'media-viewer-buttons', 'media-viewer-author', 'media-viewer-caption'].find(s => {
|
||||||
try {
|
try {
|
||||||
mover = findUpClassName(target, s);
|
mover = findUpClassName(target, s);
|
||||||
if(mover) return true;
|
if(mover) return true;
|
||||||
@ -1093,13 +1101,17 @@ export default class AppMediaViewer extends AppMediaViewerBase<'caption', 'delet
|
|||||||
constructor(private inputFilter: 'inputMessagesFilterPhotoVideo' | 'inputMessagesFilterChatPhotos' = 'inputMessagesFilterPhotoVideo') {
|
constructor(private inputFilter: 'inputMessagesFilterPhotoVideo' | 'inputMessagesFilterChatPhotos' = 'inputMessagesFilterPhotoVideo') {
|
||||||
super(['delete', 'forward']);
|
super(['delete', 'forward']);
|
||||||
|
|
||||||
const stub = document.createElement('div');
|
/* const stub = document.createElement('div');
|
||||||
stub.classList.add(MEDIA_VIEWER_CLASSNAME + '-stub');
|
stub.classList.add(MEDIA_VIEWER_CLASSNAME + '-stub');
|
||||||
this.content.main.prepend(stub);
|
this.content.main.prepend(stub); */
|
||||||
|
|
||||||
this.content.caption = document.createElement('div');
|
this.content.caption = document.createElement('div');
|
||||||
this.content.caption.classList.add(MEDIA_VIEWER_CLASSNAME + '-caption');
|
this.content.caption.classList.add(MEDIA_VIEWER_CLASSNAME + '-caption'/* , 'media-viewer-stub' */);
|
||||||
this.content.main.append(this.content.caption);
|
|
||||||
|
new Scrollable(this.content.caption);
|
||||||
|
|
||||||
|
//this.content.main.append(this.content.caption);
|
||||||
|
this.wholeDiv.append(this.content.caption);
|
||||||
|
|
||||||
this.setBtnMenuToggle([{
|
this.setBtnMenuToggle([{
|
||||||
icon: 'forward',
|
icon: 'forward',
|
||||||
@ -1274,12 +1286,13 @@ export default class AppMediaViewer extends AppMediaViewerBase<'caption', 'delet
|
|||||||
|
|
||||||
private setCaption(message: any) {
|
private setCaption(message: any) {
|
||||||
const caption = message.message;
|
const caption = message.message;
|
||||||
|
this.content.caption.classList.toggle('hide', !caption);
|
||||||
if(caption) {
|
if(caption) {
|
||||||
this.content.caption.innerHTML = RichTextProcessor.wrapRichText(caption, {
|
this.content.caption.firstElementChild.innerHTML = RichTextProcessor.wrapRichText(caption, {
|
||||||
entities: message.totalEntities
|
entities: message.totalEntities
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.content.caption.innerHTML = '';
|
this.content.caption.firstElementChild.innerHTML = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,14 +2,13 @@ export default class SwipeHandler {
|
|||||||
private xDown: number;
|
private xDown: number;
|
||||||
private yDown: number;
|
private yDown: number;
|
||||||
|
|
||||||
constructor(element: HTMLElement, private onSwipe: (xDiff: number, yDiff: number) => boolean) {
|
constructor(element: HTMLElement, private onSwipe: (xDiff: number, yDiff: number) => boolean, private verifyTouchTarget?: (evt: TouchEvent) => boolean) {
|
||||||
element.addEventListener('touchstart', this.handleTouchStart, false);
|
element.addEventListener('touchstart', this.handleTouchStart, false);
|
||||||
element.addEventListener('touchmove', this.handleTouchMove, false);
|
element.addEventListener('touchmove', this.handleTouchMove, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTouchStart = (evt: TouchEvent) => {
|
handleTouchStart = (evt: TouchEvent) => {
|
||||||
// * Fix for seek input
|
if(this.verifyTouchTarget && !this.verifyTouchTarget(evt)) {
|
||||||
if((evt.target as HTMLElement).tagName == 'INPUT') {
|
|
||||||
this.xDown = this.yDown = null;
|
this.xDown = this.yDown = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -624,7 +624,7 @@ export class AppImManager {
|
|||||||
} else if(target.classList.contains('name')) {
|
} else if(target.classList.contains('name')) {
|
||||||
let peerID = +target.dataset.peerID;
|
let peerID = +target.dataset.peerID;
|
||||||
|
|
||||||
if(!isNaN(peerID)) {
|
if(peerID) {
|
||||||
this.setPeer(peerID);
|
this.setPeer(peerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -632,7 +632,7 @@ export class AppImManager {
|
|||||||
} else if(target.tagName == "AVATAR-ELEMENT") {
|
} else if(target.tagName == "AVATAR-ELEMENT") {
|
||||||
let peerID = +target.getAttribute('peer');
|
let peerID = +target.getAttribute('peer');
|
||||||
|
|
||||||
if(!isNaN(peerID)) {
|
if(peerID) {
|
||||||
this.setPeer(peerID);
|
this.setPeer(peerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -652,7 +652,7 @@ export class AppImManager {
|
|||||||
} else if(target.tagName == 'IMG' && target.parentElement.tagName == "AVATAR-ELEMENT") {
|
} else if(target.tagName == 'IMG' && target.parentElement.tagName == "AVATAR-ELEMENT") {
|
||||||
let peerID = +target.parentElement.getAttribute('peer');
|
let peerID = +target.parentElement.getAttribute('peer');
|
||||||
|
|
||||||
if(!isNaN(peerID)) {
|
if(peerID) {
|
||||||
this.setPeer(peerID);
|
this.setPeer(peerID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,13 +259,13 @@ $bubble-margin: .25rem;
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
#bubbles.is-selecting & {
|
#bubbles.is-selecting & {
|
||||||
transform: scale(1);
|
transform: scale3d(1, 1, 1);
|
||||||
transform-origin: bottom;
|
transform-origin: bottom;
|
||||||
transition: transform var(--layer-transition);
|
transition: transform var(--layer-transition);
|
||||||
}
|
}
|
||||||
|
|
||||||
#bubbles.is-selecting:not(.backwards) & {
|
#bubbles.is-selecting:not(.backwards) & {
|
||||||
transform: scale(.76);
|
transform: scale3d(.76, .76, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @include respond-to(handhelds) {
|
// @include respond-to(handhelds) {
|
||||||
@ -328,6 +328,10 @@ $bubble-margin: .25rem;
|
|||||||
&.is-group-last {
|
&.is-group-last {
|
||||||
padding-bottom: $bubble-margin;
|
padding-bottom: $bubble-margin;
|
||||||
|
|
||||||
|
.bubble-select-checkbox {
|
||||||
|
bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
#bubbles-inner.is-chat &.is-in {
|
#bubbles-inner.is-chat &.is-in {
|
||||||
.bubble-select-checkbox {
|
.bubble-select-checkbox {
|
||||||
bottom: 7px;
|
bottom: 7px;
|
||||||
|
@ -89,9 +89,10 @@ $move-duration: .35s;
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-stub {
|
/* &-stub {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
min-height: 50px;
|
||||||
|
} */
|
||||||
|
|
||||||
&-container {
|
&-container {
|
||||||
align-self: center;
|
align-self: center;
|
||||||
@ -109,17 +110,46 @@ $move-duration: .35s;
|
|||||||
}
|
}
|
||||||
|
|
||||||
&-caption {
|
&-caption {
|
||||||
flex: 1;
|
position: absolute;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: $color-gray;
|
color: #fff;
|
||||||
transition: $open-duration;
|
//color: #707579;
|
||||||
max-width: 50vw;
|
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
z-index: 5;
|
||||||
|
bottom: 3rem;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
padding: 0 .5rem;
|
||||||
|
background-color: rgba(0, 0, 0, .6);
|
||||||
|
border-radius: 8px;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity $open-duration;
|
||||||
|
|
||||||
html.no-touch &:hover {
|
@include respond-to(handhelds) {
|
||||||
color: #fff;
|
border-radius: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
> .scrollable {
|
||||||
|
padding: .5rem 0;
|
||||||
|
max-height: 10rem;
|
||||||
|
max-width: 1280px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.media-viewer-whole.active & {
|
||||||
|
opacity: 1;
|
||||||
|
|
||||||
|
html.no-touch & {
|
||||||
|
opacity: .2;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
opacity: 1;
|
||||||
|
//color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user