Skip to content

Commit

Permalink
Fix FF constraint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Zack Bloom committed Jan 28, 2014
1 parent 1935617 commit c81a0a0
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 16 deletions.
7 changes: 4 additions & 3 deletions coffee/constraint.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ getBoundingRect = (tether, to) ->
to = [pos.left, pos.top, size.width + pos.left, size.height + pos.top]

for side, i in BOUNDS_FORMAT
if side in ['top', 'left']
to[i] += parseFloat style["border-#{ side }-width"]
side = side[0].toUpperCase() + side.substr(1)
if side in ['Top', 'Left']
to[i] += parseFloat style["border#{ side }Width"]
else
to[i] -= parseFloat style["border-#{ side }-width"]
to[i] -= parseFloat style["border#{ side }Width"]

to

Expand Down
4 changes: 2 additions & 2 deletions coffee/tether.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ class _Tether
offsetParentSize = offsetPosition

offsetBorder = {}
for side in ['top', 'left', 'bottom', 'right']
offsetBorder[side] = parseFloat offsetParentStyle["border-#{ side }-width"]
for side in ['Top', 'Left', 'Bottom', 'Right']
offsetBorder[side] = parseFloat offsetParentStyle["border#{ side }Width"]

offsetPosition.right = document.body.scrollWidth - offsetPosition.left - offsetParentSize.width + offsetBorder.right
offsetPosition.bottom = document.body.scrollHeight - offsetPosition.top - offsetParentSize.height + offsetBorder.bottom
Expand Down
3 changes: 3 additions & 0 deletions coffee/utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ getBounds = (el) ->
box.top -= origin.top
box.left -= origin.left

box.width ?= document.body.scrollWidth - box.left - box.right
box.height ?= document.body.scrollHeight - box.top - box.bottom

box.top = box.top - docEl.clientTop
box.left = box.left - docEl.clientLeft
box.right = doc.body.clientWidth - box.width - box.left
Expand Down
7 changes: 4 additions & 3 deletions js/constraint.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions js/tether.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions js/utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions tether.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@
origin = getOrigin(doc);
box.top -= origin.top;
box.left -= origin.left;
if (box.width == null) {
box.width = document.body.scrollWidth - box.left - box.right;
}
if (box.height == null) {
box.height = document.body.scrollHeight - box.top - box.bottom;
}
box.top = box.top - docEl.clientTop;
box.left = box.left - docEl.clientLeft;
box.right = doc.body.clientWidth - box.width - box.left;
Expand Down Expand Up @@ -804,10 +810,10 @@
elementStyle = getComputedStyle(this.element);
offsetParentSize = offsetPosition;
offsetBorder = {};
_ref4 = ['top', 'left', 'bottom', 'right'];
_ref4 = ['Top', 'Left', 'Bottom', 'Right'];
for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) {
side = _ref4[_j];
offsetBorder[side] = parseFloat(offsetParentStyle["border-" + side + "-width"]);
offsetBorder[side] = parseFloat(offsetParentStyle["border" + side + "Width"]);
}
offsetPosition.right = document.body.scrollWidth - offsetPosition.left - offsetParentSize.width + offsetBorder.right;
offsetPosition.bottom = document.body.scrollHeight - offsetPosition.top - offsetParentSize.height + offsetBorder.bottom;
Expand Down Expand Up @@ -991,10 +997,11 @@
to = [pos.left, pos.top, size.width + pos.left, size.height + pos.top];
for (i = _i = 0, _len = BOUNDS_FORMAT.length; _i < _len; i = ++_i) {
side = BOUNDS_FORMAT[i];
if (side === 'top' || side === 'left') {
to[i] += parseFloat(style["border-" + side + "-width"]);
side = side[0].toUpperCase() + side.substr(1);
if (side === 'Top' || side === 'Left') {
to[i] += parseFloat(style["border" + side + "Width"]);
} else {
to[i] -= parseFloat(style["border-" + side + "-width"]);
to[i] -= parseFloat(style["border" + side + "Width"]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tether.min.js

Large diffs are not rendered by default.

0 comments on commit c81a0a0

Please sign in to comment.