Browse Source

Fix viewing reaction in sticker viewer

master
Eduard Kuzmenko 2 years ago
parent
commit
07c1917b7c
  1. 2
      src/components/chat/bubbles.ts
  2. 16
      src/components/stickerViewer.ts

2
src/components/chat/bubbles.ts

@ -668,7 +668,7 @@ export default class ChatBubbles { @@ -668,7 +668,7 @@ export default class ChatBubbles {
});
});
attachStickerViewerListeners({listenTo: this.scrollable.container, listenerSetter: this.listenerSetter});
attachStickerViewerListeners({listenTo: this.scrollable.container, listenerSetter: this.listenerSetter, selector: '.attachment.media-sticker-wrapper'});
attachClickEvent(this.scrollable.container, this.onBubblesClick, {listenerSetter: this.listenerSetter});
// this.listenerSetter.add(this.bubblesContainer)('click', this.onBubblesClick/* , {capture: true, passive: false} */);

16
src/components/stickerViewer.ts

@ -28,20 +28,26 @@ import {wrapSticker} from './wrappers'; @@ -28,20 +28,26 @@ import {wrapSticker} from './wrappers';
import {STICKER_EFFECT_MULTIPLIER} from './wrappers/sticker';
let hasViewer = false;
export default function attachStickerViewerListeners({listenTo, listenerSetter}: {
export default function attachStickerViewerListeners({listenTo, listenerSetter, selector}: {
listenerSetter: ListenerSetter,
listenTo: HTMLElement
listenTo: HTMLElement,
selector?: string
}) {
if(IS_TOUCH_SUPPORTED) {
return;
}
const findTarget = (e: MouseEvent, checkForParent?: boolean) => {
const s = selector || `.media-sticker-wrapper`;
const el = (e.target as HTMLElement).closest(s) as HTMLElement;
return el && (!checkForParent || findUpAsChild(el, listenTo)) ? el : undefined;
};
const managers = rootScope.managers;
const findClassName = 'media-sticker-wrapper';
listenerSetter.add(listenTo)('mousedown', (e) => {
if(hasViewer || e.buttons > 1 || e.button !== 0) return;
let mediaContainer = findUpClassName(e.target, findClassName);
let mediaContainer = findTarget(e);
if(!mediaContainer) {
return;
}
@ -228,7 +234,7 @@ export default function attachStickerViewerListeners({listenTo, listenerSetter}: @@ -228,7 +234,7 @@ export default function attachStickerViewerListeners({listenTo, listenerSetter}:
}, 125);
const onMouseMove = async(e: MouseEvent) => {
const newMediaContainer = findUpClassName(e.target, 'media-sticker-wrapper');
const newMediaContainer = findTarget(e, true);
if(!newMediaContainer || mediaContainer === newMediaContainer) {
return;
}

Loading…
Cancel
Save