From b2373224aa0f6b6f2c9a6a2cb18d55cefd0aa284 Mon Sep 17 00:00:00 2001 From: Svetlana Terenteva Date: Mon, 12 Dec 2022 15:39:32 +0500 Subject: [PATCH] #1864 Update setScrollOffset method --- .../ketcher-core/src/application/render/raphaelRender.ts | 9 +++------ .../src/application/render/restruct/restruct.ts | 9 +++++---- packages/ketcher-react/src/script/editor/Editor.ts | 8 ++++++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/ketcher-core/src/application/render/raphaelRender.ts b/packages/ketcher-core/src/application/render/raphaelRender.ts index 6461856c6c..90711a66b7 100644 --- a/packages/ketcher-core/src/application/render/raphaelRender.ts +++ b/packages/ketcher-core/src/application/render/raphaelRender.ts @@ -196,12 +196,9 @@ class Render { this.setOffset(this.options.offset.add(d)) } } - clientArea.scrollLeft = x - clientArea.scrollTop = y - // TODO: store drag position in scaled systems - // scrollLeft = clientArea.scrollLeft; - // scrollTop = clientArea.scrollTop; - this.update(false) + + clientArea.scrollLeft = x * this.options.scale + clientArea.scrollTop = y * this.options.scale } update(force = false, viewSz: Vec2 | null = null) { diff --git a/packages/ketcher-core/src/application/render/restruct/restruct.ts b/packages/ketcher-core/src/application/render/restruct/restruct.ts index e40961536b..634c1ea53d 100644 --- a/packages/ketcher-core/src/application/render/restruct/restruct.ts +++ b/packages/ketcher-core/src/application/render/restruct/restruct.ts @@ -576,7 +576,6 @@ class ReStruct { } setSelection(selection?) { - const redraw = arguments.length === 0 // render.update only const atoms: { selected: boolean; sgroup: number }[] = [] Object.keys(ReStruct.maps).forEach((map) => { @@ -605,9 +604,11 @@ class ReStruct { ) item.selected = sGroupAtoms.length > 0 && sGroupAtoms[0].selected } - const selected = redraw - ? item.selected - : selection && selection[map] && selection[map].indexOf(id) > -1 + + const selected = + selection && selection[map] + ? selection[map].indexOf(id) > -1 + : item.selected this.showItemSelection(item, selected) }) diff --git a/packages/ketcher-react/src/script/editor/Editor.ts b/packages/ketcher-react/src/script/editor/Editor.ts index faa831019b..d431c4b0e9 100644 --- a/packages/ketcher-react/src/script/editor/Editor.ts +++ b/packages/ketcher-react/src/script/editor/Editor.ts @@ -582,12 +582,16 @@ function domEventSetup(editor: Editor, clientArea) { }) } -function recoordinate(editor: Editor, rp /* , vp */) { +function recoordinate(editor: Editor, rp?: Vec2 /* , vp */) { // rp is a point in scaled coordinates, which will be positioned // vp is the point where the reference point should now be (in view coordinates) // or the center if not set console.assert(rp, 'Reference point not specified') - editor.render.setScrollOffset(0, 0) + if (rp) { + editor.render.setScrollOffset(rp.x, rp.y) + } else { + editor.render.setScrollOffset(0, 0) + } } function getStructCenter(ReStruct, selection?) {