Browse Source

Refactor updateToolbarPos method

pull/1736/head
Artur Arseniev 7 years ago
parent
commit
b9d107e4a1
  1. 18
      src/commands/view/SelectComponent.js

18
src/commands/view/SelectComponent.js

@ -527,21 +527,25 @@ module.exports = {
* @param {Object} pos
*/
updateToolbarPos(el, elPos) {
const frameOffset = this.canvas.getCanvasView().getFrameOffset();
const { canvas } = this;
const unit = 'px';
const toolbarEl = this.canvas.getToolbarEl();
const toolbarEl = canvas.getToolbarEl();
const toolbarStyle = toolbarEl.style;
toolbarStyle.opacity = 0;
const pos = this.canvas.getTargetToElementDim(toolbarEl, el, {
const pos = canvas.getTargetToElementDim(toolbarEl, el, {
elPos,
event: 'toolbarPosUpdate'
});
if (pos) {
const isElementBiggerThanCanvas =
pos.elementHeight + pos.targetHeight >= frameOffset.height;
if (pos.top <= pos.canvasTop && !isElementBiggerThanCanvas) {
const frameOffset = canvas.getCanvasView().getFrameOffset();
// Scroll with the window if the top edge is reached and the
// element is bigger than the canvas
if (
pos.top <= pos.canvasTop &&
!(pos.elementHeight + pos.targetHeight >= frameOffset.height)
) {
pos.top = pos.elementTop + pos.elementHeight;
}

Loading…
Cancel
Save