Skip to content

Commit

Permalink
Fixed an issue with a horiziontal scrollbar popping with a popover on…
Browse files Browse the repository at this point in the history
… displayed on the right side
  • Loading branch information
josdejong committed Jan 14, 2016
1 parent 5c51429 commit b26eb2e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/js/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 7 additions & 5 deletions src/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/**
Expand Down
4 changes: 4 additions & 0 deletions test/test_schema.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
"lastName": {
"type": "string"
},
"gender": {
"enum": ["male", "female"]
},
"age": {
"description": "Age in years",
"type": "integer",
Expand Down Expand Up @@ -75,6 +78,7 @@
var json = {
"firstName": "Jos",
"lastName": "de Jong",
gender: null,
"age": 34.2,
"hobbies": [
"programming",
Expand Down

0 comments on commit b26eb2e

Please sign in to comment.