Biblioteca de predicción de posiciones del ratón-mpredict. js

Tiempo de ejecución: 30 minutos. Empezar

Autor: cudbg
Views Total: 1,902
Sitio oficial: Ir a la web
Actualizado: June 10, 2016
Licencia: MIT

Vista prévia

Biblioteca de predicción de posiciones del ratón-mpredict. js

Descripción

mpredict. js es una biblioteca de JavaScript sin dependencia que se utiliza para predecir la posición del mouse.

See also:

Funcionamiento

Asegúrese de que los archivos mpredict. js y mpredict-templates. JSON se colocan en la misma carpeta. A continuación, incluya el script mpredict. js en su página web como sigue:

<script src="mpredict.js"></script>

Empiece a predecir la posición del ratón:

mPredict.start();

Opciones posibles con valores predeterminados:

mPredict.start({


// The time interval(by milliseconds) of sampling the mouse trace

sampleInterval: 10,


// he time threshold of pausing; when the time between two consecutive mouse events is larger than this threshold, the second mouse event will be regarded as the beginning of a new trace

pauseThreshold: 50,


// The number of nearest neighbors in the KNN algorithm

K: 5,


// The path to the JSON file of templates used for the KNN algorithm

pathToTemplates: './mpredict-templates.json',


// The selector of target element to record mouse trace from

targetElement: 'document'


});

Api.

// Get the current mouse trace recorded and sampled by MPredict.js on the target DOM element
mPredict.getCurrentTrace()

// Sample a mouse trace for prediction
// trace : Array: [[x0, y0, t0], ..., [xn, yn, tn]], xi and yi are mouse positions(in pixels), ti is the timestamp
mPredict.sampleTrace(trace)

// Predict the mouse position for the given trace after deltaTime
// trace : sampled mouse trace
// deltaTime : integer(in milliseconds), deltaTime <= 0 means predicting the endpoint for the given trace
mPredict.predictPosition(trace, deltaTime)

Te puede interesar: