@learn-hunger/visual-gestures
Version:
VisualGestures.js is a package that empowers users to effortlessly control the cursor, including actions such as hover, click, drag, and drop, through precise finger movements in the air.
38 lines • 1.59 kB
JavaScript
import { DefaultConfig } from "../../config/defalut-config";
import { EVgMouseEvents } from "../../utilities/vg-constants";
import { ACommonMouseProps } from "../abstracts/vg-pointer-props-abstract";
/**
* custom Event which is fired when the user do finger motion visual action
* it is triggered from AvgPointerMove class
* when the user moves his hand(by default index finger is taken as pointer)
* it gets dispatched
*/
export class VgPointerMove extends ACommonMouseProps {
constructor(mouseProp, customProps) {
super(EVgMouseEvents.MOUSE_MOVE, mouseProp, customProps);
// this.setCursor();
this.moveCursor();
}
/**
* to set the cursor path or image like hand pointer image etc
* TODO since the fluctations are high between the events ,
* the image is getting fluctuated so currently hold
*/
setCursor() {
const { path, scale, showCursor } = DefaultConfig.instance.cursor.vgpointermove;
const { baseURI } = DefaultConfig.instance.cursor;
if (showCursor && this.cursorElement.src != baseURI + path) {
// console.log(this.cursorElement.src, baseURI + path, "cursor");
this.cursorElement.src = path;
this.cursorElement.style.scale = scale.toString();
}
}
/**
* move the cursor in between the viewport using position values
*/
moveCursor() {
this.cursorElement.style.left = this.clientX.toString() + "px";
this.cursorElement.style.top = this.clientY.toString() + "px";
}
}
//# sourceMappingURL=vg-pointer-move.js.map