vue-scrollmonitor
vue-scrollmonitor copied to clipboard
Container prop for scroll-container
Hello!
I've been trying to pass a different container to the scroll-container with no luck. Looking at the code, it seems that the container (dom element) needs to be when creating the scroll-container.
My scroll-container is inside of a component, and the container I want to pass as props is the $el of that component itself.
Is it possible to pass a new container once the scroll-container is created? Or halt the creation untill the new container is accessible?
Thanks for the work!!
It's currently impossible but I'll def try to bring a solution to your usecase.
I had the same issue, as a workaround you can wrap the scrolling component in a parent's div, and pass its node via data:
parent.vue
<template>
<div id="container">
<Child />
</div>
</template>
<script>
import Child from './child'
export default {
components: {
child
}
}
</script>
child.vue
<template>
<ScrollContainer :container="container">
<ScrollItem />
</ScrollContainer>
</template>
<script>
export default {
data () {
container: document.getElementById('container')
}
}
</script>