JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.min.js"></script>
<div id="root">
<div ref="list" class="list">
<div class="message" :key="hui.id" v-for="hui in pizda">{{ hui.id }}</div>
<div ref="sentinel"></div>
</div>
</div
</div>
CSS
.list {
height: 200px;
overflow: auto;
}
.message {
font-size: 30px;
line-height: 50px;
border-bottom: 1px solid #777;
}
JavaScript
new Vue({
el: '#root',
data: {
pizda: []
},
mounted () {
const { list, sentinel } = this.$refs;
const options = {
root: list
};
const io = new IntersectionObserver(([entry]) => {
if (!entry.isIntersecting) {
list.scrollTop = list.scrollHeight;
}
}, options);
io.observe(sentinel);
setInterval(this.pushPizda, 1000);
},
methods: {
pushPizda() {
this.pizda.push({
id: this.pizda.length + 1,
});
},
}
})