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
ff06d411
Commit
ff06d411
authored
Mar 31, 2011
by
Dave Methvin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bug_8316' of
https://github.com/timmywil/jquery
into timmywil-bug_8316
parents
459bd7f8
f9cc5597
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
50 deletions
+17
-50
offset.js
src/offset.js
+3
-3
bug_8316.html
test/data/offset/bug_8316.html
+0
-30
fixed.html
test/data/offset/fixed.html
+1
-0
offset.js
test/unit/offset.js
+13
-17
No files found.
src/offset.js
View file @
ff06d411
...
@@ -37,8 +37,8 @@ if ( "getBoundingClientRect" in document.documentElement ) {
...
@@ -37,8 +37,8 @@ if ( "getBoundingClientRect" in document.documentElement ) {
win
=
getWindow
(
doc
),
win
=
getWindow
(
doc
),
clientTop
=
docElem
.
clientTop
||
body
.
clientTop
||
0
,
clientTop
=
docElem
.
clientTop
||
body
.
clientTop
||
0
,
clientLeft
=
docElem
.
clientLeft
||
body
.
clientLeft
||
0
,
clientLeft
=
docElem
.
clientLeft
||
body
.
clientLeft
||
0
,
scrollTop
=
(
win
.
pageYOffset
||
jQuery
.
support
.
boxModel
&&
docElem
.
scrollTop
||
body
.
scrollTop
)
,
scrollTop
=
win
.
pageYOffset
||
jQuery
.
support
.
boxModel
&&
docElem
.
scrollTop
||
body
.
scrollTop
,
scrollLeft
=
(
win
.
pageXOffset
||
jQuery
.
support
.
boxModel
&&
docElem
.
scrollLeft
||
body
.
scrollLeft
)
,
scrollLeft
=
win
.
pageXOffset
||
jQuery
.
support
.
boxModel
&&
docElem
.
scrollLeft
||
body
.
scrollLeft
,
top
=
box
.
top
+
scrollTop
-
clientTop
,
top
=
box
.
top
+
scrollTop
-
clientTop
,
left
=
box
.
left
+
scrollLeft
-
clientLeft
;
left
=
box
.
left
+
scrollLeft
-
clientLeft
;
...
@@ -180,7 +180,7 @@ jQuery.offset = {
...
@@ -180,7 +180,7 @@ jQuery.offset = {
curOffset
=
curElem
.
offset
(),
curOffset
=
curElem
.
offset
(),
curCSSTop
=
jQuery
.
css
(
elem
,
"top"
),
curCSSTop
=
jQuery
.
css
(
elem
,
"top"
),
curCSSLeft
=
jQuery
.
css
(
elem
,
"left"
),
curCSSLeft
=
jQuery
.
css
(
elem
,
"left"
),
calculatePosition
=
(
(
position
===
"absolute"
||
position
===
"fixed"
)
&&
jQuery
.
inArray
(
'auto'
,
[
curCSSTop
,
curCSSLeft
])
>
-
1
)
,
calculatePosition
=
(
position
===
"absolute"
||
position
===
"fixed"
)
&&
jQuery
.
inArray
(
'auto'
,
[
curCSSTop
,
curCSSLeft
])
>
-
1
,
props
=
{},
curPosition
=
{},
curTop
,
curLeft
;
props
=
{},
curPosition
=
{},
curTop
,
curLeft
;
// need to be able to calculate position if either top or left is auto and position is either absolute or fixed
// need to be able to calculate position if either top or left is auto and position is either absolute or fixed
...
...
test/data/offset/bug_8316.html
deleted
100644 → 0
View file @
459bd7f8
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta
http-equiv=
"Content-type"
content=
"text/html; charset=utf-8"
>
<title>
bug_8316
</title>
<style
type=
"text/css"
media=
"screen"
>
#elem
{
background-color
:
#000
;
height
:
100px
;
width
:
100px
;
position
:
fixed
;
}
</style>
<script
src=
"../../../src/core.js"
></script>
<script
src=
"../../../src/deferred.js"
></script>
<script
src=
"../../../src/support.js"
></script>
<script
src=
"../../../src/sizzle/sizzle.js"
></script>
<script
src=
"../../../src/sizzle-jquery.js"
></script>
<script
src=
"../../../src/traversing.js"
></script>
<script
src=
"../../../src/data.js"
></script>
<script
src=
"../../../src/event.js"
></script>
<script
src=
"../../../src/css.js"
></script>
<script
src=
"../../../src/offset.js"
></script>
</head>
<body>
<p>
Some foo text
</p>
<div
id=
"elem"
></div>
</body>
</html>
test/data/offset/fixed.html
View file @
ff06d411
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
<body>
<body>
<div
id=
"fixed-1"
class=
"fixed"
></div>
<div
id=
"fixed-1"
class=
"fixed"
></div>
<div
id=
"fixed-2"
class=
"fixed"
></div>
<div
id=
"fixed-2"
class=
"fixed"
></div>
<div
id=
"fixed-no-top-left"
class=
"fixed"
></div>
<div
id=
"forceScroll"
></div>
<div
id=
"forceScroll"
></div>
<div
id=
"marker"
></div>
<div
id=
"marker"
></div>
<p
class=
"instructions"
>
Click the white box to move the marker to it.
</p>
<p
class=
"instructions"
>
Click the white box to move the marker to it.
</p>
...
...
test/unit/offset.js
View file @
ff06d411
...
@@ -265,7 +265,7 @@ testoffset("static", function( jQuery ) {
...
@@ -265,7 +265,7 @@ testoffset("static", function( jQuery ) {
});
});
testoffset
(
"fixed"
,
function
(
jQuery
)
{
testoffset
(
"fixed"
,
function
(
jQuery
)
{
expect
(
28
);
expect
(
30
);
jQuery
.
offset
.
initialize
();
jQuery
.
offset
.
initialize
();
...
@@ -320,6 +320,17 @@ testoffset("fixed", function( jQuery ) {
...
@@ -320,6 +320,17 @@ testoffset("fixed", function( jQuery ) {
ok
(
true
,
'Fixed position is not supported'
);
ok
(
true
,
'Fixed position is not supported'
);
}
}
});
});
// Bug 8316
var
$noTopLeft
=
jQuery
(
'#fixed-no-top-left'
);
if
(
jQuery
.
offset
.
supportsFixedPosition
)
{
equals
(
$noTopLeft
.
offset
().
top
,
1007
,
"Check offset top for fixed element with no top set"
);
equals
(
$noTopLeft
.
offset
().
left
,
1007
,
"Check offset left for fixed element with no left set"
);
}
else
{
// need to have same number of assertions
ok
(
true
,
'Fixed position is not supported'
);
ok
(
true
,
'Fixed position is not supported'
);
}
});
});
testoffset
(
"table"
,
function
(
jQuery
)
{
testoffset
(
"table"
,
function
(
jQuery
)
{
...
@@ -422,22 +433,7 @@ test("offsetParent", function(){
...
@@ -422,22 +433,7 @@ test("offsetParent", function(){
equals
(
div
[
1
],
jQuery
(
"#nothiddendiv"
)[
0
],
"The div is the offsetParent."
);
equals
(
div
[
1
],
jQuery
(
"#nothiddendiv"
)[
0
],
"The div is the offsetParent."
);
});
});
testoffset
(
"bug_8316"
,
function
(
jQuery
){
function
testoffset
(
name
,
fn
)
{
expect
(
2
);
var
tests
=
[
{
id
:
'#elem'
,
top
:
100
,
left
:
100
}
];
jQuery
.
each
(
tests
,
function
(){
var
el
=
jQuery
(
this
.
id
);
el
.
offset
({
top
:
this
.
top
,
left
:
this
.
left
});
equals
(
Math
.
round
(
el
.
offset
().
top
),
this
.
top
);
equals
(
Math
.
round
(
el
.
offset
().
left
),
this
.
left
);
});
});
function
testoffset
(
name
,
fn
)
{
test
(
name
,
function
()
{
test
(
name
,
function
()
{
// pause execution for now
// pause execution for now
...
...
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