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

clipper-fixed zooming event logic correction #13

Closed
timtnleeProject opened this issue Apr 25, 2019 · 0 comments
Closed

clipper-fixed zooming event logic correction #13

timtnleeProject opened this issue Apr 25, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request to do Features/bugs/corrections to be done in the future

Comments

@timtnleeProject
Copy link
Owner

Original zooming logic

Take mouse wheel zooming as an example

this.wheelZoom$ = new Subject().pipe(
  startWith(1),
  merge(this.wheelEvent$),
  scan((origin, delta) => {
    let rate = this.zoomRate * Math.max(origin, 0.8) * delta
    return Math.max(origin + rate, this.minScale)
  })
)

process

origin = 1
(on wheel event) origin = origin + rate1 = scale => (image's transform scale)
(on wheel event) origin = origin + rate2 = scale => (image's transform scale)
(on wheel event) origin = origin + rate3 = scale => (image's transform scale)
...

sometimes this might cause problems.

Correction

It should calculate the new scaling value base on the image's scaling value directly.

process correction

scale = 1 (by default)
(on wheel event) scale = scale + rate1 => (image's transform scale)
(on wheel event) scale = scale + rate2 = scale => (image's transform scale)
(on wheel event) scale = scale + rate3 = scale => (image's transform scale)
...

Wheel event zooming

this.wheelZoom$ = new Subject().pipe(
  startWith(1),
  merge(this.wheelEvent$),
  map(delta => {
    const origin = this.bgWH$ // get the image's scaling
    let rate = this.zoomRate * Math.max(origin, 0.8) * delta
    return Math.max(origin + rate, this.minScale)
  })
)

also, there is a touch event that zooms the image.

Todo

Apply these corrections in the next version.

@timtnleeProject timtnleeProject added enhancement New feature or request to do Features/bugs/corrections to be done in the future labels Apr 25, 2019
@timtnleeProject timtnleeProject self-assigned this Apr 25, 2019
timtnleeProject added a commit that referenced this issue Apr 25, 2019
* correct clipper-fixed zomming event logic #13
* use standard eslint rule
* build script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request to do Features/bugs/corrections to be done in the future
Projects
None yet
Development

No branches or pull requests

1 participant