I'm currently working on a class that is responsible for changing the mouse cursor when it hovers over a specific element. It requires a string parameter, which is the relative path to my custom cursor file (it's a .png file). However, upon running the website, only the default pointer is displayed. What could be causing this issue? Am I missing something in my implementation?
Below is the code snippet I've been using:
/*
* Indicates whether the mouse has entered the object
*/
private _hasEntered: boolean = false;
/*
* The file name of the custom cursor
*/
private _fileName: string = "";
constructor(fileName: string) {
this._fileName = fileName;
}
/*
* Initializes the class
*/
public awake(): void {
//...Code to handle mouse enter/exit events should be placed here
}
/**
* Triggered when the mouse enters the object
*/
private _onMouseEnter(): void {
document.body.style.cursor = this._fileName;
this._hasEntered = true;
}