vue-scrollmonitor icon indicating copy to clipboard operation
vue-scrollmonitor copied to clipboard

Container prop for scroll-container

Open VictorGa opened this issue 7 years ago • 2 comments

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!!

VictorGa avatar Nov 21 '17 11:11 VictorGa

It's currently impossible but I'll def try to bring a solution to your usecase.

AlexandreBonaventure avatar Nov 21 '17 17:11 AlexandreBonaventure

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>

vdcrea avatar Aug 06 '18 08:08 vdcrea