Skip to content

Commit

Permalink
#1864 Update setScrollOffset method
Browse files Browse the repository at this point in the history
  • Loading branch information
porcelain11 committed Dec 12, 2022
1 parent 48fb37a commit b237322
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
9 changes: 3 additions & 6 deletions packages/ketcher-core/src/application/render/raphaelRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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)
})
Expand Down
8 changes: 6 additions & 2 deletions packages/ketcher-react/src/script/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?) {
Expand Down

0 comments on commit b237322

Please sign in to comment.