npm.io
0.4.0 • Published 2d ago

@snap-engine/core

Licence
MIT
Version
0.4.0
Deps
0
Size
168 kB
Vulns
0
Weekly
413
SnapEngine

The engine is still in early stages of development. Expect frequent updates and breaking changes.

Interactivity Engine for the Web

SnapEngineJS is a collection of utilities for building interactive UI elements on the web.

  • Input handling with a common API for mouse and touch events.
  • Collision detection for basic shapes and lines.
  • Helpers for batching DOM updates.
  • Camera and world coordinate translation for pan-and-zoom interfaces.
  • A built-in WAAPI-based animation engine.
  • A visual debugger for inspecting engine internals.
  • Zero-dependency, framework-agnostic APIs.

See the website for details and documentation.

Installation

npm install @snap-engine/core

Quick Start

import { Engine, ElementObject } from "@snap-engine/core";

const engine = new Engine();
engine.assignDom(document.getElementById("container") as HTMLElement);

const object = new ElementObject(engine, null);
object.element = document.getElementById("item");

object.schedule(() => {
  object.worldPosition = [100, 200];
  object.writeTransform();
}, { stage: "WRITE_1" });

License

MIT

Keywords