Skip to content

Commit

Permalink
Backmerge: #2325 – When user hovers cursor with any template selected…
Browse files Browse the repository at this point in the history
… near the border of the canvas scrollbars appear (#2346) (#2361)
  • Loading branch information
Nitvex authored Mar 15, 2023
1 parent 9cc6f7c commit cedfabe
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
15 changes: 12 additions & 3 deletions packages/ketcher-core/src/application/render/raphaelRender.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@ Render.prototype.setMolecule = function (ctab) {
this.update(false)
}

Render.prototype.update = function (force = false, viewSz = null) {
Render.prototype.update = function (
force = false,
viewSz = null,
options = {
extendCanvas: true
}
) {
// eslint-disable-line max-statements
viewSz =
viewSz ||
Expand Down Expand Up @@ -226,12 +232,15 @@ Render.prototype.update = function (force = false, viewSz = null) {
const sz = cb.sz().floor()
const delta = this.oldCb.p0.sub(cb.p0).ceil()
this.oldBb = bb
if (!this.sz || sz.x !== this.sz.x || sz.y !== this.sz.y) {
if (
(!this.sz || sz.x !== this.sz.x || sz.y !== this.sz.y) &&
options.extendCanvas
) {
this.setPaperSize(sz)
}

this.options.offset = this.options.offset || new Vec2()
if (delta.x !== 0 || delta.y !== 0) {
if ((delta.x !== 0 || delta.y !== 0) && options.extendCanvas) {
this.setOffset(this.options.offset.add(delta))
this.ctab.translate(delta)
}
Expand Down
10 changes: 7 additions & 3 deletions packages/ketcher-react/src/script/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,13 @@ class Editor implements KetcherEditor {
showFunctionalGroupsTooltip(this)
}

update(action: Action | true, ignoreHistory?: boolean) {
update(
action: Action | true,
ignoreHistory?: boolean,
options = { extendCanvas: true }
) {
if (action === true) {
this.render.update(true) // force
this.render.update(true, null, options) // force
} else {
if (!ignoreHistory && !action.isDummy()) {
this.historyStack.splice(this.historyPtr, HISTORY_SIZE + 1, action)
Expand All @@ -406,7 +410,7 @@ class Editor implements KetcherEditor {
this.historyPtr = this.historyStack.length
this.event.change.dispatch(action) // TODO: stoppable here
}
this.render.update()
this.render.update(false, null, options)
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ketcher-react/src/script/editor/tool/paste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class PasteTool {
this.editor.render.page2obj(event)
)
this.action = action
this.editor.update(this.action, true)
this.editor.update(this.action, true, { extendCanvas: false })

this.mergeItems = getMergeItems(this.editor, pasteItems)
this.editor.hover(getHoverToFuse(this.mergeItems))
Expand Down
2 changes: 1 addition & 1 deletion packages/ketcher-react/src/script/editor/tool/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class TemplateTool {
)

this.followAction = followAction
this.editor.update(followAction, true)
this.editor.update(followAction, true, { extendCanvas: false })

if (this.mode === 'fg') {
const skip = getIgnoredGroupItem(this.editor.struct(), pasteItems)
Expand Down

0 comments on commit cedfabe

Please sign in to comment.