|
|
@ -176,25 +176,27 @@ export default class ChatContextMenu { |
|
|
|
|
|
|
|
|
|
|
|
const initResult = this.init(); |
|
|
|
const initResult = this.init(); |
|
|
|
element = initResult.element; |
|
|
|
element = initResult.element; |
|
|
|
const {cleanup, destroy, menuPadding, reactionsMenu} = initResult; |
|
|
|
const {cleanup, destroy, menuPadding, reactionsMenu, reactionsMenuPosition} = initResult; |
|
|
|
let isReactionsMenuVisible = false; |
|
|
|
let isReactionsMenuVisible = false; |
|
|
|
if(reactionsMenu) { |
|
|
|
if(reactionsMenu) { |
|
|
|
const className = 'is-visible'; |
|
|
|
const className = 'is-visible'; |
|
|
|
isReactionsMenuVisible = reactionsMenu.container.classList.contains(className); |
|
|
|
isReactionsMenuVisible = reactionsMenu.container.classList.contains(className); |
|
|
|
if(isReactionsMenuVisible) reactionsMenu.container.classList.remove(className); |
|
|
|
if(isReactionsMenuVisible) reactionsMenu.container.classList.remove(className); |
|
|
|
|
|
|
|
|
|
|
|
const offsetWidth = element.offsetWidth; |
|
|
|
if(reactionsMenuPosition === 'horizontal') { |
|
|
|
|
|
|
|
const offsetSize = element[/* reactionsMenuPosition === 'vertical' ? 'offsetHeight' : */'offsetWidth']; |
|
|
|
// if(reactionsMenu.scrollable.container.scrollWidth > offsetWidth) {
|
|
|
|
// if(reactionsMenu.scrollable.container.scrollWidth > offsetWidth) {
|
|
|
|
const INNER_CONTAINER_PADDING = 8; |
|
|
|
const INNER_CONTAINER_PADDING = 8; |
|
|
|
const visibleLength = (offsetWidth - INNER_CONTAINER_PADDING) / REACTION_CONTAINER_SIZE; |
|
|
|
const visibleLength = (offsetSize - INNER_CONTAINER_PADDING) / REACTION_CONTAINER_SIZE; |
|
|
|
const nextVisiblePart = visibleLength % 1; |
|
|
|
const nextVisiblePart = visibleLength % 1; |
|
|
|
const MIN_NEXT_VISIBLE_PART = 0.65; |
|
|
|
const MIN_NEXT_VISIBLE_PART = 0.65; |
|
|
|
if(nextVisiblePart < MIN_NEXT_VISIBLE_PART) { |
|
|
|
if(nextVisiblePart < MIN_NEXT_VISIBLE_PART) { |
|
|
|
const minWidth = (offsetWidth + (MIN_NEXT_VISIBLE_PART - nextVisiblePart) * REACTION_CONTAINER_SIZE) | 0; |
|
|
|
const minSize = (offsetSize + (MIN_NEXT_VISIBLE_PART - nextVisiblePart) * REACTION_CONTAINER_SIZE) | 0; |
|
|
|
element.style.minWidth = minWidth + 'px'; |
|
|
|
element.style[/* reactionsMenuPosition === 'vertical' ? 'minHeight' : */'minWidth'] = minSize + 'px'; |
|
|
|
} |
|
|
|
} |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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(element);
|
|
|
|
//bubble.parentElement.append(element);
|
|
|
@ -204,7 +206,7 @@ export default class ChatContextMenu { |
|
|
|
if(reactionsMenu) { |
|
|
|
if(reactionsMenu) { |
|
|
|
reactionsMenu.widthContainer.style.top = element.style.top; |
|
|
|
reactionsMenu.widthContainer.style.top = element.style.top; |
|
|
|
reactionsMenu.widthContainer.style.left = element.style.left; |
|
|
|
reactionsMenu.widthContainer.style.left = element.style.left; |
|
|
|
reactionsMenu.widthContainer.style.setProperty('--menu-width', element.offsetWidth + 'px'); |
|
|
|
reactionsMenu.widthContainer.style.setProperty('--menu-width', element[reactionsMenuPosition === 'vertical' ? 'offsetHeight' : 'offsetWidth'] + 'px'); |
|
|
|
element.parentElement.append(reactionsMenu.widthContainer); |
|
|
|
element.parentElement.append(reactionsMenu.widthContainer); |
|
|
|
if(isReactionsMenuVisible) void reactionsMenu.container.offsetLeft; // reflow
|
|
|
|
if(isReactionsMenuVisible) void reactionsMenu.container.offsetLeft; // reflow
|
|
|
|
} |
|
|
|
} |
|
|
@ -603,26 +605,28 @@ export default class ChatContextMenu { |
|
|
|
|
|
|
|
|
|
|
|
let menuPadding: MenuPositionPadding; |
|
|
|
let menuPadding: MenuPositionPadding; |
|
|
|
let reactionsMenu: ChatReactionsMenu; |
|
|
|
let reactionsMenu: ChatReactionsMenu; |
|
|
|
|
|
|
|
let reactionsMenuPosition: 'horizontal' | 'vertical'; |
|
|
|
if(this.message._ === 'message' && !this.chat.selection.isSelecting && !this.message.pFlags.is_outgoing && !this.message.pFlags.is_scheduled) { |
|
|
|
if(this.message._ === 'message' && !this.chat.selection.isSelecting && !this.message.pFlags.is_outgoing && !this.message.pFlags.is_scheduled) { |
|
|
|
const position: 'horizontal' | 'vertical' = (IS_APPLE || IS_TOUCH_SUPPORTED)/* && false */ ? 'horizontal' : 'vertical'; |
|
|
|
reactionsMenuPosition = (IS_APPLE || IS_TOUCH_SUPPORTED)/* && false */ ? 'horizontal' : 'vertical'; |
|
|
|
reactionsMenu = this.reactionsMenu = new ChatReactionsMenu(this.appReactionsManager, position, this.middleware); |
|
|
|
reactionsMenu = this.reactionsMenu = new ChatReactionsMenu(this.appReactionsManager, reactionsMenuPosition, this.middleware); |
|
|
|
reactionsMenu.init(this.appMessagesManager.getGroupsFirstMessage(this.message)); |
|
|
|
reactionsMenu.init(this.appMessagesManager.getGroupsFirstMessage(this.message)); |
|
|
|
// element.prepend(reactionsMenu.widthContainer);
|
|
|
|
// element.prepend(reactionsMenu.widthContainer);
|
|
|
|
|
|
|
|
|
|
|
|
const size = 42; |
|
|
|
const size = 36; |
|
|
|
const margin = 8; |
|
|
|
const margin = 8; |
|
|
|
const totalSize = size + margin; |
|
|
|
const totalSize = size + margin; |
|
|
|
if(position === 'vertical') { |
|
|
|
const paddingLeft = 0, paddingRight = 0; |
|
|
|
|
|
|
|
if(reactionsMenuPosition === 'vertical') { |
|
|
|
menuPadding = { |
|
|
|
menuPadding = { |
|
|
|
top: 24, |
|
|
|
top: paddingLeft, |
|
|
|
// bottom: 36, // positionMenu will detect it itself somehow
|
|
|
|
// bottom: 36, // positionMenu will detect it itself somehow
|
|
|
|
left: totalSize |
|
|
|
left: totalSize |
|
|
|
}; |
|
|
|
}; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
menuPadding = { |
|
|
|
menuPadding = { |
|
|
|
top: totalSize, |
|
|
|
top: totalSize, |
|
|
|
right: 36, |
|
|
|
right: paddingRight, |
|
|
|
left: 24 |
|
|
|
left: paddingLeft |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -640,7 +644,8 @@ export default class ChatContextMenu { |
|
|
|
reactionsMenu.widthContainer.remove(); |
|
|
|
reactionsMenu.widthContainer.remove(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
menuPadding, |
|
|
|
menuPadding, |
|
|
|
reactionsMenu |
|
|
|
reactionsMenu, |
|
|
|
|
|
|
|
reactionsMenuPosition |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|