cornerstonejs / cornerstoneTools

A framework for tools built on top of Cornerstone.
https://tools.cornerstonejs.org/
MIT License
577 stars 452 forks source link

fix: undefined points in touch events #1517

Open slak44 opened 1 year ago

slak44 commented 1 year ago

Bug fix.

Currently, there are several situations where undefined point objects are used in touch event handlers:

  1. Without touching the viewport beforehand, use the zoom tool. The panend event handler is called with startPoints undefined, which later throws.
  2. Using the magnify tool too quickly after scrolling the stack tries to draw the tool but evt.detail.currentPoints is undefined.
  3. There's also a way to reach the panmove handler with the lastDelta object undefined. Though I can't reproduce this as easily, the fix is similar.

Check that all these objects are defined, so the tools don't end up accessing properties on undefined. There was already one such check in panend, but the same problem shows up in a few places.

No.

Found the issues by using the tools in OHIF.

codecov[bot] commented 1 year ago

Codecov Report

Merging #1517 (e11001a) into master (925a3dd) will decrease coverage by 0.00%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #1517      +/-   ##
==========================================
- Coverage   21.70%   21.69%   -0.01%     
==========================================
  Files         287      287              
  Lines       10137    10139       +2     
  Branches     2081     2082       +1     
==========================================
  Hits         2200     2200              
- Misses       6750     6751       +1     
- Partials     1187     1188       +1     
Impacted Files Coverage Δ
src/eventListeners/touchEventListeners.js 4.27% <0.00%> (-0.05%) :arrow_down:
src/tools/MagnifyTool.js 0.00% <0.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more