Hello,
I modified a previously written script which controlled dragging an HTML element on the screen with the mouse. I modified it to instead drag the background position, but change only the X value (horizontal axis).
The problem is, every time I click the element to drag the background, it resets the x value back to 0. The reason is because the variable which pulls the x value pulling offsetLeft, to calculate the left positioning of the actual element, which happens to be 0. I have tried changing this to backgroundPositionX, but I get an error that backgroundPositionX is undefined.
Shouldn't it be able to retrieve the backgroundPositionX that currently exists on the property? Here is what the relevant code looks like:
Why won't this work?
Thanks!
I modified a previously written script which controlled dragging an HTML element on the screen with the mouse. I modified it to instead drag the background position, but change only the X value (horizontal axis).
The problem is, every time I click the element to drag the background, it resets the x value back to 0. The reason is because the variable which pulls the x value pulling offsetLeft, to calculate the left positioning of the actual element, which happens to be 0. I have tried changing this to backgroundPositionX, but I get an error that backgroundPositionX is undefined.
Shouldn't it be able to retrieve the backgroundPositionX that currently exists on the property? Here is what the relevant code looks like:
Code:
lastElemLeft = this.style.backgroundPositionX;
Why won't this work?
Thanks!
















