Fixed an issue with a horiziontal scrollbar popping with a popover on displayed on the right side

This commit is contained in:
jos 2016-01-14 20:04:45 +01:00
parent 5c51429abd
commit b26eb2ebe4
3 changed files with 13 additions and 6 deletions

View File

@ -168,7 +168,8 @@ Node.prototype.setError = function (error, child) {
var contentRect = this.editor.content.getBoundingClientRect();
var popoverRect = popover.getBoundingClientRect();
var fit = util.insideRect(contentRect, popoverRect);
var margin = 20; // account for a scroll bar
var fit = util.insideRect(contentRect, popoverRect, margin);
if (fit) {
break;

View File

@ -664,12 +664,14 @@ exports.parsePath = function parsePath(jsonPath) {
* Test whether the child rect fits completely inside the parent rect.
* @param {ClientRect} parent
* @param {ClientRect} child
* @param {number} margin
*/
exports.insideRect = function (parent, child) {
return child.left >= parent.left
&& child.right <= parent.right
&& child.top >= parent.top
&& child.bottom <= parent.bottom;
exports.insideRect = function (parent, child, margin) {
var _margin = margin !== undefined ? margin : 0;
return child.left - _margin >= parent.left
&& child.right + _margin <= parent.right
&& child.top - _margin >= parent.top
&& child.bottom + _margin <= parent.bottom;
};
/**

View File

@ -48,6 +48,9 @@
"lastName": {
"type": "string"
},
"gender": {
"enum": ["male", "female"]
},
"age": {
"description": "Age in years",
"type": "integer",
@ -75,6 +78,7 @@
var json = {
"firstName": "Jos",
"lastName": "de Jong",
gender: null,
"age": 34.2,
"hobbies": [
"programming",