npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@progress/kendo-draggable

v3.1.0

Published

A cross-browser/event abstraction that handles mouse and touch drag sequences

Downloads

362,035

Readme

Commitizen friendly

Kendo UI Draggable

A repository for the cross-platform abstraction for drag sequences.

Overview

The Kendo UI Draggable component handles mouse drags and touch sequences on mobile devices.

A drag sequence means:

  • Mouse click, drag, release for desktop devices.
  • Touch press, drag, release for mobile devices.

Installation

The library is published as a scoped NPM package in the NPMJS Telerik account.

npm install --save '@progress/kendo-draggable';

Basic Usage

The draggable class constructor accepts an object with three optional event handler callbacks—press, drag, and release.

import Draggable from '@progress/kendo-draggable';

const draggable = new Draggable({
    press: function(e) {
        console.log("pressed", e.pageX, e.pageY);
    },
    drag: function(e) {
        console.log("drag", e.pageX, e.pageY);
    },
    release: function(e) {
        console.log("release", e.pageX, e.pageY);
    }
});

draggable.bindTo(document.getElementById("my-element"));

The Draggable may be re-bound to another element—the event handlers will be automatically unbound from the previous one.

draggable.bindTo(document.getElementById("another-element"));

The draggable object persists a reference to the currently bound element. That is why it should be destroyed when or if the corresponding element is removed from the document.

draggable.destroy();

Features

The Kendo UI Draggable supports:

  • Mouse events
  • Touch events
  • Pointer events
  • Handling of multiple touches. Rather, not getting confused by them.

Dragging on iOS/Android

Handling the drag sequence on mobile devices may require the disabling of the touch-based scrolling. The Draggable will not do that out of the box. The recommended way to handle this issue is by setting a touch-action CSS property. Depending on the type of drags that are handled, you may need touch-action: none, touch-action: pan-y, or touch-action: pan-x.

The touch-action setting does not work for iOS yet. While the iOS 9.3 version, which has been released recently, provides limited support, pan-x and pan-y do not work. To disable the touch-based scrolling in iOS, prevent the touchstart event:

    <div ontouchstart="return false">
        <div id="my-draggable-element"></div>
    </div>

Preventing Selection

The dragging of elements that contain text activates the browser text selection, which, in most cases, is not desirable. To avoid this behavior, use the user-select: none CSS property with its respective browser prefixes.

Mouse-Only mode

To ignore all touch and pointer events, set mouseOnly to true. This is useful when you want to keep the default touch-drag behavior, e.g. horizontal scroll.

import Draggable from '@progress/kendo-draggable';

const draggable = new Draggable({
    mouseOnly: true,
    press: function(e) {
        console.log("pressed", e.pageX, e.pageY);
    },
    drag: function(e) {
        console.log("drag", e.pageX, e.pageY);
    },
    release: function(e) {
        console.log("release", e.pageX, e.pageY);
    }
});

draggable.bindTo(document.getElementById("my-element"));

Browser Support

  • Google Chrome
  • Firefox
  • Safari (OS X)
  • Safari (iOS)
  • Chrome (Android)
  • IE/Edge