jeromeetienne / virtualjoystick.js

a virtual joystick library to emulate a joystick on touch screen in javascript
http://jeromeetienne.github.com/virtualjoystick.js/examples/basic.html
MIT License
417 stars 125 forks source link

inconsistent base position across browser #44

Closed felixmariotto closed 3 years ago

felixmariotto commented 4 years ago

The issue happens only when sationaryBase == true, because of these lines :

if(this._stationaryBase === true){
    this._baseEl.style.display  = "";
    this._baseEl.style.left     = (this._baseX - this._baseEl.width /2)+"px";
    this._baseEl.style.top      = (this._baseY - this._baseEl.height/2)+"px";
}

it is fixed by replacing element.width and element.height by element.clientWidth and element.clientHeight