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

Resolve the issue of other canvases being unable to interact when overlapping on mobile devices. #1849

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

zhengxiongwei520
Copy link

Hello author, I have a problem (by translations).
My project uses both Openseadragon and Konva. Openseadragon is also a Canvas library, and Konva is a child element of Openseadragon.

createCanvas() {
    this._canvasDiv = document.createElement('div');
    this._canvasDiv.style.position = 'absolute';
    this._canvasDiv.style.left = '0';
    this._canvasDiv.style.top = '0';
    this._canvasDiv.style.width = '100%';
    this._canvasDiv.style.height = '100%';
    this._canvasDiv.setAttribute('id', this._id);
    this._viewer?.canvas.appendChild(this._canvasDiv);
    this._konvaStage = new Konva.Stage({
      container: this._id,
      width: this._containerWidth,
      height: this._containerHeight
    }); 
  }

I initialized Konva in this way. _viewer is a class of Openseadragon. I added Konva to Openseadragon. Then I used Konva to mark and draw, and everything was normal, except on the mobile side.

I checked for a long time and finally found this code through the keyword mobile. Adding the judgment can meet my needs, but I don’t know if it will affect other codes.
At first glance, it seems more like you missed the judgment of pointer?

if (evt.cancelable && eventType !== 'touch' && eventType !== 'pointer') {
    evt.preventDefault();
}

After adding this judgment code, the problem that Openseadragon can only be dragged once is solved. It seems that lowering the version of Openseadragon can also solve this conflict problem, but my project cannot lower the version of Openseadragon, so I proposed this PR.

@lavrton lavrton merged commit db71b4b into konvajs:master Nov 5, 2024
2 checks passed
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.

2 participants