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
f8a1f7b6
Commit
f8a1f7b6
authored
Oct 31, 2011
by
timmywil
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bug_10613_2'
parents
0191e989
83a355a9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
41 deletions
+36
-41
offset.js
src/offset.js
+7
-17
support.js
src/support.js
+28
-24
index.html
test/index.html
+1
-0
No files found.
src/offset.js
View file @
f8a1f7b6
...
@@ -75,7 +75,7 @@ if ( "getBoundingClientRect" in document.documentElement ) {
...
@@ -75,7 +75,7 @@ if ( "getBoundingClientRect" in document.documentElement ) {
left
=
elem
.
offsetLeft
;
left
=
elem
.
offsetLeft
;
while
(
(
elem
=
elem
.
parentNode
)
&&
elem
!==
body
&&
elem
!==
docElem
)
{
while
(
(
elem
=
elem
.
parentNode
)
&&
elem
!==
body
&&
elem
!==
docElem
)
{
if
(
jQuery
.
offset
.
supportsF
ixedPosition
&&
prevComputedStyle
.
position
===
"fixed"
)
{
if
(
jQuery
.
support
.
f
ixedPosition
&&
prevComputedStyle
.
position
===
"fixed"
)
{
break
;
break
;
}
}
...
@@ -87,7 +87,7 @@ if ( "getBoundingClientRect" in document.documentElement ) {
...
@@ -87,7 +87,7 @@ if ( "getBoundingClientRect" in document.documentElement ) {
top
+=
elem
.
offsetTop
;
top
+=
elem
.
offsetTop
;
left
+=
elem
.
offsetLeft
;
left
+=
elem
.
offsetLeft
;
if
(
jQuery
.
offset
.
doesNotAddBorder
&&
!
(
jQuery
.
offse
t
.
doesAddBorderForTableAndCells
&&
rtable
.
test
(
elem
.
nodeName
))
)
{
if
(
jQuery
.
support
.
doesNotAddBorder
&&
!
(
jQuery
.
suppor
t
.
doesAddBorderForTableAndCells
&&
rtable
.
test
(
elem
.
nodeName
))
)
{
top
+=
parseFloat
(
computedStyle
.
borderTopWidth
)
||
0
;
top
+=
parseFloat
(
computedStyle
.
borderTopWidth
)
||
0
;
left
+=
parseFloat
(
computedStyle
.
borderLeftWidth
)
||
0
;
left
+=
parseFloat
(
computedStyle
.
borderLeftWidth
)
||
0
;
}
}
...
@@ -96,7 +96,7 @@ if ( "getBoundingClientRect" in document.documentElement ) {
...
@@ -96,7 +96,7 @@ if ( "getBoundingClientRect" in document.documentElement ) {
offsetParent
=
elem
.
offsetParent
;
offsetParent
=
elem
.
offsetParent
;
}
}
if
(
jQuery
.
offse
t
.
subtractsBorderForOverflowNotVisible
&&
computedStyle
.
overflow
!==
"visible"
)
{
if
(
jQuery
.
suppor
t
.
subtractsBorderForOverflowNotVisible
&&
computedStyle
.
overflow
!==
"visible"
)
{
top
+=
parseFloat
(
computedStyle
.
borderTopWidth
)
||
0
;
top
+=
parseFloat
(
computedStyle
.
borderTopWidth
)
||
0
;
left
+=
parseFloat
(
computedStyle
.
borderLeftWidth
)
||
0
;
left
+=
parseFloat
(
computedStyle
.
borderLeftWidth
)
||
0
;
}
}
...
@@ -109,7 +109,7 @@ if ( "getBoundingClientRect" in document.documentElement ) {
...
@@ -109,7 +109,7 @@ if ( "getBoundingClientRect" in document.documentElement ) {
left
+=
body
.
offsetLeft
;
left
+=
body
.
offsetLeft
;
}
}
if
(
jQuery
.
offset
.
supportsF
ixedPosition
&&
prevComputedStyle
.
position
===
"fixed"
)
{
if
(
jQuery
.
support
.
f
ixedPosition
&&
prevComputedStyle
.
position
===
"fixed"
)
{
top
+=
Math
.
max
(
docElem
.
scrollTop
,
body
.
scrollTop
);
top
+=
Math
.
max
(
docElem
.
scrollTop
,
body
.
scrollTop
);
left
+=
Math
.
max
(
docElem
.
scrollLeft
,
body
.
scrollLeft
);
left
+=
Math
.
max
(
docElem
.
scrollLeft
,
body
.
scrollLeft
);
}
}
...
@@ -118,23 +118,13 @@ if ( "getBoundingClientRect" in document.documentElement ) {
...
@@ -118,23 +118,13 @@ if ( "getBoundingClientRect" in document.documentElement ) {
};
};
}
}
jQuery
.
offset
=
{};
jQuery
.
offset
=
{
jQuery
.
each
(
(
"doesAddBorderForTableAndCells doesNotAddBorder "
+
"doesNotIncludeMarginInBodyOffset subtractsBorderForOverflowNotVisible "
+
"supportsFixedPosition"
).
split
(
" "
),
function
(
i
,
prop
)
{
jQuery
.
offset
[
prop
]
=
jQuery
.
support
[
prop
];
});
jQuery
.
extend
(
jQuery
.
offset
,
{
bodyOffset
:
function
(
body
)
{
bodyOffset
:
function
(
body
)
{
var
top
=
body
.
offsetTop
,
var
top
=
body
.
offsetTop
,
left
=
body
.
offsetLeft
;
left
=
body
.
offsetLeft
;
if
(
jQuery
.
offse
t
.
doesNotIncludeMarginInBodyOffset
)
{
if
(
jQuery
.
suppor
t
.
doesNotIncludeMarginInBodyOffset
)
{
top
+=
parseFloat
(
jQuery
.
css
(
body
,
"marginTop"
)
)
||
0
;
top
+=
parseFloat
(
jQuery
.
css
(
body
,
"marginTop"
)
)
||
0
;
left
+=
parseFloat
(
jQuery
.
css
(
body
,
"marginLeft"
)
)
||
0
;
left
+=
parseFloat
(
jQuery
.
css
(
body
,
"marginLeft"
)
)
||
0
;
}
}
...
@@ -184,7 +174,7 @@ jQuery.extend( jQuery.offset, {
...
@@ -184,7 +174,7 @@ jQuery.extend( jQuery.offset, {
curElem
.
css
(
props
);
curElem
.
css
(
props
);
}
}
}
}
}
)
;
};
jQuery
.
fn
.
extend
({
jQuery
.
fn
.
extend
({
...
...
src/support.js
View file @
f8a1f7b6
...
@@ -20,8 +20,7 @@ jQuery.support = (function() {
...
@@ -20,8 +20,7 @@ jQuery.support = (function() {
events
,
events
,
eventName
,
eventName
,
i
,
i
,
isSupported
,
isSupported
;
offsetSupport
;
// Preliminary tests
// Preliminary tests
div
.
setAttribute
(
"className"
,
"t"
);
div
.
setAttribute
(
"className"
,
"t"
);
...
@@ -231,9 +230,6 @@ jQuery.support = (function() {
...
@@ -231,9 +230,6 @@ jQuery.support = (function() {
(
parseInt
(
(
document
.
defaultView
.
getComputedStyle
(
marginDiv
,
null
)
||
{
marginRight
:
0
}
).
marginRight
,
10
)
||
0
)
===
0
;
(
parseInt
(
(
document
.
defaultView
.
getComputedStyle
(
marginDiv
,
null
)
||
{
marginRight
:
0
}
).
marginRight
,
10
)
||
0
)
===
0
;
}
}
// Remove the body element we added
testElement
.
innerHTML
=
""
;
// Technique from Juriy Zaytsev
// Technique from Juriy Zaytsev
// http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
// http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
// We only care about the case where non-standard event systems
// We only care about the case where non-standard event systems
...
@@ -256,29 +252,35 @@ jQuery.support = (function() {
...
@@ -256,29 +252,35 @@ jQuery.support = (function() {
}
}
}
}
// Determine fixed-position support early
// Run fixed position tests at doc ready to avoid a crash
testElement
.
style
.
position
=
"static"
;
// related to the invisible body in IE8
testElement
.
style
.
top
=
"0px"
;
jQuery
(
function
()
{
testElement
.
style
.
marginTop
=
"1px"
;
var
container
,
outer
,
inner
,
table
,
td
,
offsetSupport
,
offsetSupport
=
(
function
(
body
,
container
)
{
conMarginTop
=
1
,
var
outer
,
inner
,
table
,
td
,
supports
,
bodyMarginTop
=
parseFloat
(
body
.
style
.
marginTop
)
||
0
,
ptlm
=
"position:absolute;top:0;left:0;width:1px;height:1px;margin:0;"
,
ptlm
=
"position:absolute;top:0;left:0;width:1px;height:1px;margin:0;"
,
vb
=
"visibility:hidden;border:0;"
,
style
=
"style='"
+
ptlm
+
"border:5px solid #000;padding:0;'"
,
style
=
"style='"
+
ptlm
+
"border:5px solid #000;padding:0;'"
,
html
=
"<div "
+
style
+
"><div></div></div>"
+
html
=
"<div "
+
style
+
"><div></div></div>"
+
"<table "
+
style
+
" cellpadding='0' cellspacing='0'>"
+
"<table "
+
style
+
" cellpadding='0' cellspacing='0'>"
+
"<tr><td></td></tr></table>"
;
"<tr><td></td></tr></table>"
;
container
.
style
.
cssText
=
ptlm
+
"border:0;visibility:hidden"
;
// Reconstruct a container
body
=
document
.
getElementsByTagName
(
"body"
)[
0
];
container
.
innerHTML
=
html
;
container
=
document
.
createElement
(
"div"
);
container
.
style
.
cssText
=
vb
+
"width:0;height:0;position:static;top:0;marginTop:"
+
conMarginTop
+
"px"
;
body
.
insertBefore
(
container
,
body
.
firstChild
);
body
.
insertBefore
(
container
,
body
.
firstChild
);
outer
=
container
.
firstChild
;
// Construct a test element
testElement
=
document
.
createElement
(
"div"
);
testElement
.
style
.
cssText
=
ptlm
+
vb
;
testElement
.
innerHTML
=
html
;
container
.
appendChild
(
testElement
);
outer
=
testElement
.
firstChild
;
inner
=
outer
.
firstChild
;
inner
=
outer
.
firstChild
;
td
=
outer
.
nextSibling
.
firstChild
.
firstChild
;
td
=
outer
.
nextSibling
.
firstChild
.
firstChild
;
supports
=
{
offsetSupport
=
{
doesNotAddBorder
:
(
inner
.
offsetTop
!==
5
),
doesNotAddBorder
:
(
inner
.
offsetTop
!==
5
),
doesAddBorderForTableAndCells
:
(
td
.
offsetTop
===
5
)
doesAddBorderForTableAndCells
:
(
td
.
offsetTop
===
5
)
};
};
...
@@ -287,20 +289,22 @@ jQuery.support = (function() {
...
@@ -287,20 +289,22 @@ jQuery.support = (function() {
inner
.
style
.
top
=
"20px"
;
inner
.
style
.
top
=
"20px"
;
// safari subtracts parent border width here which is 5px
// safari subtracts parent border width here which is 5px
supports
.
supportsF
ixedPosition
=
(
inner
.
offsetTop
===
20
||
inner
.
offsetTop
===
15
);
offsetSupport
.
f
ixedPosition
=
(
inner
.
offsetTop
===
20
||
inner
.
offsetTop
===
15
);
inner
.
style
.
position
=
inner
.
style
.
top
=
""
;
inner
.
style
.
position
=
inner
.
style
.
top
=
""
;
outer
.
style
.
overflow
=
"hidden"
;
outer
.
style
.
overflow
=
"hidden"
;
outer
.
style
.
position
=
"relative"
;
outer
.
style
.
position
=
"relative"
;
supports
.
subtractsBorderForOverflowNotVisible
=
(
inner
.
offsetTop
===
-
5
);
offsetSupport
.
subtractsBorderForOverflowNotVisible
=
(
inner
.
offsetTop
===
-
5
);
supports
.
doesNotIncludeMarginInBodyOffset
=
(
body
.
offsetTop
!==
body
MarginTop
);
offsetSupport
.
doesNotIncludeMarginInBodyOffset
=
(
body
.
offsetTop
!==
con
MarginTop
);
return
supports
;
body
.
removeChild
(
container
);
testElement
=
container
=
null
;
})(
testElement
,
div
);
jQuery
.
extend
(
support
,
offsetSupport
);
});
jQuery
.
extend
(
support
,
offsetSupport
)
;
testElement
.
innerHTML
=
""
;
testElementParent
.
removeChild
(
testElement
);
testElementParent
.
removeChild
(
testElement
);
// Null connected elements to avoid leaks in IE
// Null connected elements to avoid leaks in IE
...
...
test/index.html
View file @
f8a1f7b6
...
@@ -298,5 +298,6 @@ Z</textarea>
...
@@ -298,5 +298,6 @@ Z</textarea>
<div
id=
"fx-tests"
></div>
<div
id=
"fx-tests"
></div>
</div>
</div>
</body>
</body>
</html>
</html>
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