@cornerstonejs/tools 3.12.2 → 3.13.0

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.
@@ -26,7 +26,7 @@ type PolySegAddOn = {
26
26
  computeContourData: ComputeRepresentationFn<ContourSegmentationData>;
27
27
  computeLabelmapData: ComputeRepresentationFn<LabelmapSegmentationData>;
28
28
  computeSurfaceData: ComputeRepresentationFn<SurfaceSegmentationData>;
29
- updateSurfaceData: ComputeRepresentationFn<SurfaceSegmentationData>;
29
+ updateSurfaceData: ComputeRepresentationFn<void>;
30
30
  clipAndCacheSurfacesForViewport: (surfacesInfo: SurfacesInfo[], viewport: Types.IVolumeViewport) => Promise<Map<number, Map<string, SurfaceClipResult>>>;
31
31
  extractContourData: (polyDataCache: Map<number, Map<string, SurfaceClipResult>>) => Map<number, SurfaceClipResult[]>;
32
32
  createAndAddContourSegmentationsFromClippedSurfaces: (rawContourData: Map<number, SurfaceClipResult[]>, viewport: Types.IStackViewport | Types.IVolumeViewport, segmentationId: string) => Map<number, Set<string>>;
@@ -1,11 +1,12 @@
1
1
  type PlayClipOptions = {
2
2
  framesPerSecond?: number;
3
3
  frameTimeVector?: number[];
4
+ frameTimeVectorSpeedMultiplier?: number;
4
5
  reverse?: boolean;
5
6
  loop?: boolean;
6
7
  dynamicCineEnabled?: boolean;
7
- frameTimeVectorSpeedMultiplier?: number;
8
8
  waitForRendered?: number;
9
+ bounce?: boolean;
9
10
  };
10
11
  interface ToolData {
11
12
  intervalId: number | undefined;
@@ -17,6 +18,7 @@ interface ToolData {
17
18
  speed: number;
18
19
  reverse: boolean;
19
20
  loop: boolean;
21
+ bounce: boolean;
20
22
  dynamicCineEnabled?: boolean;
21
23
  }
22
24
  type CinePlayContext = {
@@ -39,6 +39,7 @@ function playClip(element, playClipOptions) {
39
39
  speed: playClipOptions.frameTimeVectorSpeedMultiplier ?? 1,
40
40
  reverse: playClipOptions.reverse ?? false,
41
41
  loop: playClipOptions.loop ?? true,
42
+ bounce: playClipOptions.bounce ?? false,
42
43
  };
43
44
  addToolState(element, playClipData);
44
45
  }
@@ -63,24 +64,30 @@ function playClip(element, playClipOptions) {
63
64
  playClipTimeouts = timeouts;
64
65
  playClipIsTimeVarying = isTimeVarying;
65
66
  }
67
+ if (playClipOptions.bounce !== undefined) {
68
+ playClipData.bounce = playClipOptions.bounce;
69
+ }
66
70
  const playClipAction = () => {
67
71
  const { numScrollSteps, currentStepIndex } = playClipContext;
68
72
  let newStepIndex = currentStepIndex + (playClipData.reverse ? -1 : 1);
69
- const newStepIndexOutOfRange = newStepIndex < 0 || newStepIndex >= numScrollSteps;
70
- if (!playClipData.loop && newStepIndexOutOfRange) {
71
- _stopClip(element, {
72
- stopDynamicCine: !isDynamicCinePlaying,
73
- viewportId: viewport.id,
74
- });
75
- const eventDetail = { element };
76
- triggerEvent(element, CINE_EVENTS.CLIP_STOPPED, eventDetail);
77
- return;
78
- }
79
- if (newStepIndex >= numScrollSteps) {
80
- newStepIndex = 0;
81
- }
82
- else if (newStepIndex < 0) {
83
- newStepIndex = numScrollSteps - 1;
73
+ const outOfRange = newStepIndex < 0 || newStepIndex >= numScrollSteps;
74
+ if (outOfRange) {
75
+ if (playClipData.bounce) {
76
+ playClipData.reverse = !playClipData.reverse;
77
+ newStepIndex = currentStepIndex + (playClipData.reverse ? -1 : 1);
78
+ newStepIndex = Math.max(0, Math.min(numScrollSteps - 1, newStepIndex));
79
+ }
80
+ else if (!playClipData.loop) {
81
+ _stopClip(element, {
82
+ stopDynamicCine: !isDynamicCinePlaying,
83
+ viewportId: viewport.id,
84
+ });
85
+ triggerEvent(element, CINE_EVENTS.CLIP_STOPPED, { element });
86
+ return;
87
+ }
88
+ else {
89
+ newStepIndex = playClipData.reverse ? numScrollSteps - 1 : 0;
90
+ }
84
91
  }
85
92
  const delta = newStepIndex - currentStepIndex;
86
93
  if (delta) {
@@ -90,8 +97,7 @@ function playClip(element, playClipOptions) {
90
97
  catch (e) {
91
98
  console.warn('Play clip not scrolling', e);
92
99
  _stopClipWithData(playClipData);
93
- triggerEvent(element, CINE_EVENTS.CLIP_STOPPED, eventDetail);
94
- return;
100
+ triggerEvent(element, CINE_EVENTS.CLIP_STOPPED, { element });
95
101
  }
96
102
  }
97
103
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "3.12.2",
3
+ "version": "3.13.0",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -103,7 +103,7 @@
103
103
  "canvas": "^3.1.0"
104
104
  },
105
105
  "peerDependencies": {
106
- "@cornerstonejs/core": "^3.12.2",
106
+ "@cornerstonejs/core": "^3.13.0",
107
107
  "@kitware/vtk.js": "32.12.1",
108
108
  "@types/d3-array": "^3.0.4",
109
109
  "@types/d3-interpolate": "^3.0.1",
@@ -122,5 +122,5 @@
122
122
  "type": "individual",
123
123
  "url": "https://ohif.org/donate"
124
124
  },
125
- "gitHead": "2e252505eafa22440251b1f41489a1d6803e5e97"
125
+ "gitHead": "f576d5b54b208a44403faa2cde957f4a98be4fd1"
126
126
  }