|
|
@ -44,6 +44,7 @@ import PopupPickUser from "../../popups/pickUser"; |
|
|
|
import PopupPeer from "../../popups/peer"; |
|
|
|
import PopupPeer from "../../popups/peer"; |
|
|
|
import Scrollable from "../../scrollable"; |
|
|
|
import Scrollable from "../../scrollable"; |
|
|
|
import { isTouchSupported } from "../../../helpers/touchSupport"; |
|
|
|
import { isTouchSupported } from "../../../helpers/touchSupport"; |
|
|
|
|
|
|
|
import { isFirefox } from "../../../helpers/userAgent"; |
|
|
|
|
|
|
|
|
|
|
|
let setText = (text: string, row: Row) => { |
|
|
|
let setText = (text: string, row: Row) => { |
|
|
|
//fastRaf(() => {
|
|
|
|
//fastRaf(() => {
|
|
|
@ -52,6 +53,8 @@ let setText = (text: string, row: Row) => { |
|
|
|
//});
|
|
|
|
//});
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const PARALLAX_SUPPORTED = !isFirefox; |
|
|
|
|
|
|
|
|
|
|
|
type ListLoaderResult<T> = {count: number, items: any[]}; |
|
|
|
type ListLoaderResult<T> = {count: number, items: any[]}; |
|
|
|
class ListLoader<T> { |
|
|
|
class ListLoader<T> { |
|
|
|
public current: T; |
|
|
|
public current: T; |
|
|
@ -164,14 +167,16 @@ class ListLoader<T> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class PeerProfileAvatars { |
|
|
|
class PeerProfileAvatars { |
|
|
|
public static BASE_CLASS = 'profile-avatars'; |
|
|
|
private static BASE_CLASS = 'profile-avatars'; |
|
|
|
|
|
|
|
private static SCALE = PARALLAX_SUPPORTED ? 2 : 1; |
|
|
|
|
|
|
|
private static TRANSLATE_TEMPLATE = PARALLAX_SUPPORTED ? `translate3d({x}, 0, -1px) scale(${PeerProfileAvatars.SCALE})` : 'translate({x}, 0)'; |
|
|
|
public container: HTMLElement; |
|
|
|
public container: HTMLElement; |
|
|
|
public avatars: HTMLElement; |
|
|
|
public avatars: HTMLElement; |
|
|
|
public gradient: HTMLElement; |
|
|
|
public gradient: HTMLElement; |
|
|
|
public info: HTMLElement; |
|
|
|
public info: HTMLElement; |
|
|
|
public tabs: HTMLDivElement; |
|
|
|
private tabs: HTMLDivElement; |
|
|
|
public listLoader: ListLoader<string | Message.messageService>; |
|
|
|
private listLoader: ListLoader<string | Message.messageService>; |
|
|
|
public peerId: number; |
|
|
|
private peerId: number; |
|
|
|
|
|
|
|
|
|
|
|
constructor(public scrollable: Scrollable) { |
|
|
|
constructor(public scrollable: Scrollable) { |
|
|
|
this.container = document.createElement('div'); |
|
|
|
this.container = document.createElement('div'); |
|
|
@ -266,11 +271,11 @@ class PeerProfileAvatars { |
|
|
|
element: this.avatars, |
|
|
|
element: this.avatars, |
|
|
|
onSwipe: (xDiff, yDiff) => { |
|
|
|
onSwipe: (xDiff, yDiff) => { |
|
|
|
lastDiffX = xDiff; |
|
|
|
lastDiffX = xDiff; |
|
|
|
let lastX = x + xDiff * -2; |
|
|
|
let lastX = x + xDiff * -PeerProfileAvatars.SCALE; |
|
|
|
if(lastX > 0) lastX = 0; |
|
|
|
if(lastX > 0) lastX = 0; |
|
|
|
else if(lastX < minX) lastX = minX; |
|
|
|
else if(lastX < minX) lastX = minX; |
|
|
|
|
|
|
|
|
|
|
|
this.avatars.style.transform = `translate3d(${lastX}px, 0, -1px) scale(2)`; |
|
|
|
this.avatars.style.transform = PeerProfileAvatars.TRANSLATE_TEMPLATE.replace('{x}', lastX + 'px'); |
|
|
|
//console.log(xDiff, yDiff);
|
|
|
|
//console.log(xDiff, yDiff);
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
}, |
|
|
|
}, |
|
|
@ -294,13 +299,13 @@ class PeerProfileAvatars { |
|
|
|
x = -width * lastIndex; */ |
|
|
|
x = -width * lastIndex; */ |
|
|
|
x = rect.left - this.container.getBoundingClientRect().left; |
|
|
|
x = rect.left - this.container.getBoundingClientRect().left; |
|
|
|
|
|
|
|
|
|
|
|
this.avatars.style.transform = `translate3d(${x}px, 0, -1px) scale(2)`; |
|
|
|
this.avatars.style.transform = PeerProfileAvatars.TRANSLATE_TEMPLATE.replace('{x}', x + 'px'); |
|
|
|
|
|
|
|
|
|
|
|
this.avatars.classList.add('no-transition'); |
|
|
|
this.avatars.classList.add('no-transition'); |
|
|
|
void this.avatars.offsetLeft; // reflow
|
|
|
|
void this.avatars.offsetLeft; // reflow
|
|
|
|
}, |
|
|
|
}, |
|
|
|
onReset: () => { |
|
|
|
onReset: () => { |
|
|
|
const addIndex = Math.ceil(Math.abs(lastDiffX) / (width / 2)) * (lastDiffX >= 0 ? 1 : -1); |
|
|
|
const addIndex = Math.ceil(Math.abs(lastDiffX) / (width / PeerProfileAvatars.SCALE)) * (lastDiffX >= 0 ? 1 : -1); |
|
|
|
cancelNextClick(); |
|
|
|
cancelNextClick(); |
|
|
|
|
|
|
|
|
|
|
|
//console.log(addIndex);
|
|
|
|
//console.log(addIndex);
|
|
|
@ -372,7 +377,8 @@ class PeerProfileAvatars { |
|
|
|
onJump: (item, older) => { |
|
|
|
onJump: (item, older) => { |
|
|
|
const id = this.listLoader.index; |
|
|
|
const id = this.listLoader.index; |
|
|
|
//const nextId = Math.max(0, id);
|
|
|
|
//const nextId = Math.max(0, id);
|
|
|
|
this.avatars.style.transform = `translate3d(-${200 * id}%, 0, -1px) scale(2)`; |
|
|
|
const x = 100 * PeerProfileAvatars.SCALE * id; |
|
|
|
|
|
|
|
this.avatars.style.transform = PeerProfileAvatars.TRANSLATE_TEMPLATE.replace('{x}', `-${x}%`); |
|
|
|
|
|
|
|
|
|
|
|
const activeTab = this.tabs.querySelector('.active'); |
|
|
|
const activeTab = this.tabs.querySelector('.active'); |
|
|
|
if(activeTab) activeTab.classList.remove('active'); |
|
|
|
if(activeTab) activeTab.classList.remove('active'); |
|
|
@ -457,7 +463,9 @@ class PeerProfile { |
|
|
|
private threadId: number; |
|
|
|
private threadId: number; |
|
|
|
|
|
|
|
|
|
|
|
constructor(public scrollable: Scrollable) { |
|
|
|
constructor(public scrollable: Scrollable) { |
|
|
|
|
|
|
|
if(!PARALLAX_SUPPORTED) { |
|
|
|
|
|
|
|
this.scrollable.container.classList.add('no-parallax'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public init() { |
|
|
|
public init() { |
|
|
@ -609,13 +617,17 @@ class PeerProfile { |
|
|
|
if(oldAvatars) oldAvatars.container.replaceWith(this.avatars.container); |
|
|
|
if(oldAvatars) oldAvatars.container.replaceWith(this.avatars.container); |
|
|
|
else this.element.prepend(this.avatars.container); |
|
|
|
else this.element.prepend(this.avatars.container); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(PARALLAX_SUPPORTED) { |
|
|
|
this.scrollable.container.classList.add('parallax'); |
|
|
|
this.scrollable.container.classList.add('parallax'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(PARALLAX_SUPPORTED) { |
|
|
|
this.scrollable.container.classList.remove('parallax'); |
|
|
|
this.scrollable.container.classList.remove('parallax'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(this.avatars) { |
|
|
|
if(this.avatars) { |
|
|
|
this.avatars.container.remove(); |
|
|
|
this.avatars.container.remove(); |
|
|
|