
Just another JavaScript library for realtime mouse position prediction that predicts which DOM element an user will interact with next.
See also:
- JavaScript Library For Mouse Position Tracking And User Input Prediction – Trial.js
- Mouse Position Prediction Library – mpredict.js
How to use it:
Just install the Premonish.js in your project and we’re ready to go.
$ npm install premonish
Initialize the Premonish by creating a new Premonish object.
var premonish = new Premonish({
// an array of selectors
selectors: [],
// an array of DOM elements
elements: []
});Predict the user interaction.
premonish.onIntent(({el, confidence}) => {
// el is the expected DOM element
// confidence is a score from 0-1 on how confident we are in this prediction.
});Stop the mouse position prediction.
premonish.stop();
Use the onMouseMove callback to look at some of the internal calculations that premonish is making.
premonish.onMouseMove(({ position, velocity, expected }) => {
// Each value is an object { x: number, y: number }.
// `expected` is the approximate point premonish thinks the
// user is moving the mouse to.
});






