Selecto.js는 드래그 영역에서 마우스 나 터치로 요소를 선택할 수 있는 컴포넌트입니다.
https://github.com/daybrush/selecto
<script src="//daybrush.com/selecto/release/latest/dist/selecto.min.js"></script>
import Selecto from "selecto"; const selecto = new Selecto({ // The container to add a selection element container: document.body, // The area to drag selection element (default: container) dragContainer: Element, // Targets to select. You can register a queryselector or an Element. selectableTargets: [".target", document.querySelector(".target2")], // Whether to select by click (default: true) selectByClick: true, // Whether to select from the target inside (default: true) selectFromInside: true, // After the select, whether to select the next target with the selected target (deselected if the target is selected again). continueSelect: false, // Determines which key to continue selecting the next target via keydown and keyup. toggleContinueSelect: "shift", // The container for keydown and keyup events keyContainer: window, // The rate at which the target overlaps the drag area to be selected. (default: 100) hitRate: 100, }); selecto.on("select", e => { e.added.forEach(el => { el.classList.add("selected"); }); e.removed.forEach(el => { el.classList.remove("selected"); }); });
등록된 댓글이 없습니다.