User Interaction Prediction With Pure JavaScript – Premonish.js

Category: Javascript , Others , Recommended | December 4, 2016
Views Total:584 views
Official Page:Go to website
Last Update:December 4, 2016


User Interaction Prediction With Pure JavaScript – Premonish.js


Just another JavaScript library for realtime mouse position prediction that predicts which DOM element an user will interact with next.

See also:

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.


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.

You Might Be Interested In:

Leave a Reply