Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
36b4a9ba
Commit
36b4a9ba
authored
Mar 17, 2009
by
Brandon Aaron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some clean up in the offset method
parent
26731d47
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
offset.js
src/offset.js
+11
-10
No files found.
src/offset.js
View file @
36b4a9ba
if
(
document
.
documentElement
[
"getBoundingClientRect"
]
)
if
(
"getBoundingClientRect"
in
document
.
documentElement
)
jQuery
.
fn
.
offset
=
function
()
{
jQuery
.
fn
.
offset
=
function
()
{
if
(
!
this
[
0
]
)
return
{
top
:
0
,
left
:
0
};
var
elem
=
this
[
0
];
if
(
this
[
0
]
===
this
[
0
].
ownerDocument
.
body
)
return
jQuery
.
offset
.
bodyOffset
(
this
[
0
]
);
if
(
!
elem
)
return
{
top
:
0
,
left
:
0
};
var
box
=
this
[
0
].
getBoundingClientRect
(),
doc
=
this
[
0
].
ownerDocument
,
body
=
doc
.
body
,
docElem
=
doc
.
documentElement
,
if
(
elem
===
elem
.
ownerDocument
.
body
)
return
jQuery
.
offset
.
bodyOffset
(
elem
);
var
box
=
elem
.
getBoundingClientRect
(),
doc
=
elem
.
ownerDocument
,
body
=
doc
.
body
,
docElem
=
doc
.
documentElement
,
clientTop
=
docElem
.
clientTop
||
body
.
clientTop
||
0
,
clientLeft
=
docElem
.
clientLeft
||
body
.
clientLeft
||
0
,
clientTop
=
docElem
.
clientTop
||
body
.
clientTop
||
0
,
clientLeft
=
docElem
.
clientLeft
||
body
.
clientLeft
||
0
,
top
=
box
.
top
+
(
self
.
pageYOffset
||
jQuery
.
boxModel
&&
docElem
.
scrollTop
||
body
.
scrollTop
)
-
clientTop
,
top
=
box
.
top
+
(
self
.
pageYOffset
||
jQuery
.
boxModel
&&
docElem
.
scrollTop
||
body
.
scrollTop
)
-
clientTop
,
left
=
box
.
left
+
(
self
.
pageXOffset
||
jQuery
.
boxModel
&&
docElem
.
scrollLeft
||
body
.
scrollLeft
)
-
clientLeft
;
left
=
box
.
left
+
(
self
.
pageXOffset
||
jQuery
.
boxModel
&&
docElem
.
scrollLeft
||
body
.
scrollLeft
)
-
clientLeft
;
...
@@ -10,11 +11,12 @@ if ( document.documentElement["getBoundingClientRect"] )
...
@@ -10,11 +11,12 @@ if ( document.documentElement["getBoundingClientRect"] )
};
};
else
else
jQuery
.
fn
.
offset
=
function
()
{
jQuery
.
fn
.
offset
=
function
()
{
if
(
!
this
[
0
]
)
return
{
top
:
0
,
left
:
0
};
var
elem
=
this
[
0
];
if
(
this
[
0
]
===
this
[
0
].
ownerDocument
.
body
)
return
jQuery
.
offset
.
bodyOffset
(
this
[
0
]
);
if
(
!
elem
)
return
{
top
:
0
,
left
:
0
};
if
(
elem
===
elem
.
ownerDocument
.
body
)
return
jQuery
.
offset
.
bodyOffset
(
elem
);
jQuery
.
offset
.
initialized
||
jQuery
.
offset
.
initialize
();
jQuery
.
offset
.
initialized
||
jQuery
.
offset
.
initialize
();
var
elem
=
this
[
0
],
offsetParent
=
elem
.
offsetParent
,
prevOffsetParent
=
elem
,
var
offsetParent
=
elem
.
offsetParent
,
prevOffsetParent
=
elem
,
doc
=
elem
.
ownerDocument
,
computedStyle
,
docElem
=
doc
.
documentElement
,
doc
=
elem
.
ownerDocument
,
computedStyle
,
docElem
=
doc
.
documentElement
,
body
=
doc
.
body
,
defaultView
=
doc
.
defaultView
,
body
=
doc
.
body
,
defaultView
=
doc
.
defaultView
,
prevComputedStyle
=
defaultView
.
getComputedStyle
(
elem
,
null
),
prevComputedStyle
=
defaultView
.
getComputedStyle
(
elem
,
null
),
...
@@ -50,11 +52,10 @@ else
...
@@ -50,11 +52,10 @@ else
jQuery
.
offset
=
{
jQuery
.
offset
=
{
initialize
:
function
()
{
initialize
:
function
()
{
if
(
this
.
initialized
)
return
;
if
(
this
.
initialized
)
return
;
var
body
=
document
.
body
,
container
=
document
.
createElement
(
'div'
),
innerDiv
,
checkDiv
,
table
,
td
,
rules
,
prop
,
bodyMarginTop
=
body
.
style
.
marginTop
,
var
body
=
document
.
body
,
container
=
document
.
createElement
(
'div'
),
innerDiv
,
checkDiv
,
table
,
td
,
prop
,
bodyMarginTop
=
body
.
style
.
marginTop
,
html
=
'<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>'
;
html
=
'<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>'
;
rules
=
{
position
:
'absolute'
,
top
:
0
,
left
:
0
,
margin
:
0
,
border
:
0
,
width
:
'1px'
,
height
:
'1px'
,
visibility
:
'hidden'
};
jQuery
.
extend
(
container
.
style
,
{
position
:
'absolute'
,
top
:
0
,
left
:
0
,
margin
:
0
,
border
:
0
,
width
:
'1px'
,
height
:
'1px'
,
visibility
:
'hidden'
}
);
for
(
prop
in
rules
)
container
.
style
[
prop
]
=
rules
[
prop
];
container
.
innerHTML
=
html
;
container
.
innerHTML
=
html
;
body
.
insertBefore
(
container
,
body
.
firstChild
);
body
.
insertBefore
(
container
,
body
.
firstChild
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment