question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Weird rendering artifacts/borders when enabling panzoom with onTouch: () => false

See original GitHub issue

When I enable panzoom on an image and then tap on the image I see weird golden borders on Chrome’s developer tools in mobile device mode and blue borders on my iPhone in Chrome.

Chrome: Screen Shot 2019-12-22 at 2 06 33 PM

(notice the golden borders on the right and left)

iOS chrome: WhatsApp Image 2019-12-22 at 13 36 38

(Notice the blue borders)

I verified that there are no actual borders being set, these seem to be weird rendering artifacts, perhaps due to css transforms? Not initializing panzoom makes the borders go away.

This is my code:

    panzoom(backgroundImageRef.current, {
        minZoom: 1, // prevent zooming out
        maxZoom: 4, // prevent zooming beyond acceptable levels
        bounds: true, // prevent panning outside of container
        boundsPadding: 1, // prevent panning outside of container
        zoomDoubleClickSpeed: 1, // disable double click zoom
        beforeWheel: () => true, // disable wheel scrolling
        filterKey: () => true, // disable keybindings
        beforeMouseDown: () => true, // disable panning
        onTouch: () => false // do not preventDefault
      })

Note that when I change onTouch: () => false to onTouch: () => true, the borders seem to go away. However, this is unacceptable because the preventDefault prevents the user from being able to scroll (pan) on the x or y axis.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
anvakacommented, Dec 25, 2019

The library supports keyboard based interaction, for that it adds tabindex attribute for the container, which makes it focusable.

If you do not prefer to support keyboard interaction pass disableKeyboardInteraction: true into the options. I do not recommend this approach, as keyboard interaction can be crucial in some hardware configurations (and sometime more accessible)

Alternative and in my opinion a better solution would be to set focus outline on the parent element of your zoomable container, like you did. So that the browser doesn’t apply default css styles to the focused element

2reactions
tommedemacommented, Dec 22, 2019

I don’t know why, but the borders went away after I added this in my css:

// Removes unnecessary outlines on safari
  *:focus {
    outline: none;
  }

How is this related to panzoom? Without panzoom, it wasn’t necessary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found