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

Minor fixes #15

Closed
wants to merge 10 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ function createPanZoom(domElement, options) {

function onTouch(e) {
if (e.touches.length === 1) {
return handleSignleFingerTouch(e, e.touches[0])
return handleSingleFingerTouch(e, e.touches[0])
} else if (e.touches.length === 2) {
// handleTouchMove() will care about pinch zoom.
e.stopPropagation()
Expand All @@ -428,9 +428,10 @@ function createPanZoom(domElement, options) {
}
}

function handleSignleFingerTouch(e) {
e.stopPropagation()
e.preventDefault()
function handleSingleFingerTouch(e) {
// allow single touch propagation to enable link or image maps touching
// e.stopPropagation()
Copy link
Owner

Choose a reason for hiding this comment

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

These lines were here for a reason. We can't simply comment them out, as that would break consumers who don't want touch events be propagated, without giving them a way out.

I'd suggest to pass a callback into options object, and if it is present, invoke the callback here with e as an argument. Then it would be up to that callback to invoke e.stopPropagation()

Makes sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I needed to remove them to enable image maps areas touch. The callback solution makes sense for sure. I will try it out.

BTW, is there documentation for the library somewhere else than here? Yesterday I couldn't find documentation about options and bounds.

Copy link
Owner

Choose a reason for hiding this comment

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

The only documentation available is in the README.md file. Please feel free to extend it, and I'll do the same.

// e.preventDefault()

var touch = e.touches[0]
mouseX = touch.clientX
Expand Down