Skip to content

Commit

Permalink
Merge pull request #71 from Freegle/feature/v-observe-visibility-dire…
Browse files Browse the repository at this point in the history
…ctive-improvement

feat: custom v-observe-visibility directive
  • Loading branch information
edwh authored Feb 22, 2024
2 parents 7d56be5 + e26d6e3 commit 0a84d95
Show file tree
Hide file tree
Showing 6 changed files with 11,848 additions and 6,062 deletions.
2 changes: 1 addition & 1 deletion components/InfiniteLoading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:key="bump"
v-observe-visibility="{
callback: visibilityChanged,
intersection: {
options: {
rootMargin: '0px 0px ' + distance + 'px 0px',
},
}"
Expand Down
15 changes: 11 additions & 4 deletions components/MessageSummary.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<template>
<div v-if="message" :id="'msg-' + id" class="position-relative">
<div
v-if="message"
:id="'msg-' + id"
v-observe-visibility="{
callback: view,
options: {
observeFullElement: true,
},
}"
class="position-relative"
>
<template v-if="message.successful">
<MessageFreegled :id="id" />
</template>
Expand Down Expand Up @@ -52,7 +62,6 @@
/>
</div>
</div>
<div v-observe-visibility="view" />
</div>
</template>

Expand Down Expand Up @@ -125,8 +134,6 @@ export default {
if (this.me && this.message.unseen) {
await this.messageStore.view(this.id)
}
this.$emit('view')
},
expand() {
this.$emit('expand')
Expand Down
6 changes: 0 additions & 6 deletions components/OurMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
@hidden="expanded = false"
/>
</div>
<div v-observe-visibility="visibilityChanged" />
</div>
</template>

Expand Down Expand Up @@ -278,11 +277,6 @@ export default {
this.$emit('view')
}
},
visibilityChanged(vis) {
if (vis) {
this.$emit('visible', this.id)
}
},
},
}
</script>
Loading

0 comments on commit 0a84d95

Please sign in to comment.