Assigning scrollLeft with (scrollWidth - clientWidth) is not working properly

Viewed 413

I assigned element.scrollLeft with element.scrollWidth - element.clientWidth

element.scrollLeft = element.scrollWidth - element.clientWidth;

And received the following:

enter image description here

Here is the console log for element.scrollLeft as well as for element.scrollWidth - element.clientWidth as follows:

console.log("Max scroll width: " + (element.scrollWidth - element.clientWidth));
console.log("Actual scroll after assignment: " + element.scrollLeft);

Why am element.scrollLeft value doesn't match element.scrollWidth - element.clientWidth?

0 Answers
Related