All Projects → taye → Interact.js

taye / Interact.js

Licence: mit
JavaScript drag and drop, resizing and multi-touch gestures with inertia and snapping for modern browsers (and also IE9+)

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
shell
77523 projects

Projects that are alternatives of or similar to Interact.js

Smooth Dnd
drag and drop library for javascript
Stars: ✭ 408 (-96.14%)
Mutual labels:  drag-and-drop, drop, vanilla
Keen Slider
The HTML touch slider carousel with the most native feeling
Stars: ✭ 3,097 (-70.68%)
Mutual labels:  mobile, touch, vanilla
Embla Carousel
A lightweight carousel library with fluid motion and great swipe precision.
Stars: ✭ 1,874 (-82.26%)
Mutual labels:  mobile, touch, vanilla
React Fastclick
Fast Touch Events for React
Stars: ✭ 476 (-95.49%)
Mutual labels:  mobile, touch
Better Gesture
A gesture library use for pc, mobile, vue, and mini programs
Stars: ✭ 419 (-96.03%)
Mutual labels:  mobile, touch
Dragula
👌 Drag and drop so simple it hurts
Stars: ✭ 21,011 (+98.95%)
Mutual labels:  drag-and-drop, vanilla
Framework7
Full featured HTML framework for building iOS & Android apps
Stars: ✭ 16,560 (+56.8%)
Mutual labels:  mobile, touch
Swiper
Most modern mobile touch slider with hardware accelerated transitions
Stars: ✭ 29,519 (+179.51%)
Mutual labels:  mobile, touch
Sortable
Reorderable drag-and-drop lists for modern browsers and touch devices. No jQuery or framework required.
Stars: ✭ 23,641 (+123.85%)
Mutual labels:  drag-and-drop, touch
Gong Wpf Dragdrop
The GongSolutions.WPF.DragDrop library is a drag'n'drop framework for WPF
Stars: ✭ 1,669 (-84.2%)
Mutual labels:  drag-and-drop, drop
React Smooth Dnd
react wrapper components for smooth-dnd
Stars: ✭ 1,560 (-85.23%)
Mutual labels:  drag-and-drop, drop
Vue Smooth Dnd
Vue wrapper components for smooth-dnd
Stars: ✭ 1,121 (-89.39%)
Mutual labels:  drag-and-drop, drop
React Easy Swipe
Easy handler for common swipe operations
Stars: ✭ 85 (-99.2%)
Mutual labels:  mobile, touch
Vue Gallery
📷 Responsive and customizable image and video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers.
Stars: ✭ 405 (-96.17%)
Mutual labels:  mobile, touch
Kddraganddropcollectionview
This component allows for the transfer of data items between collection views through drag and drop
Stars: ✭ 476 (-95.49%)
Mutual labels:  drag-and-drop, drop
Croppr.js
A vanilla JavaScript image cropper that's lightweight, awesome, and has absolutely zero dependencies.
Stars: ✭ 294 (-97.22%)
Mutual labels:  touch, vanilla
Trip
移动前端开发经验指南
Stars: ✭ 550 (-94.79%)
Mutual labels:  mobile, touch
Hover On Touch
A pure Javascript Plugin for an alternative hover function that works on mobile and desktop devices. It triggers a hover css class on »Taphold« and goes to a possible link on »Tap«. It works with all html elements.
Stars: ✭ 256 (-97.58%)
Mutual labels:  mobile, touch
Cupertino Pane
🎉📱Multi-functional panes and boards for next generation progressive applications
Stars: ✭ 267 (-97.47%)
Mutual labels:  mobile, touch
Ng2 Dnd
Angular 2 Drag-and-Drop without dependencies
Stars: ✭ 861 (-91.85%)
Mutual labels:  drag-and-drop, drop

interact.js

JavaScript drag and drop, resizing and multi-touch gestures with inertia and snapping for modern browsers (and also IE9+).

Gitter jsDelivr Build Status

Features include:

  • inertia and snapping
  • multi-touch, simultaneous interactions
  • cross browser and device, supporting the desktop and mobile versions of Chrome, Firefox and Opera as well as Internet Explorer 9+
  • interaction with SVG elements
  • being standalone and customizable
  • not modifying the DOM except to change the cursor (but you can disable that)

Installation

  • npm: npm install interactjs
  • jsDelivr CDN: <script src="https://cdn.jsdelivr.net/npm/interactjs/dist/interact.min.js"></script>
  • unpkg CDN: <script src="https://unpkg.com/interactjs/dist/interact.min.js"></script>
  • Rails 5.1+:
    1. yarn add interactjs
    2. //= require interactjs/interact
  • Webjars SBT/Play 2: libraryDependencies ++= Seq("org.webjars.npm" % "interactjs" % version)

Typescript definitions

The project is written in Typescript and the npm package includes the type definitions, but if you need the typings alone, you can install them with:

npm install --save-dev @interactjs/types

Documentation

http://interactjs.io/docs

Example

var pixelSize = 16;

interact('.rainbow-pixel-canvas')
  .origin('self')
  .draggable({
    modifiers: [
      interact.modifiers.snap({
        // snap to the corners of a grid
        targets: [
          interact.snappers.grid({ x: pixelSize, y: pixelSize }),
        ],
      })
    ],
    listeners: {
      // draw colored squares on move
      move: function (event) {
        var context = event.target.getContext('2d'),
            // calculate the angle of the drag direction
            dragAngle = 180 * Math.atan2(event.dx, event.dy) / Math.PI;

        // set color based on drag angle and speed
        context.fillStyle = 'hsl(' + dragAngle + ', 86%, '
                            + (30 + Math.min(event.speed / 1000, 1) * 50) + '%)';

        // draw squares
        context.fillRect(event.pageX - pixelSize / 2, event.pageY - pixelSize / 2,
                         pixelSize, pixelSize);
      }
    }
  })
  // clear the canvas on doubletap
  .on('doubletap', function (event) {
    var context = event.target.getContext('2d');

    context.clearRect(0, 0, context.canvas.width, context.canvas.height);
  });

  function resizeCanvases () {
    [].forEach.call(document.querySelectorAll('.rainbow-pixel-canvas'), function (canvas) {
      canvas.width = document.body.clientWidth;
      canvas.height = window.innerHeight * 0.7;
    });
  }

  // interact.js can also add DOM event listeners
  interact(document).on('DOMContentLoaded', resizeCanvases);
  interact(window).on('resize', resizeCanvases);

See the above code in action at https://codepen.io/taye/pen/tCKAm

License

interact.js is released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].