Skip to content

Base Class

Everything Pointeract does is based on this class.

TL;DR CheatSheet

DescriptionMethod
Instantiate the Classnew Pointeract(element, modules, options?)
Start Base Classstart()
Stop Base Classstop()
Start Modulesstart(moduleConstructor | ModuleConstructor[])
Stop Modulesstop(moduleConstructor | ModuleConstructor[])
Subscribeon(eventName, callback)
Unsubscribeoff(eventName, callback)
Get Event Typestypeof events.<eventName>
Disposedispose()

Full Example

TypeScript
import { Pointeract, Drag, PreventDefault } from 'pointeract';

const app = document.getElementById('app') as HTMLDivElement;
const options = {
    coordinateOutput: 'absolute',
}
const pointeract = new Pointeract(app, [Drag, PreventDefault], options).start();

const hook = (e: typeof pointeract.events.drag) => {
    console.log(e.detail);
};

// Subscribe to drag events
const unsubscribe = pointeract.on('drag', hook);
// Unsubscribe
unsubscribe();
// Or: pointeract.off('drag', hook);

// Hot update options
options.coordinateOutput = 'relative';

// Pause
pointeract.stop();
// Resume
pointeract.start();
pointeract.stop(PreventDefault); // Disable PreventDefault only

// Dispose
pointeract.dispose();