Skip to content

Commit

Permalink
fix: volume viewport getCurrentImageId (#265)
Browse files Browse the repository at this point in the history
* Fix issue when getting an index that equals 0.

When using this method while being on the first image, the index returns 0, and this method would return `undefined`.
This is unwanted since the first image obviously has a 0 index which is usable.
My fix simply consists of ensuring the returned value is a number (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN).

* Update VolumeViewport.ts
  • Loading branch information
gabriellebaudy authored Oct 27, 2022
1 parent 7d5b70d commit 30e4a5d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/src/RenderingEngine/VolumeViewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ class VolumeViewport extends Viewport implements IVolumeViewport {
public getCurrentImageId = (): string | undefined => {
const index = this._getImageIdIndex();

if (!index) {
if (isNaN(index)) {
return;
}

Expand Down

0 comments on commit 30e4a5d

Please sign in to comment.