Skip to content

Commit

Permalink
fix: #998 moveEndHandler should be consistent w/ v2.4.x
Browse files Browse the repository at this point in the history
* fix  #998 fix moveEndHandler will trigger that when i click the enabled element, but it is not the same with 2.4.x and eslint auto fix

* fix(lint): disabl prettier/prettier with getPixe

* fix(lint): eslint lint fix

* fix: codeclimate issue

* fix: merge conflict
  • Loading branch information
xingbofeng authored and dannyrb committed Aug 6, 2019
1 parent e7099c3 commit 1839b80
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 23 deletions.
35 changes: 22 additions & 13 deletions src/manipulators/moveNewHandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,22 @@ export default function(
handle.active = true;
state.isToolLocked = true;

const moveHandler = _moveHandler.bind(
this,
toolName,
annotation,
handle,
options,
interactionType
);
function moveHandler(evt) {
_moveHandler(
toolName,
annotation,
handle,
options,
interactionType,
{
moveHandler,
moveEndHandler,
},
evt
);
}
// So we don't need to inline the entire `moveEndEventHandler` function
const moveEndHandler = evt => {
function moveEndHandler(evt) {
_moveEndHandler(
toolName,
annotation,
Expand All @@ -80,15 +86,12 @@ export default function(
},
evt
);
};
}

// Add event listeners
_moveEvents[interactionType].forEach(eventType => {
element.addEventListener(eventType, moveHandler);
});
_moveEndEvents[interactionType].forEach(eventType => {
element.addEventListener(eventType, moveEndHandler);
});
element.addEventListener(EVENTS.TOUCH_START, _stopImmediatePropagation);
}

Expand All @@ -98,9 +101,15 @@ function _moveHandler(
handle,
options,
interactionType,
{ moveEndHandler },
evt
) {
const { currentPoints, image, element, buttons } = evt.detail;
// Add moveEndEvent Handler when move trigger

_moveEndEvents[interactionType].forEach(eventType => {
element.addEventListener(eventType, moveEndHandler);
});
const page = currentPoints.page;
const fingerOffset = -57;
const targetLocation = external.cornerstone.pageToPixel(
Expand Down
2 changes: 2 additions & 0 deletions src/tools/annotation/EllipticalRoiTool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ jest.mock('./../../externalModules.js', () => ({
metaData: {
get: jest.fn(),
},
/* eslint-disable prettier/prettier */
getPixels: () => [100, 100, 100, 100, 4, 5, 100, 3, 6],
/* eslint-enable prettier/prettier */
},
}));

Expand Down
2 changes: 0 additions & 2 deletions src/tools/annotation/FreehandMouseTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -1252,8 +1252,6 @@ export default class FreehandMouseTool extends BaseAnnotationTool {
* @returns {Boolean}
*/
_checkInvalidHandleLocation(data, eventData) {
const { element } = eventData;

if (data.handles.points.length < 2) {
return true;
}
Expand Down
7 changes: 3 additions & 4 deletions src/tools/annotation/ProbeTool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ jest.mock('./../../externalModules.js', () => ({
get: jest.fn(),
},
getStoredPixels: (element, x, y) => {
// prettier-ignore
const storedPixels = [10, 20, 30,
40, 50, 60,
70, 80, 90];
/* eslint-disable prettier/prettier */
const storedPixels = [10, 20, 30, 40, 50, 60, 70, 80, 90];
/* eslint-enable prettier/prettier */

return [storedPixels[x * 2 + y]];
},
Expand Down
7 changes: 3 additions & 4 deletions src/tools/annotation/RectangleRoiTool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ jest.mock('./../../externalModules.js', () => ({
metaData: {
get: jest.fn(),
},
// prettier-ignore
getPixels: () => [100, 100, 100,
100, 4, 5,
100, 3, 6]
/* eslint-disable prettier/prettier */
getPixels: () => [100, 100, 100, 100, 4, 5, 100, 3, 6],
/* eslint-enable prettier/prettier */
},
}));

Expand Down
1 change: 1 addition & 0 deletions src/tools/base/BaseAnnotationTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class BaseAnnotationTool extends BaseTool {
* @returns {void}
*/
updateCachedStats(image, element, data) {
// eslint-disable-line
logger.warn(`updateCachedStats not implemented for ${this.name}.`);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/tools/cursors/MouseCursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { modules } from '../../store/index.js';

const cursorModule = modules.cursor;

/* eslint-disable valid-jsdoc */

/*
MACROS - The following keys will have the appropriate value injected when
an SVG is requested:
Expand Down

0 comments on commit 1839b80

Please sign in to comment.