Heart reaction: dynamic postion

This commit is contained in:
10G Meow 2024-06-08 13:42:57 +03:00
parent 134b1f8cff
commit f1c12663c8
2 changed files with 24 additions and 10 deletions

View file

@ -86,7 +86,7 @@
showMoreMessageOperations({event: event, anchor: $event.anchor}) showMoreMessageOperations({event: event, anchor: $event.anchor})
" "
v-on:layout-change="onLayoutChange" v-on:layout-change="onLayoutChange"
v-on:addQuickHeartReaction="addQuickHeartReaction(event)" v-on:addQuickHeartReaction="addQuickHeartReaction({event, position: $event.position})"
/> />
<!-- <div v-if="debugging" style="user-select:text">EventID: {{ event.getId() }}</div> --> <!-- <div v-if="debugging" style="user-select:text">EventID: {{ event.getId() }}</div> -->
<!-- <div v-if="debugging" style="user-select:text">Event: {{ JSON.stringify(event) }}</div> --> <!-- <div v-if="debugging" style="user-select:text">Event: {{ JSON.stringify(event) }}</div> -->
@ -333,7 +333,9 @@
<!-- PURGE ROOM POPUP --> <!-- PURGE ROOM POPUP -->
<PurgeRoomDialog :show="showPurgeConfirmation" :room="room" @close="showPurgeConfirmation = false" /> <PurgeRoomDialog :show="showPurgeConfirmation" :room="room" @close="showPurgeConfirmation = false" />
<div :class="['heart-wrapper', { 'is-active': heartAnimation }]">
<!-- Heart animation -->
<div :class="['heart-wrapper', { 'is-active': heartAnimation }]" :style="hearAnimationPosition">
<div :class="['heart', { 'is-active': heartAnimation }]" /> <div :class="['heart', { 'is-active': heartAnimation }]" />
</div> </div>
</div> </div>
@ -506,7 +508,11 @@ export default {
retentionTimer: null, retentionTimer: null,
showProfileDialog: false, showProfileDialog: false,
showPurgeConfirmation: false, showPurgeConfirmation: false,
heartAnimation: false heartAnimation: false,
heartPosition: {
top: 0,
left: 0
}
}; };
}, },
@ -781,6 +787,12 @@ export default {
.filter((e) => util.downloadableTypes().includes(e.getContent().msgtype)).length}); .filter((e) => util.downloadableTypes().includes(e.getContent().msgtype)).length});
} }
return ""; return "";
},
hearAnimationPosition() {
return {
'--top': this.heartPosition.top,
'--left': this.heartPosition.left
};
} }
}, },
@ -1586,8 +1598,9 @@ export default {
this.sendQuickReaction({ reaction: e.emoji, event: e.event }); this.sendQuickReaction({ reaction: e.emoji, event: e.event });
}, },
addQuickHeartReaction(event) { addQuickHeartReaction(e) {
this.sendQuickReaction({ reaction: this.heartEmoji, event }, true); this.heartPosition = e.position
this.sendQuickReaction({ reaction: this.heartEmoji, event: e.event }, true);
}, },
setReplyToImage(event) { setReplyToImage(event) {
@ -1944,9 +1957,6 @@ export default {
@import "@/assets/css/chat.scss"; @import "@/assets/css/chat.scss";
.heart-wrapper { .heart-wrapper {
position: fixed; position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: -1; z-index: -1;
.heart { .heart {
@ -1969,6 +1979,8 @@ export default {
} }
&.is-active { &.is-active {
z-index: 1000; z-index: 1000;
top: var(--top);
left: var(--left);
} }
} }
</style> </style>

View file

@ -333,8 +333,10 @@ export default {
this.mcCustom.add(new Hammer.Tap({ event: 'doubletap', taps: 2 })); this.mcCustom.add(new Hammer.Tap({ event: 'doubletap', taps: 2 }));
this.mcCustom.on("doubletap", () => { this.mcCustom.on("doubletap", (evt) => {
this.$emit("addQuickHeartReaction"); var { top, left } = evt.target.getBoundingClientRect();
var position = { top: `${top}px`, left: `${left}px`};
this.$emit("addQuickHeartReaction", { position });
}); });
this.mc.on("press", () => { this.mc.on("press", () => {