picturae / openseadragonselection

An OpenSeadragon selection plugin for the tiled viewer.
Apache License 2.0
50 stars 24 forks source link

Selection not working after first selection - Chrome + tablet touch mode #35

Open AlexDarbyFujitsuGmail opened 6 years ago

AlexDarbyFujitsuGmail commented 6 years ago

There is a issue which happens after a image selection has been made.

To reproduce:

  1. start chome browser
  2. open webpage https://picturae.github.io/openseadragonselection/
  3. open chrome developer tools (More tools / Developer tools)
  4. developer tools - select the Toogle device toolbar to set tablet touch mode
  5. webpage - select the tool selection icon (empty square)
  6. create a selection on the image
  7. confirm or cancel the selection
  8. try to create a new selection (this will not be possible)
iangilman commented 6 years ago

Hopefully @picturae can help out, but if not, you might try looking at the MouseTracker handlers in selection.js.

sekwah41 commented 6 years ago

Issue is fixed by on cancel calling this.outerTracker.setTracking(false); this.outerTracker.setTracking(true);

So I am not sure what needs to be changed but it solves the problem

iangilman commented 6 years ago

Good find! It would be nice to know why that fixes it, but even adding it to this plugin as is might be an improvement.

sekwah41 commented 6 years ago

I will make a quick pull request in a min for this fix

sekwah41 commented 6 years ago

@iangilman seems that the pointers are not being reset correctly. I have managed to so far narrow it down to clearTrackedPointers(tracker). If you add the below passthrough to $.MouseTracker.prototype it also fixes the issue. selection.js

cancel: function() {
            /*
             * These two lines have been added to fix a issue with mobile where the selection is just a pinpoint after the first drag
             * For some reason disabling then re-enabling the tracking fixes this issue.
             */
            this.outerTracker.clearPoints();
            this.viewer.raiseEvent('selection_cancel', false);
            return this.undraw();
        },

$.MouseTracker.prototype from openseadragon.js

clearPoints: function() {
            clearTrackedPointers(this);
        },

My suggestion would be to either look at how the trackers are handled or add an option to call this on trackers into openseadragon at least as a fix for now as well as for more power to addons.

iangilman commented 6 years ago

@sekwah41 sounds promising. @msalsbery do you have any thoughts on the above?