PAIR-code/scatter-gl

Use of offsetWidth and offsetHeight induces scroll bars

Opened this issue · 0 comments

While exploring an unrelated bug, I noticed that ScatterGL uses offsetWidth and offsetHeight properties of its container to set the size of the canvas it renders into.

As the offsetWidth and offsetHeight return the integer values, this can induce horizontal and/or vertical scroll bars in containers if one dimension is not an integer. See the following screenshot from LIT.

One solution is to take the floor of the width and height from getBoundingClientRect() so that it's guaranteed to be at most 1px smaller in each dimension, thereby avoiding scroll bars. Another solution is to support float values for canvas dimesions.