Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scale factor min bug - unable to set zoom value to specified minimum value #161

Closed
wolasss opened this issue Nov 19, 2019 · 3 comments
Closed
Assignees
Labels

Comments

@wolasss
Copy link
Contributor

wolasss commented Nov 19, 2019

Hi, thanks for all the work you did in the library, it works really nice.

I found a little bug I think, please consider this example:

https://jsfiddle.net/546yqbzk/

You have two function, zoomIn() - zooms the viewer by the scale of 1.25 and zoomOut() that scales the viewer by the factor of 1 / 1.25 (0.8).

So from my understanding, if I set a scaleFactorMin to 1, it would let the value of zoom to equal one. So if I click on the zoom in button once and then zoom out once I would expect the viewer to come back to the same position since 1.25 * 0.8 = 1. Unfortunetely it doesnt work as expected. It does not come back to zoom value of 1.

I think the problem lies in the

function lessThanScaleFactorMin (value, scaleFactor) {

function lessThanScaleFactorMin actually checks if the calculated value is LESS OR EQUAL, hence it stops from setting the value equal to scaleFactorMin.

@chrvadala
Copy link
Owner

I did few tests and I agree with you, both lessThanScaleFactorMin and moreThanScaleFactorMax codes have to be replaced with a STRICT COMPARE operator. I'll release a fix in a couple day, in the meantime a rapid workaround is to sum (or substract) an EPSILON

 scaleFactorMin={1 - Number.EPSILON}

@chrvadala chrvadala self-assigned this Nov 19, 2019
@chrvadala chrvadala added the bug label Nov 19, 2019
@chrvadala
Copy link
Owner

Fixed with 3.6

@wolasss
Copy link
Contributor Author

wolasss commented Nov 23, 2019

Perfect, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants