Issue #426 : Imporve Toolbar position calculating (#435)

* Issue #426 : Imporve Toolbar position calculating

* header tool update

* 2.0.5
This commit is contained in:
Peter Savchenko 2018-08-28 18:14:34 +03:00 committed by GitHub
parent 0ea3197a73
commit 6ac69a48e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 14 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +1 @@
Subproject commit 92e5373cf8826492a96b6ca5070552ddf6aa749d
Subproject commit da319d4757f1909d049f0f205be62ac08ef377f5

View file

@ -1,6 +1,6 @@
{
"name": "codex.editor",
"version": "2.0.4",
"version": "2.0.5",
"description": "Codex Editor. Native JS, based on API and Open Source",
"main": "build/codex-editor.js",
"scripts": {

View file

@ -1,3 +1,4 @@
import SelectionUtils from '../selection';
/**
*
* «Toolbar» is the node that moves up/down over current block
@ -176,23 +177,28 @@ export default class Toolbar extends Module {
}
/**
* @todo Compute dynamically on prepare
* @type {number}
* Set Toolbar Min Height as Selection Height (usually similar with Block's height)
* Plus Button and Toolbox positioned at the center of the Toolbar
*/
const defaultToolbarHeight = 49;
const defaultOffset = 34;
this.nodes.content.style.minHeight = SelectionUtils.rect.height + 'px';
var newYCoordinate = currentNode.offsetTop - (defaultToolbarHeight / 2) + defaultOffset;
this.nodes.wrapper.style.transform = `translate3D(0, ${Math.floor(newYCoordinate)}px, 0)`;
/**
* Move Toolbar to the Top coordinate of Block
*/
this.nodes.wrapper.style.transform = `translate3D(0, ${Math.floor(currentNode.offsetTop)}px, 0)`;
}
/**
* Open Toolbar with Plus Button
*/
open() {
this.move();
this.nodes.wrapper.classList.add(Toolbar.CSS.toolbarOpened);
/**
* Wait Block rendering for correct height computing
*/
setTimeout(() => {
this.move();
this.nodes.wrapper.classList.add(Toolbar.CSS.toolbarOpened);
}, 50);
}
/**

View file

@ -32,6 +32,12 @@
}
}
&__plus,
.ce-toolbox {
top: 50%;
transform: translateY(-50%);
}
/**
* Block actions Zone
* -------------------------