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

New: Enhanced pinch to zoom #567

Merged
merged 3 commits into from
Jan 11, 2018
Merged

New: Enhanced pinch to zoom #567

merged 3 commits into from
Jan 11, 2018

Conversation

jeremypress
Copy link
Contributor

@jeremypress jeremypress commented Jan 4, 2018

Still a WIP, but this PR adds a more fluid pinch-to-zoom by:

  1. Scaling the visible pages canvases with CSS transform
  2. Calculating the overall scale and translate it to a PDF.js zoom
  3. Removing the CSS scale and scrolling to where we left off while pinching

Open Issues:

  1. Slight jump when transitioning from CSS scaling to PDF.js zoom
  2. Pages will occasionally scroll when pinching using the presentation viewer.

@boxcla
Copy link

boxcla commented Jan 4, 2018

Verified that @jeremypress has signed the CLA. Thanks for the pull request!

Copy link
Contributor

@JustinHoldstock JustinHoldstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, other than I think there's some duplicated code between some start/change/end functions.

* @return {void}
*/
pinchToZoomEndHandler() {
if (this.zoomWrapper && this.isPinching) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To remove a level of arrowness, you could do if(!this.zoomWrapper || !this.isPinching) return

Copy link
Contributor

@JustinHoldstock JustinHoldstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, after comments! Good job :)

src/lib/util.js Outdated
}
}

return closestPage[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Careful, this'll error out if closestPage is never set

this.xOffset = xOrigin;
this.y = touchMidpoint[1];
this.x = touchMidpoint[0];
//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty comment

// PDF.js zoom
this.pdfViewer.currentScaleValue = this.pdfViewer.currentScale * this.pinchScale;

// // Scroll to correct position after zoom
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra // in comment (unless github is acting up)
as well as commented code

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

Successfully merging this pull request may close these issues.

None yet

3 participants