when I drag the background image to left or right, also making effect on compass icon which is rotating 360deg. It's working (kind of) at very first cycle. But not on second or third etc.. after the first cycle compass is adding a new gap. So 0 to 360 not matching. Dragging cycle not finishes where it starts.
I think I miss calculate on the function where I rotate compass icon:
function setDegree(){
const x = getCssData()
const d = (360 / 5000) // 5000 is actual background image size.
const r = (x - def.value) * d * -1;
compass.value.style.transform = "rotate(" + r + "deg)"
}
For better understanding I made a sandbox.
P.S: I uploaded the background image and compass.svg into assets folder, but sandbox doesn't showing. still trying to fix image path...