Thanks to visit codestin.com
Credit goes to Github.com

Skip to content
forked from simonwep/viselect

✨ Viselect - A high performance and lightweight library to add a visual way of selecting elements, just like on your Desktop. Zero dependencies, super small. Support for major frameworks!

License

Notifications You must be signed in to change notification settings

knotxjs/viselect

 
 

Repository files navigation

Logo

Visual dom-selection library

License MIT No dependencies Support me version Buy me a coffee Build Status Docs gzip size brotli size Vue support Preact support React support

demo gif

Forked Change

viselect now supports virtual scrolling. You can customize scroll position retrieval and setting methods through the scrollController option:

import SelectionArea from '@knotx/viselect';

// Create a selection area with virtual scrolling support
const selection = new SelectionArea({
  // Other options...
  
  // Custom scroll controller
  scrollController: {
    // Custom method to get scroll position
    getScrollPosition: (element) => {
      // If element is a virtual scroll container, return virtual scroll position
      if (element.classList.contains('virtual-scroll-container')) {
        return {
          x: yourVirtualScrollInstance.scrollLeft,
          y: yourVirtualScrollInstance.scrollTop
        };
      }
      
      // Otherwise return native scroll position
      return {
        x: element.scrollLeft,
        y: element.scrollTop
      };
    },
    
    // Custom method to set scroll position
    setScrollPosition: (element, position) => {
      // If element is a virtual scroll container, set virtual scroll position
      if (element.classList.contains('virtual-scroll-container')) {
        if (position.x !== undefined) {
          yourVirtualScrollInstance.scrollLeft = position.x;
        }
        if (position.y !== undefined) {
          yourVirtualScrollInstance.scrollTop = position.y;
        }
        return;
      }
      
      // Otherwise set native scroll position
      if (position.x !== undefined) {
        element.scrollLeft = position.x;
      }
      if (position.y !== undefined) {
        element.scrollTop = position.y;
      }
    },
    
    // Custom method to get scroll size (total scrollable area)
    getScrollSize: (element) => {
      if (element.classList.contains('virtual-scroll-container')) {
        return {
          width: yourVirtualScrollInstance.scrollWidth,
          height: yourVirtualScrollInstance.scrollHeight
        };
      }
      
      return {
        width: element.scrollWidth,
        height: element.scrollHeight
      };
    },
    
    // Custom method to get client size (visible area)
    getClientSize: (element) => {
      if (element.classList.contains('virtual-scroll-container')) {
        return {
          width: yourVirtualScrollInstance.clientWidth,
          height: yourVirtualScrollInstance.clientHeight
        };
      }
      
      return {
        width: element.clientWidth,
        height: element.clientHeight
      };
    }
  }
});

Features 🤘

  • 🌟 Modern bundle
  • 🔩 Ultra tiny (~4kb)
  • 👌 Simple usage
  • ⚡ Highly optimized
  • ✔ Zero dependencies
  • 📱 Mobile / touch support
  • 🖱 Vertical and horizontal scroll support
  • 💪 Battle tested (over 6 years old and used in many apps)

Getting started

Head over to the documentation to get started 🚀

You want to contribute?

That's awesome! Check out the contribution guidelines to get started :)

About

✨ Viselect - A high performance and lightweight library to add a visual way of selecting elements, just like on your Desktop. Zero dependencies, super small. Support for major frameworks!

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 81.9%
  • CSS 9.5%
  • Vue 4.3%
  • HTML 2.4%
  • JavaScript 1.9%