1.10.27 • Published 8 months ago

interactjs v1.10.27

Weekly downloads
101,255
License
MIT
Repository
github
Last release
8 months ago

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.

vue-pithy-cropper@pubngo-stack/reservation-api-browser@spongelearning/widget-layout@epicor/kineticvtsl-grid-layoutconcretecms-bedrockanole_grid_layoutrevogridvda_vuevuegridlayout-scalecompatibilityvue-grid-layout-copy@mindhiveoy/react-timelinegrapher-tsfz-opmap-helpervue-3-interactapp-junwu-testjunwu-cover-editorhot-zone-img@nowams/verovioscoreeditoravrorajs@avrora/avb@avrora/engineqx-componentsdesign_editor_poc@clockbook-app/schedule-module-browser@clockbook-app/schedule-moduler-browser@clockbook-app/timetracker-module-browserng5-grid-layout@infinitebrahmanuniverse/nolb-interaasp-grid-layout1hotfusionftms-fe-common-componentspds-formmakingpds-componentsverovioscoreeditor@everything-registry/sub-chunk-1921literax-pdf-viewertbrowsetengits-spreadsheetsvelte-zooming-uiterriajsvue-layout-gridvue-annotatorvue-annotator2vue-interactvue-interact-altvue-interactjsweditorjsxlink-legoxlink-lego-biguiyuanxlink-lego1xinli-roomkit-web-vue2.7xinli-roomkit-web-vue3xl-jgrm-element-prowxw-grid-layoutwylibshayder-pacsandboxshotsegelshipthis-pdfxrer3d-terriajsrealmail-extensionsreacthub-timeline-editorteamcosuper-duper-renderersplorroom-uikit-web-vue3rejst-mentalsword-testing00rejst-mentalsword-testing02rejst-mentalsword-testing03svelte-polaroidssv-printthree-guitoolsthn-componentsvue-grid-layout-eoivue-grid-layout-exvue-grid-layout-for3vue-grid-layout-forkvue-grid-layout-fork-updatevue-grid-layout-specific-configs-to-resizevue-grid-layout-xvue-grid-provue-grid-layout-itemvue-grid-layout-jackvue-grid-layout-nextvue-grid-layout-scalevue-circle-avatarvibe-editorvoyager-componentsrejst-mentalsword-testing01ovp-uimlrcbsousa-grid-layout-pluslj-grid-layout-v3lb-glloongtex-codehalley-kitgrid-dashboard-frameworkgridplusgrid-layout-vuegrid-layout-vue3
1.10.27

8 months ago

1.10.26

12 months ago

1.10.24

12 months ago

1.10.25

12 months ago

1.10.22

12 months ago

1.10.23

12 months ago

1.10.20

1 year ago

1.10.21

1 year ago

1.10.19

1 year ago

1.10.18

1 year ago

1.10.15

2 years ago

1.10.16

2 years ago

1.10.13

2 years ago

1.10.14

2 years ago

1.10.12

2 years ago

1.10.17

2 years ago

1.10.11

4 years ago

1.10.10

4 years ago

1.10.9

4 years ago

1.10.8

4 years ago

1.10.7

4 years ago

1.10.6

4 years ago

1.10.5

4 years ago

1.10.4

4 years ago

1.10.3

4 years ago

1.10.2

4 years ago

1.10.1

4 years ago

1.10.0

4 years ago

1.9.22

4 years ago

1.9.21

4 years ago

1.9.20

4 years ago

1.9.19

4 years ago

1.9.18

4 years ago

1.9.17

5 years ago

1.9.16

5 years ago

1.9.15

5 years ago

1.9.14

5 years ago

1.9.13

5 years ago

1.9.12

5 years ago

1.9.11

5 years ago

1.9.10

5 years ago

1.9.9

5 years ago

1.9.8

5 years ago

1.9.7

5 years ago

1.9.6

5 years ago

1.9.5

5 years ago

1.9.4

5 years ago

1.9.3

5 years ago

1.9.2

5 years ago

1.9.1

5 years ago

1.9.0

5 years ago

1.8.5

5 years ago

1.8.4

5 years ago

1.8.3

5 years ago

1.8.2

5 years ago

1.8.1

5 years ago

1.8.0

5 years ago

1.8.0-rc.3

5 years ago

1.8.0-rc.2

5 years ago

1.8.0-rc.1

5 years ago

1.8.0-rc.0

5 years ago

1.8.0-alpha.7

5 years ago

1.7.3

5 years ago

1.8.0-alpha.6

5 years ago

1.8.0-alpha.2

5 years ago

1.8.0-alpha.3

5 years ago

1.8.0-alpha.4

5 years ago

1.8.0-alpha.5

5 years ago

1.8.0-alpha.1

5 years ago

1.7.2

5 years ago

1.7.1

5 years ago

1.8.0-alpha.0

5 years ago

1.7.0

5 years ago

1.6.3

5 years ago

1.6.2

5 years ago

1.6.1

5 years ago

1.6.1-0

5 years ago

1.6.0

5 years ago

1.5.4

5 years ago

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.14

5 years ago

1.4.13

5 years ago

1.4.12

5 years ago

1.4.11

5 years ago

1.4.10

5 years ago

1.4.9

5 years ago

1.4.8

5 years ago

1.4.7

5 years ago

1.4.6

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.4.0-rc.13

6 years ago

1.4.0-rc.12

6 years ago

1.4.0-rc.11

6 years ago

1.4.0-rc.10

6 years ago

1.4.0-rc.9

6 years ago

1.4.0-rc.8

6 years ago

1.4.0-rc.7

6 years ago

1.4.0-rc.6

6 years ago

1.4.0-rc.5

6 years ago

1.4.0-rc.4

6 years ago

1.4.0-rc.3

6 years ago

1.4.0-rc.2

6 years ago

1.4.0-rc.1

6 years ago

1.4.0-rc.0

6 years ago

1.4.0-beta.4

6 years ago

1.4.0-beta.3

6 years ago

1.4.0-beta.2

6 years ago

1.4.0-beta.1

6 years ago

1.4.0-beta.0

6 years ago

1.4.0-alpha.33

6 years ago

1.4.0-alpha.32

6 years ago

1.4.0-alpha.31

6 years ago

1.4.0-alpha.30

6 years ago

1.4.0-alpha.29

6 years ago

1.4.0-alpha.28

6 years ago

1.4.0-alpha.27

6 years ago

1.4.0-alpha.26

6 years ago

1.4.0-alpha.25

6 years ago

1.4.0-alpha.24

6 years ago

1.4.0-alpha.23

6 years ago

1.4.0-alpha.22

6 years ago

1.4.0-alpha.21

6 years ago

1.4.0-alpha.20

6 years ago

1.4.0-alpha.19

6 years ago

1.4.0-alpha.18

6 years ago

1.4.0-alpha.17

6 years ago

0.0.0

6 years ago

1.4.0-alpha.16

6 years ago

1.4.0-alpha.15

6 years ago

1.4.0-alpha.14

6 years ago

1.4.0-alpha.13

6 years ago

1.4.0-alpha.12

6 years ago

1.4.0-alpha.10

6 years ago

1.4.0-alpha.9

6 years ago

1.4.0-alpha.8

6 years ago

1.4.0-alpha.7

6 years ago

1.4.0-alpha.6

6 years ago

1.3.4

7 years ago

1.4.0-alpha.5

7 years ago

1.4.0-alpha.4

7 years ago

1.4.0-alpha.3

7 years ago

1.4.0-alpha.2

7 years ago

1.4.0-alpha.1

7 years ago

1.4.0-alpha.0

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.3.0-rc.4

7 years ago

1.3.0-rc.3

7 years ago

1.3.0-rc.2

7 years ago

1.3.0-rc.1

7 years ago

1.3.0-rc.0

7 years ago

1.3.0-alpha.7

7 years ago

1.3.0-alpha.6

7 years ago

1.3.0-alpha.5

7 years ago

1.2.9

7 years ago

1.3.0-alpha.3

7 years ago

1.3.0-alpha.2

7 years ago

1.3.0-alpha.1

8 years ago

1.3.0-alpha.0

8 years ago

1.2.8

8 years ago

1.2.7

8 years ago