mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
fix the bug with scrolling post comments into view
This commit is contained in:
parent
9eb90eea8d
commit
50feeed8bf
@ -47,6 +47,33 @@ export default {
|
|||||||
return comment.id === updatedComment.id ? updatedComment : comment
|
return comment.id === updatedComment.id ? updatedComment : comment
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
scrollCommentsIntoView() {
|
||||||
|
if (!window || !document) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const container = document.getElementById('comments')
|
||||||
|
if (container) {
|
||||||
|
const top = container.offsetTop
|
||||||
|
window.scroll({
|
||||||
|
top,
|
||||||
|
left: 0,
|
||||||
|
behavior: 'smooth',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
$route(to, from) {
|
||||||
|
// scroll inside the same page
|
||||||
|
if (to.hash === '#comments') {
|
||||||
|
this.scrollCommentsIntoView()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if (this.$route.hash === '#comments') {
|
||||||
|
setTimeout(this.scrollCommentsIntoView, 250)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -77,17 +77,6 @@ export default {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
$route(to, from) {
|
|
||||||
if (to.hash === '#comments') {
|
|
||||||
window.scroll({
|
|
||||||
top: document.getElementById('comments').offsetTop,
|
|
||||||
left: 0,
|
|
||||||
behavior: 'smooth',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -193,7 +193,7 @@ export default {
|
|||||||
|
|
||||||
.ds-card-image {
|
.ds-card-image {
|
||||||
img {
|
img {
|
||||||
max-height: 300px;
|
height: 300px;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
object-position: center;
|
object-position: center;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user