Skip to content

Commit

Permalink
Merge pull request #1730 from arthuralmeidap/issue-toolbar-position C…
Browse files Browse the repository at this point in the history
…loses #1728 #1434

Fixed display for the component's toolbar to not cover component's content
  • Loading branch information
artf committed Jan 17, 2019
2 parents 738c536 + d7cacfd commit c3174da
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/commands/view/SelectComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,15 +527,29 @@ module.exports = {
* @param {Object} pos
*/
updateToolbarPos(el, elPos) {
var unit = 'px';
var toolbarEl = this.canvas.getToolbarEl();
var toolbarStyle = toolbarEl.style;
const frameOffset = this.canvas.getCanvasView().getFrameOffset();
const unit = 'px';
const toolbarEl = this.canvas.getToolbarEl();
const toolbarStyle = toolbarEl.style;
toolbarStyle.opacity = 0;
var pos = this.canvas.getTargetToElementDim(toolbarEl, el, {
const pos = this.canvas.getTargetToElementDim(toolbarEl, el, {
elPos,
event: 'toolbarPosUpdate'
});

if (pos) {
const isElementBiggerThanCanvas =
pos.elementHeight + pos.targetHeight >= frameOffset.height;

if (pos.top <= pos.canvasTop && !isElementBiggerThanCanvas) {
pos.top = pos.elementTop + pos.elementHeight;
}

// Check if not outside of the canvas
if (pos.left < pos.canvasLeft) {
pos.left = pos.canvasLeft;
}

var leftPos = pos.left + pos.elementWidth - pos.targetWidth;
toolbarStyle.top = pos.top + unit;
toolbarStyle.left = (leftPos < 0 ? 0 : leftPos) + unit;
Expand Down

0 comments on commit c3174da

Please sign in to comment.