-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3b35bb
commit eeb9afc
Showing
29 changed files
with
223 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+43.9 KB
.../Zoom-Tool-Zoom-In-Out-attachment-points-with-menu-buttons-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42.5 KB
.../Zoom-Tool-Zoom-In-Out-attachment-points-with-menu-buttons-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+41.4 KB
.../Zoom-Tool-Zoom-In-Out-attachment-points-with-menu-buttons-3-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+41 KB
...s/Zoom-Tool-Zoom-In-Out-attachment-points-with-mouse-wheel-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42.5 KB
...s/Zoom-Tool-Zoom-In-Out-attachment-points-with-mouse-wheel-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+44.4 KB
...s/Zoom-Tool-Zoom-In-Out-attachment-points-with-mouse-wheel-3-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+46.4 KB
....ts-snapshots/Zoom-Tool-Zoom-In-Out-bond-with-menu-buttons-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42.8 KB
....ts-snapshots/Zoom-Tool-Zoom-In-Out-bond-with-menu-buttons-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+43.3 KB
....ts-snapshots/Zoom-Tool-Zoom-In-Out-bond-with-menu-buttons-3-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+41.3 KB
...c.ts-snapshots/Zoom-Tool-Zoom-In-Out-bond-with-mouse-wheel-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+43.2 KB
...c.ts-snapshots/Zoom-Tool-Zoom-In-Out-bond-with-mouse-wheel-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+45.1 KB
...c.ts-snapshots/Zoom-Tool-Zoom-In-Out-bond-with-mouse-wheel-3-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39.9 KB
...-snapshots/Zoom-Tool-Zoom-In-Out-monomer-with-menu-buttons-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39.4 KB
...-snapshots/Zoom-Tool-Zoom-In-Out-monomer-with-menu-buttons-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39.1 KB
...-snapshots/Zoom-Tool-Zoom-In-Out-monomer-with-menu-buttons-3-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39.2 KB
...s-snapshots/Zoom-Tool-Zoom-In-Out-monomer-with-mouse-wheel-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+39.6 KB
...s-snapshots/Zoom-Tool-Zoom-In-Out-monomer-with-mouse-wheel-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+40.1 KB
...s-snapshots/Zoom-Tool-Zoom-In-Out-monomer-with-mouse-wheel-3-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42.9 KB
...oom-Tool-Zoom-In-Out-selection-rectangle-with-menu-buttons-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42.9 KB
...oom-Tool-Zoom-In-Out-selection-rectangle-with-menu-buttons-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42.5 KB
...oom-Tool-Zoom-In-Out-selection-rectangle-with-menu-buttons-3-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+40.8 KB
...Zoom-Tool-Zoom-In-Out-selection-rectangle-with-mouse-wheel-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+42 KB
...Zoom-Tool-Zoom-In-Out-selection-rectangle-with-mouse-wheel-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+43.6 KB
...Zoom-Tool-Zoom-In-Out-selection-rectangle-with-mouse-wheel-3-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions
47
packages/ketcher-core/__tests__/application/editor/shared/coordinates.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import Coordinates from 'application/editor/shared/coordinates'; | ||
import ZoomTool from 'application/editor/tools/Zoom'; | ||
import { ZoomTransform } from 'd3'; | ||
import { Vec2 } from 'domain/entities'; | ||
import { DrawingEntitiesManager } from 'domain/entities/DrawingEntitiesManager'; | ||
|
||
describe('Coordinates', () => { | ||
const position = new Vec2(100, 100, 0); | ||
ZoomTool.getInstance(new DrawingEntitiesManager()); | ||
ZoomTool.instance.setZoomTransform(new ZoomTransform(1.2, 40, 40)); | ||
|
||
it('should convert page coordinates to model coordinates', () => { | ||
const converted = Coordinates.pageToModel(position); | ||
const coordinates = new Vec2(2.5, 2.5, 0); | ||
expect(converted).toEqual(coordinates); | ||
}); | ||
|
||
it('should convert view coordinates to model coordinates', () => { | ||
const converted = Coordinates.viewToModel(position); | ||
const coordinates = new Vec2(1.25, 1.25, 0); | ||
expect(converted).toEqual(coordinates); | ||
}); | ||
|
||
it('should convert modal coordinates to view coordinates', () => { | ||
const coordinates = Coordinates.modelToView(position); | ||
const converted = new Vec2(4840, 4840, 0); | ||
expect(coordinates).toEqual(converted); | ||
}); | ||
|
||
it('should convert modal coordinates to page coordinates', () => { | ||
const coordinates = Coordinates.modelToPage(position); | ||
const converted = new Vec2(4000, 4000, 0); | ||
expect(coordinates).toEqual(converted); | ||
}); | ||
|
||
it('should convert page coordinates to view coordinates', () => { | ||
const coordinates = Coordinates.pageToView(position); | ||
const converted = new Vec2(160, 160, 0); | ||
expect(coordinates).toEqual(converted); | ||
}); | ||
|
||
it('should convert view coordinates to page coordinates', () => { | ||
const coordinates = Coordinates.viewToPage(position); | ||
const converted = new Vec2(50, 50, 0); | ||
expect(coordinates).toEqual(converted); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/ketcher-core/__tests__/application/editor/tools/ZoomTool.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { CoreEditor } from 'application/editor'; | ||
import { polymerEditorTheme } from '../../../mock-data'; | ||
import { createPolymerEditorCanvas } from '../../../helpers/dom'; | ||
import ZoomTool from 'application/editor/tools/Zoom'; | ||
import { select } from 'd3'; | ||
|
||
describe('Zoom Tool', () => { | ||
let canvas: SVGSVGElement; | ||
let button; | ||
const zoomed = jest.fn(); | ||
|
||
beforeEach(() => { | ||
window.SVGElement.prototype.getBBox = () => ({ | ||
width: 20, | ||
height: 30, | ||
}); | ||
canvas = createPolymerEditorCanvas(); | ||
button = document.createElement('button'); | ||
button.setAttribute('class', 'zoom-in'); | ||
document.body.appendChild(button); | ||
}); | ||
|
||
['zoom-in', 'zoom-out', 'zoom-reset'].forEach((name) => { | ||
it(`should zoom in when press element with class name ${name}`, () => { | ||
jest | ||
.spyOn(ZoomTool.prototype, 'subscribeMenuZoom') | ||
.mockImplementation(() => { | ||
select(`.${name}`).on('click', zoomed); | ||
}); | ||
// eslint-disable-next-line no-new | ||
new CoreEditor({ | ||
theme: polymerEditorTheme, | ||
canvas, | ||
}); | ||
|
||
const zoomInBtn = document.getElementsByClassName(`${name}`)[0]; | ||
zoomInBtn?.dispatchEvent(new MouseEvent('click')); | ||
expect(zoomed).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
it('should zoom in when scrool mouse wheel up', () => { | ||
jest.spyOn(ZoomTool.prototype, 'zoomAction').mockImplementation(zoomed); | ||
|
||
// eslint-disable-next-line no-new | ||
new CoreEditor({ | ||
theme: polymerEditorTheme, | ||
canvas, | ||
}); | ||
window.dispatchEvent(new WheelEvent('wheel')); | ||
expect(zoomed).toHaveBeenCalled(); | ||
}); | ||
}); |
6 changes: 5 additions & 1 deletion
6
packages/ketcher-core/src/application/editor/shared/coordinates.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters