@cornerstonejs/tools 1.1.3 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "main": "dist/umd/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -26,7 +26,7 @@
26
26
  "webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
27
27
  },
28
28
  "dependencies": {
29
- "@cornerstonejs/core": "^1.1.3",
29
+ "@cornerstonejs/core": "^1.1.5",
30
30
  "lodash.clonedeep": "4.5.0",
31
31
  "lodash.get": "^4.4.2"
32
32
  },
@@ -49,5 +49,5 @@
49
49
  "type": "individual",
50
50
  "url": "https://ohif.org/donate"
51
51
  },
52
- "gitHead": "c81d8b4ceec625deb25e4a606d1bffc4cf81e454"
52
+ "gitHead": "042e5d584c3ca57948eb84e987a49118a48e091a"
53
53
  }
@@ -22,6 +22,9 @@ const { MOUSE_DOWN, MOUSE_DOWN_ACTIVATE, MOUSE_CLICK, MOUSE_UP, MOUSE_DRAG } =
22
22
  //
23
23
  const DOUBLE_CLICK_TOLERANCE_MS = 400;
24
24
 
25
+ // This tolerance is how long to accept a secondary button down
26
+ const MULTI_BUTTON_TOLERANCE_MS = 150;
27
+
25
28
  // A drag (projected distance) during the double click timeout that is greater than this
26
29
  // value will cancel the timeout and suppress any double click that might occur.
27
30
  // This tolerance is particularly important on touch devices where some movement
@@ -124,17 +127,28 @@ const doubleClickState: IDoubleClickState = {
124
127
  * @private
125
128
  */
126
129
  function mouseDownListener(evt: MouseEvent) {
127
- // Ignore any mouse down during the double click timeout because only
128
- // the first mouse down has the potential of being handled.
129
130
  if (doubleClickState.doubleClickTimeout) {
131
+ // A second identical click will be a double click event, so ignore it
132
+ if (evt.buttons === doubleClickState.mouseDownEvent.buttons) return;
133
+
134
+ // Record the second button or the changed button event as the initial
135
+ // button down state so that the multi-button event can be detected
136
+ doubleClickState.mouseDownEvent = evt;
137
+
138
+ // If second button is added, then ensure double click timeout is terminated
139
+ // and do not handle three or more button gestures.
140
+ _doStateMouseDownAndUp();
130
141
  return;
131
142
  }
132
143
 
133
- // Only left single button click can be doubled up, so fire immediately
134
- // on anything except left double click.
144
+ // Handle multi-button clicks by adding a delay before handling them.
145
+ // Double clicks (left button only) physically take the user longer, so
146
+ // use a longer timeout, and for multi-button at the same time, the clicks
147
+ // are done at the same time by the user, just the system perceives them
148
+ // separately, so have a short timeout to allow catching both buttons.
135
149
  doubleClickState.doubleClickTimeout = setTimeout(
136
150
  _doStateMouseDownAndUp,
137
- evt.buttons === 1 ? DOUBLE_CLICK_TOLERANCE_MS : 0
151
+ evt.buttons === 1 ? DOUBLE_CLICK_TOLERANCE_MS : MULTI_BUTTON_TOLERANCE_MS
138
152
  );
139
153
 
140
154
  // First mouse down of a potential double click. So save it and start