Skip to content

Commit 45a47be

Browse files
huchenleichristian-byrnegithub-actions
authored
Ctrl+Shift+Drag zoom on mouse position (#538) (#541)
* Ctrl+Shift+Drag zoom on mouse position (#538) * Update test expectations [skip ci] --------- Co-authored-by: bymyself <abolkonsky.rem@gmail.com> Co-authored-by: github-actions <github-actions@github.com>
1 parent 2252f0a commit 45a47be

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

browser_tests/interaction.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,23 @@ test.describe('Canvas Interaction', () => {
110110
await expect(comfyPage.canvas).toHaveScreenshot('zoomed-out.png')
111111
})
112112

113+
test('Can zoom in/out with ctrl+shift+vertical-drag', async ({
114+
comfyPage
115+
}) => {
116+
await comfyPage.page.keyboard.down('Control')
117+
await comfyPage.page.keyboard.down('Shift')
118+
await comfyPage.dragAndDrop({ x: 10, y: 100 }, { x: 10, y: 40 })
119+
await expect(comfyPage.canvas).toHaveScreenshot('zoomed-in-ctrl-shift.png')
120+
await comfyPage.dragAndDrop({ x: 10, y: 40 }, { x: 10, y: 160 })
121+
await expect(comfyPage.canvas).toHaveScreenshot('zoomed-out-ctrl-shift.png')
122+
await comfyPage.dragAndDrop({ x: 10, y: 280 }, { x: 10, y: 220 })
123+
await expect(comfyPage.canvas).toHaveScreenshot(
124+
'zoomed-default-ctrl-shift.png'
125+
)
126+
await comfyPage.page.keyboard.up('Control')
127+
await comfyPage.page.keyboard.up('Shift')
128+
})
129+
113130
test('Can pan', async ({ comfyPage }) => {
114131
await comfyPage.pan({ x: 200, y: 200 })
115132
await expect(comfyPage.canvas).toHaveScreenshot('panned.png')
Loading
Loading
Loading

src/scripts/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,8 +1245,8 @@ export class ComfyApp {
12451245
let scale = startScale - deltaY / 100
12461246

12471247
this.ds.changeScale(scale, [
1248-
this.ds.element.width / 2,
1249-
this.ds.element.height / 2
1248+
self.zoom_drag_start[0],
1249+
self.zoom_drag_start[1]
12501250
])
12511251
this.graph.change()
12521252

0 commit comments

Comments
 (0)