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
75655e57
Commit
75655e57
authored
Jan 15, 2011
by
Sylvester Keil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use parseFloat instead of parseInt to read CSS values.
This fixes #7730 and #7885.
parent
d9cb6987
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
3 deletions
+31
-3
offset.js
src/offset.js
+5
-3
offset.js
test/unit/offset.js
+26
-0
No files found.
src/offset.js
View file @
75655e57
...
...
@@ -187,11 +187,13 @@ jQuery.offset = {
// need to be able to calculate position if either top or left is auto and position is absolute
if
(
calculatePosition
)
{
curPosition
=
curElem
.
position
();
curTop
=
curPosition
.
top
;
curLeft
=
curPosition
.
left
;
}
else
{
curTop
=
parseFloat
(
curCSSTop
)
||
0
;
curLeft
=
parseFloat
(
curCSSLeft
)
||
0
;
}
curTop
=
calculatePosition
?
curPosition
.
top
:
parseInt
(
curCSSTop
,
10
)
||
0
;
curLeft
=
calculatePosition
?
curPosition
.
left
:
parseInt
(
curCSSLeft
,
10
)
||
0
;
if
(
jQuery
.
isFunction
(
options
)
)
{
options
=
options
.
call
(
elem
,
i
,
curOffset
);
}
...
...
test/unit/offset.js
View file @
75655e57
...
...
@@ -422,6 +422,32 @@ test("offsetParent", function(){
equals
(
div
[
1
],
jQuery
(
"#nothiddendiv"
)[
0
],
"The div is the offsetParent."
);
});
test
(
"fractions (see #7730 and #7885)"
,
function
()
{
expect
(
2
);
jQuery
(
'body'
).
append
(
'<div id="fractions"/>'
);
var
expected
=
{
top
:
1000
,
left
:
1000
};
var
div
=
jQuery
(
'#fractions'
);
div
.
css
({
position
:
'absolute'
,
left
:
'1000.7432222px'
,
top
:
'1000.532325px'
,
width
:
100
,
height
:
100
});
div
.
offset
(
expected
);
var
result
=
div
.
offset
();
equals
(
result
.
top
,
expected
.
top
,
"Check top"
);
equals
(
result
.
left
,
expected
.
left
,
"Check left"
);
div
.
remove
();
});
function
testoffset
(
name
,
fn
)
{
test
(
name
,
function
()
{
...
...
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