Show picker on left side if it doesn't fit at the bottom

This commit is contained in:
jos 2018-08-22 17:43:13 +02:00
parent 30d7a7b2a6
commit 61039c665e
1 changed files with 8 additions and 1 deletions

View File

@ -129,6 +129,8 @@ treemode.destroy = function () {
* @private
*/
treemode._setOptions = function (options) {
var editor = this;
this.options = {
search: true,
history: true,
@ -142,10 +144,15 @@ treemode._setOptions = function (options) {
colorPicker: true,
onColorPicker: function (parent, color, onChange) {
if (VanillaPicker) {
var contentRect = editor.content.getBoundingClientRect();
var parentRect = parent.getBoundingClientRect();
var pickerWidth = 250;
var pickerRight = parentRect.right + pickerWidth;
new VanillaPicker({
parent: parent,
color: color,
popup: 'bottom',
popup: (pickerRight < contentRect.right) ? 'bottom' : 'left',
onDone: function (color) {
var alpha = color.rgba[3]
var hex = (alpha === 1)