Skip to content
Snippets Groups Projects
Commit c72e847b authored by Liam Coursodon's avatar Liam Coursodon Committed by Sébastien Blin
Browse files

Emoji Picker: correct position

GitLab: #1431

Change-Id: I5d86598da3120df5b34b375e1019bb0d0c8d88f0
parent 74120737
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ BaseContextMenu {
property bool closeWithoutAnimation: false
property var emojiPicker
function xPositionProvider(width) {
function xPosition(width) {
// Use the width at function scope to retrigger property evaluation.
const listViewWidth = listView.width;
const parentX = parent.x;
......@@ -51,9 +51,30 @@ BaseContextMenu {
}
}
x: xPositionProvider(width)
x: xPosition(width)
y: parent.y
function xPositionProvider(width) {
// Use the width at function scope to retrigger property evaluation.
const listViewWidth = listView.width;
if (isOutgoing) {
return -5 - width;
} else {
const rightMargin = listViewWidth - (msgBubble.x + width);
return width > rightMargin + 35 ? -5 - width : 35;
}
}
function yPositionProvider(height) {
const topOffset = msgBubble.mapToItem(listView, 0, 0).y;
const listViewHeight = listView.height;
const bottomMargin = listViewHeight - height - topOffset;
if (bottomMargin < 0 || (topOffset < 0 && topOffset + height > 0)) {
return 30 - height;
} else {
return 0;
}
}
signal addMoreEmoji
onAddMoreEmoji: {
JamiQmlUtils.updateMessageBarButtonsPoints();
......@@ -74,7 +95,6 @@ BaseContextMenu {
});
if (emojiPicker !== null) {
root.opacity = 0;
emojiPicker.closed.connect(() => close());
emojiPicker.x = xPositionProvider(JamiTheme.emojiPickerWidth);
emojiPicker.y = yPositionProvider(JamiTheme.emojiPickerHeight);
emojiPicker.open();
......@@ -83,11 +103,8 @@ BaseContextMenu {
}
}
// Close the picker when listView vertical properties change.
property real listViewHeight: listView.height
onListViewHeightChanged: close()
property bool isScrolling: listView.verticalScrollBar.active
onIsScrollingChanged: close()
onOpened: root.closeWithoutAnimation = false
onClosed: if (emojiPicker)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment