Skip to content

Commit 82ba370

Browse files
committed
Reverted back to using the num helper method in offset.js
1 parent de6520b commit 82ba370

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/offset.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,14 @@ jQuery.fn.extend({
112112
parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset();
113113

114114
// Subtract element margins
115-
offset.top -= parseInt( jQuery.curCSS( this[0], 'marginTop', true ), 10 ) || 0;
116-
offset.left -= parseInt( jQuery.curCSS( this[0], 'marginLeft', true ), 10 ) || 0;
115+
// note: when an element has margin: auto the offsetLeft and marginLeft
116+
// are the same in Safari causing offset.left to incorrectly be 0
117+
offset.top -= num( this, 'marginTop' );
118+
offset.left -= num( this, 'marginLeft' );
117119

118120
// Add offsetParent borders
119-
parentOffset.top += parseInt( jQuery.curCSS( offsetParent[0], 'borderTopWidth', true ), 10 ) || 0;
120-
parentOffset.left += parseInt( jQuery.curCSS( offsetParent[0], 'borderLeftWidth', true ), 10 ) || 0;
121+
parentOffset.top += num( offsetParent, 'borderTopWidth' );
122+
parentOffset.left += num( offsetParent, 'borderLeftWidth' );
121123

122124
// Subtract the two offsets
123125
results = {

0 commit comments

Comments
 (0)