diff --git a/.all-contributorsrc b/.all-contributorsrc
index 50140e260..93bf70f58 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -383,6 +383,15 @@
"review",
"userTesting"
]
+ },
+ {
+ "login": "christianmol",
+ "name": "Christian Mol",
+ "avatar_url": "https://avatars.githubusercontent.com/u/36736693?v=4",
+ "profile": "https://github.com/christianmol",
+ "contributions": [
+ "code"
+ ]
}
],
"contributorsPerLine": 7
diff --git a/README.md b/README.md
index ba1724ed6..cd3b23db7 100755
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@
[![Build Status][build-badge]][build]
[![Coverage Status][coverage-badge]][coverage]
-[](#contributors)
+[](#contributors)
[![NPM version][npm-version-image]][npm-url]
[![NPM downloads][npm-downloads-image]][npm-url]
@@ -165,7 +165,7 @@ Thanks goes to these people ([emoji key][emojis]):
| [
Juan Narvaez](https://github.com/jdnarvaez)
[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=jdnarvaez "Code") | [
Mike](https://github.com/mikehazell)
[📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=mikehazell "Documentation") [💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=mikehazell "Code") [⚠️](https://github.com/cornerstonejs/cornerstoneTools/commits?author=mikehazell "Tests") | [
Sangkeun Kim](http://sisobus.com)
[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=sisobus "Code") [💬](#question-sisobus "Answering Questions") | [
Victor Saase](https://github.com/vsaase)
[🤔](#ideas-vsaase "Ideas, Planning, & Feedback") | [
Michael Wasser](http://www.mikewasser.com)
[📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=untoldone "Documentation") | [
Amandeep Singh](https://github.com/singhArmani)
[🖋](#content-singhArmani "Content") | [
Madison Dickson](http://mix3dstudios.com)
[📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=mix3d "Documentation") |
| [
Kevin Lee Drum](https://github.com/kevinleedrum)
[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=kevinleedrum "Code") | [
Makarand Bauskar](https://github.com/mmbauskar)
[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=mbauskar "Code") | [
Biharck Araujo](http://www.biharck.com.br)
[💡](#example-biharck "Examples") [📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=biharck "Documentation") | [
Devon Bernard](https://www.linkedin.com/in/devonbernard)
[📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=DevonBernard "Documentation") | [
Karl-Heinrich](https://github.com/Karl-Heinrich)
[🐛](https://github.com/cornerstonejs/cornerstoneTools/issues?q=author%3AKarl-Heinrich "Bug reports") [💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=Karl-Heinrich "Code") [⚠️](https://github.com/cornerstonejs/cornerstoneTools/commits?author=Karl-Heinrich "Tests") | [
counterxing](https://blog.xingbofeng.com/)
[🐛](https://github.com/cornerstonejs/cornerstoneTools/issues?q=author%3Axingbofeng "Bug reports") [💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=xingbofeng "Code") | [
Jorge Lopes](https://github.com/jlopes90)
[💬](#question-jlopes90 "Answering Questions") |
| [
Gabriel Garrido](http://garrido.io)
[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=Ggpsv "Code") | [
ASVBPREAUBV](https://github.com/ASVBPREAUBV)
[📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=ASVBPREAUBV "Documentation") | [
frolic06](https://github.com/frolic06)
[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=frolic06 "Code") | [
codepage949](https://github.com/codepage949)
[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=codepage949 "Code") | [
Asherah Connor](https://kivikakk.ee)
[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=kivikakk "Code") | [
Ikko Ashimine](https://bandism.net/)
[🐛](https://github.com/cornerstonejs/cornerstoneTools/issues?q=author%3Aeltociear "Bug reports") | [
Bill Wallace](https://github.com/wayfarer3130)
[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=wayfarer3130 "Code") [📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=wayfarer3130 "Documentation") |
-| [
Bruno Alves de Faria](http://radicalimaging.com/)
[🐛](https://github.com/cornerstonejs/cornerstoneTools/issues?q=author%3Abrunoalvesdefaria "Bug reports") [💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=brunoalvesdefaria "Code") [🖋](#content-brunoalvesdefaria "Content") [📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=brunoalvesdefaria "Documentation") [🔌](#plugin-brunoalvesdefaria "Plugin/utility libraries") [👀](#review-brunoalvesdefaria "Reviewed Pull Requests") [⚠️](https://github.com/cornerstonejs/cornerstoneTools/commits?author=brunoalvesdefaria "Tests") [🔧](#tool-brunoalvesdefaria "Tools") [📓](#userTesting-brunoalvesdefaria "User Testing") | [
Igor Octaviano](http://igoroctaviano.com)
[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=igoroctaviano "Code") [📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=igoroctaviano "Documentation") [🚧](#maintenance-igoroctaviano "Maintenance") [👀](#review-igoroctaviano "Reviewed Pull Requests") [📓](#userTesting-igoroctaviano "User Testing") |
+| [
Bruno Alves de Faria](http://radicalimaging.com/)
[🐛](https://github.com/cornerstonejs/cornerstoneTools/issues?q=author%3Abrunoalvesdefaria "Bug reports") [💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=brunoalvesdefaria "Code") [🖋](#content-brunoalvesdefaria "Content") [📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=brunoalvesdefaria "Documentation") [🔌](#plugin-brunoalvesdefaria "Plugin/utility libraries") [👀](#review-brunoalvesdefaria "Reviewed Pull Requests") [⚠️](https://github.com/cornerstonejs/cornerstoneTools/commits?author=brunoalvesdefaria "Tests") [🔧](#tool-brunoalvesdefaria "Tools") [📓](#userTesting-brunoalvesdefaria "User Testing") | [
Igor Octaviano](http://igoroctaviano.com)
[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=igoroctaviano "Code") [📖](https://github.com/cornerstonejs/cornerstoneTools/commits?author=igoroctaviano "Documentation") [🚧](#maintenance-igoroctaviano "Maintenance") [👀](#review-igoroctaviano "Reviewed Pull Requests") [📓](#userTesting-igoroctaviano "User Testing") | [
Christian Mol](https://github.com/christianmol)
[💻](https://github.com/cornerstonejs/cornerstoneTools/commits?author=christianmol "Code") |
This project follows the [all-contributors][all-contributors] specification.
diff --git a/src/tools/StackScrollTool.js b/src/tools/StackScrollTool.js
index 3b43faf16..9835b7c33 100644
--- a/src/tools/StackScrollTool.js
+++ b/src/tools/StackScrollTool.js
@@ -20,6 +20,7 @@ export default class StackScrollTool extends BaseTool {
configuration: {
loop: false,
allowSkipping: true,
+ invert: false,
},
svgCursor: stackScrollCursor,
};
@@ -33,7 +34,7 @@ export default class StackScrollTool extends BaseTool {
_dragCallback(evt) {
const eventData = evt.detail;
const { element, deltaPoints } = eventData;
- const { loop, allowSkipping } = this.configuration;
+ const { loop, allowSkipping, invert } = this.configuration;
const options = getToolOptions(this.name, element);
const pixelsPerImage = this._getPixelPerImage(element);
@@ -46,7 +47,12 @@ export default class StackScrollTool extends BaseTool {
if (Math.abs(deltaY) >= pixelsPerImage) {
const imageIdIndexOffset = Math.round(deltaY / pixelsPerImage);
- scroll(element, imageIdIndexOffset, loop, allowSkipping);
+ scroll(
+ element,
+ invert ? -imageIdIndexOffset : imageIdIndexOffset,
+ loop,
+ allowSkipping
+ );
options.deltaY = deltaY % pixelsPerImage;
} else {
diff --git a/src/tools/StackScrollTool.test.js b/src/tools/StackScrollTool.test.js
index 1b3070b72..8480789a4 100644
--- a/src/tools/StackScrollTool.test.js
+++ b/src/tools/StackScrollTool.test.js
@@ -43,6 +43,12 @@ describe('StachScroll.js', () => {
expect(instantiatedTool.configuration.allowSkipping).toEqual(true);
});
+
+ it('should have default configuration invert as false', () => {
+ const instantiatedTool = new StackScrollTool();
+
+ expect(instantiatedTool.configuration.invert).toEqual(false);
+ });
});
describe('_dragCallback', () => {
@@ -74,5 +80,53 @@ describe('StachScroll.js', () => {
expect(scroll).not.toHaveBeenCalled();
});
+
+ it('should call scroll with positive index when DeltaY is positive and invert is set to false', () => {
+ instantiatedTool._getDeltaY.mockReturnValue(600);
+ instantiatedTool._getPixelPerImage.mockReturnValue(100);
+
+ instantiatedTool._dragCallback(mockEvent);
+
+ expect(scroll).toHaveBeenCalledWith({}, 6, false, true);
+ });
+
+ it('should call scroll with negative index when DeltaY is negative and invert is set to false', () => {
+ instantiatedTool._getDeltaY.mockReturnValue(-600);
+ instantiatedTool._getPixelPerImage.mockReturnValue(100);
+
+ instantiatedTool._dragCallback(mockEvent);
+
+ expect(scroll).toHaveBeenCalledWith({}, -6, false, true);
+ });
+
+ it('should call scroll with negative index when DeltaY is positive and invert is set to true', () => {
+ instantiatedTool = new StackScrollTool({
+ configuration: { invert: true },
+ });
+ instantiatedTool._getDeltaY = jest.fn();
+ instantiatedTool._getPixelPerImage = jest.fn();
+ scroll.mockClear();
+
+ instantiatedTool._getDeltaY.mockReturnValue(600);
+ instantiatedTool._getPixelPerImage.mockReturnValue(100);
+ instantiatedTool._dragCallback(mockEvent);
+
+ expect(scroll).toHaveBeenCalledWith({}, -6, false, true);
+ });
+
+ it('should call scroll with positive index when DeltaY is negative and invert is set to true', () => {
+ instantiatedTool = new StackScrollTool({
+ configuration: { invert: true },
+ });
+ instantiatedTool._getDeltaY = jest.fn();
+ instantiatedTool._getPixelPerImage = jest.fn();
+ scroll.mockClear();
+
+ instantiatedTool._getDeltaY.mockReturnValue(-600);
+ instantiatedTool._getPixelPerImage.mockReturnValue(100);
+ instantiatedTool._dragCallback(mockEvent);
+
+ expect(scroll).toHaveBeenCalledWith({}, 6, false, true);
+ });
});
});