client/src/mixins/BaseCollection.vue
Artem Anufrij 3af8005786 move
2023-02-08 12:37:55 +01:00

29 lines
679 B
Vue

<script>
export default {
props: {
item: { covers: {} },
},
methods: {
scrollFunction() {
let element = document.getElementById(this.item._id);
let bounding = element.getBoundingClientRect();
let scrollDown = bounding.top < 56;
let scrollUp =
bounding.top + bounding.height >
(window.innerHeight || document.documentElement.clientHeight);
if (scrollDown) {
element.scrollIntoView({
behavior: "smooth",
block: "start",
});
} else if (scrollUp) {
element.scrollIntoView({
behavior: "smooth",
block: "end",
});
}
},
},
};
</script>