댓글 검색 목록

[javascript] Selecto.js는 드래그 영역에서 마우스 나 터치로 요소를 선택할 수 있는 컴포넌트

페이지 정보

작성자 운영자 작성일 20-08-31 10:12 조회 713 댓글 0

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");
    });
});




댓글목록 0

등록된 댓글이 없습니다.

웹학교 로고

온라인 코딩학교

코리아뉴스 2001 - , All right reserved.