MCPcopy
hub / github.com/taye/interact.js

github.com/taye/interact.js @v1.10.27 sqlite

repository ↗ · DeepWiki ↗ · release v1.10.27 ↗
1,890 symbols 3,992 edges 547 files 117 documented · 6%
README

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+:
  • yarn add interactjs
  • //= 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.

Extension points exported contracts — how you extend this code

Scope (Interface)
(no doc) [3 implementers]
packages/@interactjs/auto-start/base.ts
Scope (Interface)
(no doc) [3 implementers]
packages/@interactjs/auto-start/base.d.ts
Scope (Interface)
(no doc) [3 implementers]
packages/@interactjs/actions/drop/plugin.ts
Scope (Interface)
(no doc) [3 implementers]
packages/@interactjs/actions/drop/plugin.d.ts
Scope (Interface)
(no doc) [3 implementers]
packages/@interactjs/types/index.d.ts

Core symbols most depended-on inside this repo

extend
called by 187
packages/@interactjs/utils/extend.ts
fire
called by 120
packages/@interactjs/core/scope.ts
use
called by 103
packages/@interactjs/core/InteractStatic.d.ts
on
called by 78
packages/@interactjs/core/InteractStatic.d.ts
usePlugin
called by 77
packages/@interactjs/core/scope.js
start
called by 56
packages/@interactjs/modifiers/types.ts
interact
called by 55
packages/@interactjs/core/InteractStatic.js
interacting
called by 41
packages/@interactjs/core/Interaction.js

Shape

Function 960
Method 449
Interface 332
Class 137
Enum 12

Languages

TypeScript100%

Modules by API surface

packages/@interactjs/types/index.d.ts126 symbols
packages/@interactjs/utils/pointerUtils.ts33 symbols
packages/@interactjs/utils/pointerUtils.prod.js32 symbols
packages/@interactjs/utils/pointerUtils.js32 symbols
packages/@interactjs/core/Interaction.ts29 symbols
packages/@interactjs/core/Interactable.ts26 symbols
packages/@interactjs/inertia/plugin.prod.js25 symbols
packages/@interactjs/core/Interaction.prod.js25 symbols
packages/@interactjs/core/Interaction.js25 symbols
packages/@interactjs/core/Interactable.prod.js25 symbols
packages/@interactjs/core/Interactable.js25 symbols
packages/@interactjs/actions/drop/plugin.ts25 symbols

Dependencies from manifests, versioned

@babel/core7.18.2 · 1×
@babel/plugin-proposal-export-default-from7.17.12 · 1×
@babel/plugin-proposal-optional-catch-binding7.16.7 · 1×
@babel/plugin-proposal-optional-chaining7.17.12 · 1×
@babel/plugin-transform-class-properties7.23.3 · 1×
@babel/plugin-transform-runtime7.18.2 · 1×
@babel/preset-env7.18.2 · 1×
@babel/preset-typescript7.17.12 · 1×
@babel/runtime7.18.3 · 1×
@interactjs/actions1.10.27 · 1×
@interactjs/auto-scroll1.10.27 · 1×
@interactjs/auto-start1.10.27 · 1×

For agents

$ claude mcp add interact.js \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact