keen-slider icon indicating copy to clipboard operation
keen-slider copied to clipboard

Translate3d rounding error

Open manspeterson opened this issue 2 years ago • 1 comments

Hi,

I'm using the react version of keen-slider. My slider is placed inside a container that is set within a display: grid.

At certain viewport widths the calculated translate3d() is off by 1px, meaning each incremental slide gets pushed +1 pixel to the side. And by 1px off I mean the base of the translate3d() is 1px less than the automatic set min-/max-height for each slide (i.e. translate3d(({max-width}-1)*i*-1, 0,0)).

I'm guessing this is some kind of rounding error. Is this a known bug? Or do you need a sandbox to come up with a potential workaround?

Thanks in advance, Måns

manspeterson avatar Sep 30 '22 08:09 manspeterson

Now looking at the code, while using renderMode: 'performance', this indeed seems to be the intended behavior since performance does add a Math.round() to the calculations.

Maybe this should be explained in the documentation more in detail under renderMode?

manspeterson avatar Oct 26 '22 09:10 manspeterson