Browse Source

Fix slicer for handhelds

master
Eduard Kuzmenko 4 years ago
parent
commit
345bee8c10
  1. 4
      src/components/chat/input.ts
  2. 2
      src/components/inputField.ts
  3. 16
      src/lib/appManagers/appDialogsManager.ts

4
src/components/chat/input.ts

@ -196,13 +196,13 @@ export class ChatInput {
const value = this.messageInput.innerText; const value = this.messageInput.innerText;
const entities = RichTextProcessor.parseEntities(value); const entities = RichTextProcessor.parseEntities(value);
console.log('messageInput entities', entities); //console.log('messageInput entities', entities);
const urlEntities = entities.filter(e => e._ == 'messageEntityUrl'); const urlEntities = entities.filter(e => e._ == 'messageEntityUrl');
if(urlEntities.length) { if(urlEntities.length) {
const richEntities: MessageEntity[] = []; const richEntities: MessageEntity[] = [];
const richValue = RichTextProcessor.parseMarkdown(getRichValue(this.messageInput), richEntities); const richValue = RichTextProcessor.parseMarkdown(getRichValue(this.messageInput), richEntities);
console.log('messageInput url', entities, richEntities); //console.log('messageInput url', entities, richEntities);
for(const entity of urlEntities) { for(const entity of urlEntities) {
const url = value.slice(entity.offset, entity.offset + entity.length); const url = value.slice(entity.offset, entity.offset + entity.length);

2
src/components/inputField.ts

@ -64,7 +64,7 @@ const InputField = (options: {
const input = div.firstElementChild as HTMLElement; const input = div.firstElementChild as HTMLElement;
const observer = new MutationObserver((mutationsList, observer) => { const observer = new MutationObserver((mutationsList, observer) => {
const isEmpty = isInputEmpty(input); const isEmpty = isInputEmpty(input);
console.log('input', isEmpty); //console.log('input', isEmpty);
const char = input.innerText[0]; const char = input.innerText[0];
let direction = 'ltr'; let direction = 'ltr';

16
src/lib/appManagers/appDialogsManager.ts

@ -13,7 +13,7 @@ import { isApple, isSafari } from "../../helpers/userAgent";
import { logger, LogLevels } from "../logger"; import { logger, LogLevels } from "../logger";
import { RichTextProcessor } from "../richtextprocessor"; import { RichTextProcessor } from "../richtextprocessor";
import rootScope from "../rootScope"; import rootScope from "../rootScope";
import { findUpClassName, positionElementByIndex } from "../../helpers/dom"; import { findUpClassName, findUpTag, positionElementByIndex } from "../../helpers/dom";
import appImManager, { AppImManager } from "./appImManager"; import appImManager, { AppImManager } from "./appImManager";
import appMessagesManager, { Dialog } from "./appMessagesManager"; import appMessagesManager, { Dialog } from "./appMessagesManager";
import {MyDialogFilter as DialogFilter} from "../storages/filters"; import {MyDialogFilter as DialogFilter} from "../storages/filters";
@ -753,13 +753,17 @@ export class AppDialogsManager {
const rect = this.scroll.container.getBoundingClientRect(); const rect = this.scroll.container.getBoundingClientRect();
const children = Array.from(this.scroll.splitUp.children) as HTMLElement[]; const children = Array.from(this.scroll.splitUp.children) as HTMLElement[];
const firstElement = document.elementFromPoint(rect.x, rect.y) as HTMLElement; const firstElement = findUpTag(document.elementFromPoint(rect.x, rect.y + 1), 'LI') as HTMLElement;
const lastElement = document.elementFromPoint(rect.x, rect.y + rect.height - 1) as HTMLElement; const lastElement = findUpTag(document.elementFromPoint(rect.x, rect.y + rect.height - 1), 'LI') as HTMLElement;
//alert('got element:' + rect.y);
if(!firstElement || !lastElement) { if(!firstElement || !lastElement) {
return; return;
} }
//alert('got element:' + !!firstElement);
const firstElementRect = firstElement.getBoundingClientRect(); const firstElementRect = firstElement.getBoundingClientRect();
const elementOverflow = firstElementRect.y - rect.y; const elementOverflow = firstElementRect.y - rect.y;
@ -803,14 +807,16 @@ export class AppDialogsManager {
//this.log('[slicer] elements', firstElement, lastElement, rect, sliced, sliceFromStart.length, sliceFromEnd.length); //this.log('[slicer] elements', firstElement, lastElement, rect, sliced, sliceFromStart.length, sliceFromEnd.length);
//this.log('[slicer] reset scrollTop', scrollTopWas, this.scroll.scrollTop, firstElement.offsetTop, firstElementRect.y, rect.y, elementOverflow); //this.log('[slicer] reset scrollTop', this.scroll.scrollTop, firstElement.offsetTop, firstElementRect.y, rect.y, elementOverflow);
//alert('left length:' + children.length);
this.scroll.scrollTop = firstElement.offsetTop - elementOverflow; this.scroll.scrollTop = firstElement.offsetTop - elementOverflow;
/* const firstElementRect = firstElement.getBoundingClientRect(); /* const firstElementRect = firstElement.getBoundingClientRect();
const scrollTop = */ const scrollTop = */
//this.scroll.scrollIntoView(firstElement, false); //this.scroll.scrollIntoView(firstElement, false);
}, 1e3); }, 200);
}; };
public onChatsScrollTop = () => { public onChatsScrollTop = () => {

Loading…
Cancel
Save