diff --git a/JYeontuComponentWarehouse/examples/views/componentShowViews/JCommentView.vue b/JYeontuComponentWarehouse/examples/views/componentShowViews/JCommentView.vue index 67cbd8a011cc02c33c4b024f250acbda02b48563..365d859e5f1cd1c49eccdc406a969ec21db1a499 100644 --- a/JYeontuComponentWarehouse/examples/views/componentShowViews/JCommentView.vue +++ b/JYeontuComponentWarehouse/examples/views/componentShowViews/JCommentView.vue @@ -15,6 +15,7 @@ :showNumber="2" :comment-datas="commentDatas" :orderBy="'create_time'" + :useEmoji="true" @submitComment="submitComment" > @@ -182,6 +183,12 @@ export default { type: "Boolean", describe: "默认为true" }, + { + parameter: "useEmoji", + field: "是否使用表情", + type: "Boolean", + describe: "默认为true" + }, { parameter: "orderBy", field: "排序字段(时间)", diff --git a/JYeontuComponentWarehouse/packages/JComment/src/JComment.vue b/JYeontuComponentWarehouse/packages/JComment/src/JComment.vue index 5d6133087fd692e3e02535db866ade824eb296ae..b4fdefc6cf43459bc779e564b9dfb770b1be7633 100644 --- a/JYeontuComponentWarehouse/packages/JComment/src/JComment.vue +++ b/JYeontuComponentWarehouse/packages/JComment/src/JComment.vue @@ -20,6 +20,7 @@ >
{ @@ -280,11 +287,13 @@ export default { lastLength: 0, showItem: [], showVEmojiPicker: false, - emojiTextId: "" + emojiTextId: "", + scrollTop: 0 }; }, created() { this.initData(); + this.initListen(); }, watch: { commentDatas() { @@ -293,6 +302,17 @@ export default { }, computed: {}, methods: { + initListen() { + window.onscroll = function() { + var scrollTop = + document.documentElement.scrollTop || + document.body.scrollTop; + let v = document.getElementById("v-emoji-picker"); + v.style.top = + parseInt(v.style.top) - (scrollTop - this.scrollTop) + "px"; + this.scrollTop = scrollTop; + }; + }, // 表情转码 utf16toEntities(str) { const patt = /[\ud800-\udbff][\udc00-\udfff]/g; // 检测utf16字符正则 @@ -335,8 +355,11 @@ export default { }, showEmoji(el) { let v = document.getElementById("v-emoji-picker"); - v.style.left = el.pageX + 5 + "px"; - v.style.top = el.pageY + 5 + "px"; + const srcElement = el.srcElement; + v.style.left = el.x + 5 + "px"; + v.style.top = el.y + 5 + "px"; + this.scrollTop = + document.documentElement.scrollTop || document.body.scrollTop; this.showVEmojiPicker = !this.showVEmojiPicker; this.emojiTextId = el.target.id; }, @@ -542,8 +565,9 @@ export default { text-align: left; width: 80%; padding: 1rem; + position: relative; #v-emoji-picker { - position: absolute; + position: fixed; } .j-comment-content { width: 100%;