From e5a8dfe30a874c7db0c17d7a92c3452587164e49 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Mon, 14 Oct 2019 19:28:47 +0200 Subject: [PATCH] Fix absolute guides position on scroll --- src/commands/view/ComponentDrag.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/commands/view/ComponentDrag.js b/src/commands/view/ComponentDrag.js index 251bebdeb..0cf32ddda 100644 --- a/src/commands/view/ComponentDrag.js +++ b/src/commands/view/ComponentDrag.js @@ -122,7 +122,7 @@ export default { updateGuides(guides) { (guides || this.guides).forEach(item => { const { origin } = item; - const { top, height, left, width } = editor.Canvas.getElementPos(origin); + const { top, height, left, width } = this.getElementPos(origin); switch (item.type) { case 't': @@ -204,9 +204,13 @@ export default { return el; }, + getElementPos(el) { + return this.editor.Canvas.getElementPos(el, { noScroll: 1 }); + }, + getElementGuides(el) { - const { editor, opts } = this; - const originRect = editor.Canvas.getElementPos(el, { noScroll: 1 }); + const { opts } = this; + const originRect = this.getElementPos(el); const { top, height, left, width } = originRect; const guides = [ { type: 't', y: top }, // Top @@ -222,7 +226,6 @@ export default { guide: opts.debug && this.renderGuide(item) })); guides.forEach(item => this.guides.push(item)); - console.log('getElementGuides', guides, el); return guides; }, @@ -351,12 +354,12 @@ export default { * Render guides with spacing information */ renderGuideInfo(guides = []) { - const { guidesStatic, editor } = this; + const { guidesStatic } = this; this.hideGuidesInfo(); guides.forEach(item => { const { origin, x } = item; - const rectOrigin = editor.Canvas.getElementPos(origin); + const rectOrigin = this.getElementPos(origin); const axis = isUndefined(x) ? 'y' : 'x'; const isY = axis === 'y'; const origEdge1 = rectOrigin[isY ? 'left' : 'top'];