git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f717260
)
jquery offset: reducing the code size.
author
Ariel Flesler
<aflesler@gmail.com>
Wed, 14 May 2008 17:54:54 +0000
(17:54 +0000)
committer
Ariel Flesler
<aflesler@gmail.com>
Wed, 14 May 2008 17:54:54 +0000
(17:54 +0000)
src/offset.js
patch
|
blob
|
history
diff --git
a/src/offset.js
b/src/offset.js
index
4de37a0
..
1add61c
100644
(file)
--- a/
src/offset.js
+++ b/
src/offset.js
@@
-101,23
+101,23
@@
jQuery.fn.offset = function() {
jQuery.fn.extend({
position: function() {
jQuery.fn.extend({
position: function() {
- var left = 0, top = 0, elem = this[0], offset, parentOffset, offsetParent, results;
+ var left = 0, top = 0, results;
- if (elem) {
+ if ( this[0] ) {
// Get *real* offsetParent
// Get *real* offsetParent
- offsetParent = this.offsetParent();
+ var offsetParent = this.offsetParent(),
- // Get correct offsets
- offset = this.offset();
- parentOffset = offsetParent.offset();
+ // Get correct offsets
+ offset = this.offset(),
+ parentOffset = offsetParent.offset();
// Subtract element margins
// Subtract element margins
- offset.top -= parseInt( jQuery.curCSS(elem, 'marginTop', true) ) || 0;
- offset.left -= parseInt( jQuery.curCSS(elem, 'marginLeft', true) ) || 0;
+ offset.top -= num( this, 'marginTop' );
+ offset.left -= num( this, 'marginLeft' );
// Add offsetParent borders
// Add offsetParent borders
- parentOffset.top += parseInt( jQuery.curCSS(offsetParent[0], 'borderTopWidth', true) ) || 0;
- parentOffset.left += parseInt( jQuery.curCSS(offsetParent[0], 'borderLeftWidth', true) ) || 0;
+ parentOffset.top += num( offsetParent, 'borderTopWidth' );
+ parentOffset.left += num( offsetParent, 'borderLeftWidth' );
// Subtract the two offsets
results = {
// Subtract the two offsets
results = {