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
aabf635c
Commit
aabf635c
authored
Mar 17, 2009
by
Brandon Aaron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
using parseFloat for offset and position methods and removed num helper method
parent
a37cccc8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
16 deletions
+11
-16
core.js
src/core.js
+0
-5
offset.js
src/offset.js
+11
-11
No files found.
src/core.js
View file @
aabf635c
...
...
@@ -1289,8 +1289,3 @@ function cleanData( elems ) {
}
}
}
// Helper function used by the dimensions and offset modules
function
num
(
elem
,
prop
)
{
return
elem
[
0
]
&&
parseInt
(
jQuery
.
curCSS
(
elem
[
0
],
prop
,
true
),
10
)
||
0
;
}
src/offset.js
View file @
aabf635c
...
...
@@ -28,13 +28,13 @@ else
if
(
elem
===
offsetParent
)
{
top
+=
elem
.
offsetTop
,
left
+=
elem
.
offsetLeft
;
if
(
jQuery
.
offset
.
doesNotAddBorder
&&
!
(
jQuery
.
offset
.
doesAddBorderForTableAndCells
&&
/^t
(
able|d|h
)
$/i
.
test
(
elem
.
tagName
))
)
top
+=
parse
In
t
(
computedStyle
.
borderTopWidth
,
10
)
||
0
,
left
+=
parse
In
t
(
computedStyle
.
borderLeftWidth
,
10
)
||
0
;
top
+=
parse
Floa
t
(
computedStyle
.
borderTopWidth
,
10
)
||
0
,
left
+=
parse
Floa
t
(
computedStyle
.
borderLeftWidth
,
10
)
||
0
;
prevOffsetParent
=
offsetParent
,
offsetParent
=
elem
.
offsetParent
;
}
if
(
jQuery
.
offset
.
subtractsBorderForOverflowNotVisible
&&
computedStyle
.
overflow
!==
"visible"
)
top
+=
parse
In
t
(
computedStyle
.
borderTopWidth
,
10
)
||
0
,
left
+=
parse
In
t
(
computedStyle
.
borderLeftWidth
,
10
)
||
0
;
top
+=
parse
Floa
t
(
computedStyle
.
borderTopWidth
,
10
)
||
0
,
left
+=
parse
Floa
t
(
computedStyle
.
borderLeftWidth
,
10
)
||
0
;
prevComputedStyle
=
computedStyle
;
}
...
...
@@ -79,8 +79,8 @@ jQuery.offset = {
jQuery
.
offset
.
initialized
||
jQuery
.
offset
.
initialize
();
var
top
=
body
.
offsetTop
,
left
=
body
.
offsetLeft
;
if
(
jQuery
.
offset
.
doesNotIncludeMarginInBodyOffset
)
top
+=
parse
In
t
(
jQuery
.
curCSS
(
body
,
'marginTop'
,
true
),
10
)
||
0
,
left
+=
parse
In
t
(
jQuery
.
curCSS
(
body
,
'marginLeft'
,
true
),
10
)
||
0
;
top
+=
parse
Floa
t
(
jQuery
.
curCSS
(
body
,
'marginTop'
,
true
),
10
)
||
0
,
left
+=
parse
Floa
t
(
jQuery
.
curCSS
(
body
,
'marginLeft'
,
true
),
10
)
||
0
;
return
{
top
:
top
,
left
:
left
};
}
};
...
...
@@ -90,7 +90,7 @@ jQuery.fn.extend({
position
:
function
()
{
if
(
!
this
[
0
]
)
return
null
;
var
left
=
0
,
top
=
0
,
results
,
var
elem
=
this
[
0
],
left
=
0
,
top
=
0
,
results
,
// Get *real* offsetParent
offsetParent
=
this
.
offsetParent
(),
...
...
@@ -102,12 +102,12 @@ jQuery.fn.extend({
// Subtract element margins
// note: when an element has margin: auto the offsetLeft and marginLeft
// are the same in Safari causing offset.left to incorrectly be 0
offset
.
top
-=
num
(
this
,
'marginTop'
)
;
offset
.
left
-=
num
(
this
,
'marginLeft'
)
;
offset
.
top
-=
parseFloat
(
jQuery
.
curCSS
(
elem
,
'marginTop'
,
true
),
10
)
||
0
;
offset
.
left
-=
parseFloat
(
jQuery
.
curCSS
(
elem
,
'marginLeft'
,
true
),
10
)
||
0
;
// Add offsetParent borders
parentOffset
.
top
+=
num
(
offsetParent
,
'borderTopWidth'
)
;
parentOffset
.
left
+=
num
(
offsetParent
,
'borderLeftWidth'
)
;
parentOffset
.
top
+=
parseFloat
(
jQuery
.
curCSS
(
offsetParent
[
0
],
'borderTopWidth'
,
true
),
10
)
||
0
;
parentOffset
.
left
+=
parseFloat
(
jQuery
.
curCSS
(
offsetParent
[
0
],
'borderLeftWidth'
,
true
),
10
)
||
0
;
// Subtract the two offsets
results
=
{
...
...
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