vue-drag-select icon indicating copy to clipboard operation
vue-drag-select copied to clipboard

Not work properly with 'simplebar'

Open dev-jonghoonpark opened this issue 5 years ago • 2 comments

Not work properly with 'simplebar'

the drag area is not holded when scroll. drag area work like 'fixed'. so it select new item without old item.

simplebar : https://github.com/Grsmto/simplebar

for test you should install simplebar

npm install --save simplebar-vue

and this is the code for testing

<template>
  <div class="app">
    <h1>Vue Drag Select Example</h1>
    <simple-bar>
        <drag-select-container selectorClass="item">
          <template slot-scope="{ selectedItems }">
            <div
              v-for="item in 50"
              :key="item"
              :class="getClasses(item, selectedItems)"
              :data-item="item"
            >
              Item {{ item }}
            </div>
          </template>
        </drag-select-container>
    </simple-bar>
  </div>
</template>

<script>
import DragSelect from "vue-drag-select";

import SimpleBar from 'simplebar-vue';
import 'simplebar/dist/simplebar.css';

export default {
  name: "home",

  components: {
    SimpleBar,
    "drag-select-container": DragSelect
  },

  methods: {
    getClasses(item, selectedItems) {
      const isActive = !!selectedItems.find(selectedItem => {
        return parseInt(selectedItem.dataset.item, 10) === item;
      });

      return {
        item: true,
        active: isActive
      };
    }
  }
};
</script>

<style>
/* skiped other css in example */
.simplebar-wrapper {
    max-height: 500px;
}
</style>

thanks...

dev-jonghoonpark avatar Sep 24 '19 05:09 dev-jonghoonpark

Hi there, thank you for taking the time to report this issue!

Looking through the documentation of simplebar, I noticed that it's not intended to be used on the body element. Currently, Vue Drag Select looks for scroll positions in the drag-select-container, falling back to document.body. It does not detect the scroll position in the parent (in this case the simplebar component).

I suppose we could add a prop that allows you to specify what scroll container to listen to. Would that work for you?

stephan281094 avatar Sep 27 '19 10:09 stephan281094

Yes. I think that would work to me. thanks! :>

dev-jonghoonpark avatar Sep 28 '19 07:09 dev-jonghoonpark