Biblioteca de predicción de posiciones del ratón-mpredict. js
| Autor: | cudbg |
|---|---|
| Views Total: | 1,902 |
| Sitio oficial: | Ir a la web |
| Actualizado: | June 10, 2016 |
| Licencia: | MIT |
Vista prévia
Descripción
mpredict. js es una biblioteca de JavaScript sin dependencia que se utiliza para predecir la posición del mouse.
See also:
- biblioteca de JavaScript para el seguimiento de la posición del mouse y la predicción de entrada del usuario â & #128; & #147; trial. js
- biblioteca de JavaScript para rastrear la posición del mouse en relación con el elemento â & #128; & #147; Spot. js
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)





