FIX: Position emoji-picker around d-editor.

This commit is contained in:
Bianca Nenciu 2019-05-26 18:40:36 +03:00 committed by Guo Xiang Tan
parent 7a08e23b4b
commit 43e33302e1

View File

@ -514,6 +514,7 @@ export default Ember.Component.extend({
const desktopPositioning = options => { const desktopPositioning = options => {
let attributes = { let attributes = {
position: "fixed",
width: windowWidth < 485 ? windowWidth - 12 : 400, width: windowWidth < 485 ? windowWidth - 12 : 400,
marginLeft: "", marginLeft: "",
marginTop: "", marginTop: "",
@ -562,12 +563,30 @@ export default Ember.Component.extend({
if (windowWidth < 485) { if (windowWidth < 485) {
desktopModalePositioning(); desktopModalePositioning();
} else { } else {
let previewInputOffset = $(".d-editor-input").offset(); const previewInputOffset = $(".d-editor-input").offset();
let left = previewInputOffset.left;
const pickerHeight = $(".emoji-picker").height();
const editorHeight = $(".d-editor-input").height();
const windowBottom = $(window).scrollTop() + $(window).height();
if (
previewInputOffset.top + editorHeight + pickerHeight <
windowBottom
) {
// position it below editor if there is enough space
desktopPositioning({ desktopPositioning({
left, position: "absolute",
bottom: $("#reply-control").height() - 45 top: previewInputOffset.top + editorHeight,
left: previewInputOffset.left
}); });
} else {
// try positioning it above
desktopPositioning({
position: "absolute",
top: -pickerHeight,
left: previewInputOffset.left
});
}
} }
} }
} }