Button menu changes:
Position fix Added background overlay for click
This commit is contained in:
parent
9ec40ea9e9
commit
5fe586e9ce
@ -64,6 +64,7 @@ export default class ChatContextMenu {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const side: 'left' | 'right' = bubble.classList.contains('is-in') ? 'left' : 'right';
|
const side: 'left' | 'right' = bubble.classList.contains('is-in') ? 'left' : 'right';
|
||||||
|
//bubble.parentElement.append(this.element);
|
||||||
positionMenu(e, this.element, side);
|
positionMenu(e, this.element, side);
|
||||||
openBtnMenu(this.element, () => {
|
openBtnMenu(this.element, () => {
|
||||||
this.peerID = this.msgID = 0;
|
this.peerID = this.msgID = 0;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import Countries, { Country, PhoneCodesMain } from "../countries";
|
import Countries, { Country, PhoneCodesMain } from "../countries";
|
||||||
import mediaSizes from "../helpers/mediaSizes";
|
import mediaSizes from "../helpers/mediaSizes";
|
||||||
|
import { clamp } from "../helpers/number";
|
||||||
import { isTouchSupported } from "../helpers/touchSupport";
|
import { isTouchSupported } from "../helpers/touchSupport";
|
||||||
import { isApple } from "../helpers/userAgent";
|
import { isApple } from "../helpers/userAgent";
|
||||||
|
|
||||||
@ -139,6 +140,7 @@ let closeBtnMenu = () => {
|
|||||||
if(openedMenu) {
|
if(openedMenu) {
|
||||||
openedMenu.classList.remove('active');
|
openedMenu.classList.remove('active');
|
||||||
openedMenu.parentElement.classList.remove('menu-open');
|
openedMenu.parentElement.classList.remove('menu-open');
|
||||||
|
openedMenu.previousElementSibling.remove(); // remove overlay
|
||||||
openedMenu = null;
|
openedMenu = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,6 +185,9 @@ export function openBtnMenu(menuElement: HTMLElement, onClose?: () => void) {
|
|||||||
openedMenu.classList.add('active');
|
openedMenu.classList.add('active');
|
||||||
openedMenu.parentElement.classList.add('menu-open');
|
openedMenu.parentElement.classList.add('menu-open');
|
||||||
|
|
||||||
|
const overlay = document.createElement('div');
|
||||||
|
overlay.classList.add('btn-menu-overlay');
|
||||||
|
openedMenu.parentElement.insertBefore(overlay, openedMenu);
|
||||||
//document.body.classList.add('disable-hover');
|
//document.body.classList.add('disable-hover');
|
||||||
|
|
||||||
openedMenuOnClose = onClose;
|
openedMenuOnClose = onClose;
|
||||||
@ -200,6 +205,8 @@ export function openBtnMenu(menuElement: HTMLElement, onClose?: () => void) {
|
|||||||
window.addEventListener('contextmenu', onClick, {once: true});
|
window.addEventListener('contextmenu', onClick, {once: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const PADDING_TOP = 16;
|
||||||
|
const PADDING_LEFT = 16;
|
||||||
export function positionMenu({clientX, clientY}: {clientX: number, clientY: number}/* e: MouseEvent */, elem: HTMLElement, side?: 'left' | 'right') {
|
export function positionMenu({clientX, clientY}: {clientX: number, clientY: number}/* e: MouseEvent */, elem: HTMLElement, side?: 'left' | 'right') {
|
||||||
//let {clientX, clientY} = e;
|
//let {clientX, clientY} = e;
|
||||||
|
|
||||||
@ -211,12 +218,8 @@ export function positionMenu({clientX, clientY}: {clientX: number, clientY: numb
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(side === undefined) {
|
if(side === undefined) {
|
||||||
if((clientX + scrollWidth) > innerWidth) {
|
if((clientX + scrollWidth + PADDING_LEFT) > innerWidth) {
|
||||||
if((clientX - scrollWidth) < 0) {
|
side = 'right';
|
||||||
elem.style.left = (innerWidth - scrollWidth) + 'px';
|
|
||||||
} else {
|
|
||||||
side = 'right';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,17 +227,24 @@ export function positionMenu({clientX, clientY}: {clientX: number, clientY: numb
|
|||||||
side = 'left';
|
side = 'left';
|
||||||
}
|
}
|
||||||
|
|
||||||
elem.classList.remove('bottom-left', 'bottom-right');
|
// ! don't need reverse for this, this will be the side WHERE ANIMATION WILL END !
|
||||||
if(side !== undefined) {
|
let verticalSide: 'top' | 'bottom';
|
||||||
elem.style.left = (side == 'right' ? clientX - scrollWidth : clientX) + 'px';
|
|
||||||
elem.classList.add(side == 'left' ? 'bottom-right' : 'bottom-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
if((clientY + scrollHeight) > innerHeight) {
|
if(side !== undefined) {
|
||||||
elem.style.top = (innerHeight - scrollHeight) + 'px';
|
const left = clamp(side == 'right' ? clientX - scrollWidth : clientX, PADDING_LEFT, innerWidth - scrollWidth - PADDING_LEFT);
|
||||||
} else {
|
elem.style.left = left + 'px';
|
||||||
elem.style.top = clientY + 'px';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((clientY + scrollHeight + PADDING_TOP) > innerHeight) {
|
||||||
|
elem.style.top = (clientY - scrollHeight) + 'px';
|
||||||
|
verticalSide = 'top';
|
||||||
|
} else {
|
||||||
|
elem.style.top = Math.max(PADDING_TOP, clientY) + 'px';
|
||||||
|
verticalSide = 'bottom';
|
||||||
|
}
|
||||||
|
|
||||||
|
elem.classList.remove('bottom-left', 'bottom-right', 'top-left', 'top-right');
|
||||||
|
elem.classList.add(verticalSide + '-' + (side == 'left' ? 'right' : 'left'));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function attachContextMenuListener(element: HTMLElement, callback: (e: Touch | MouseEvent) => void) {
|
export function attachContextMenuListener(element: HTMLElement, callback: (e: Touch | MouseEvent) => void) {
|
||||||
|
@ -338,9 +338,11 @@ export class AppDialogsManager {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return this.loadDialogs();
|
return this.loadDialogs();
|
||||||
}).then(result => {
|
}).then(() => {
|
||||||
appMessagesManager.getConversationsAll('', 1).then(() => {
|
appMessagesManager.getConversationsAll('', 0).finally(() => {
|
||||||
this.accumulateArchivedUnread();
|
appMessagesManager.getConversationsAll('', 1).then(() => {
|
||||||
|
this.accumulateArchivedUnread();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
box-shadow: 0 5px 8px 1px rgba(0,0,0,.24);
|
box-shadow: 0 5px 8px 1px rgba(0, 0, 0, .24);
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
top: 100%;
|
top: 100%;
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
@ -64,9 +64,9 @@
|
|||||||
border-radius: $border-radius-medium;
|
border-radius: $border-radius-medium;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transform: scale(.8);
|
transform: scale(.8);
|
||||||
transition-property: opacity,transform,visibility;
|
transition-property: opacity, transform, visibility;
|
||||||
transition-duration: .2s;
|
transition-duration: .2s;
|
||||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
transition-timing-function: cubic-bezier(.4, 0, .2, 1);
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|
||||||
-webkit-user-select: none; /* disable selection/Copy of UIWebView */
|
-webkit-user-select: none; /* disable selection/Copy of UIWebView */
|
||||||
@ -122,7 +122,7 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
html.no-touch &:hover {
|
html.no-touch &:hover {
|
||||||
background-color: rgba(112, 117, 121, 0.06);
|
background-color: rgba(112, 117, 121, .06);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
@ -136,6 +136,25 @@
|
|||||||
height: 50px;
|
height: 50px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* &-overlay {
|
||||||
|
position: fixed !important;
|
||||||
|
left: -100vw;
|
||||||
|
right: -100vw;
|
||||||
|
top: -100vh;
|
||||||
|
bottom: -100vh;
|
||||||
|
z-index: 1;
|
||||||
|
background-color: rgba(0, 0, 0, .2);
|
||||||
|
} */
|
||||||
|
&-overlay {
|
||||||
|
position: fixed !important;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 1;
|
||||||
|
//background-color: rgba(0, 0, 0, .2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-primary {
|
.btn-primary {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user