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
20391db9
Commit
20391db9
authored
Sep 08, 2006
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Touched up the docs and formatting.
parent
eb29e285
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
72 deletions
+81
-72
dimensions.js
src/dimensions/dimensions.js
+81
-72
No files found.
src/dimensions/dimensions.js
View file @
20391db9
...
@@ -6,160 +6,169 @@
...
@@ -6,160 +6,169 @@
/**
/**
* Returns the css height value for the first matched element.
* Returns the css height value for the first matched element.
* If used on document, returns the document's height (innerHeight)
* If used on document, returns the document's height (innerHeight)
* If used on window, returns the viewport
s (window's
) height
* If used on window, returns the viewport
's (window
) height
*
*
* @example $("#testdiv").height()
* @example $("#testdiv").height()
* @result [ 200px ]
* @result "200px"
*
* @example $(document).height();
* @result 800
*
* @example $(window).height();
* @result 400
*
*
* @name height
* @name height
* @type
jQuery
* @type
Object
* @cat Dimensions
* @cat Dimensions
*/
*/
$
.
fn
.
height
=
function
()
{
$
.
fn
.
height
=
function
()
{
if
(
this
.
get
(
0
)
==
window
)
return
self
.
innerHeight
||
jQuery
.
boxModel
&&
document
.
documentElement
.
clientHeight
||
document
.
body
.
clientHeight
;
if
(
this
.
get
(
0
)
==
window
)
{
if
(
this
.
get
(
0
)
==
document
)
if
(
self
.
innerHeight
)
return
self
.
innerHeight
;
return
Math
.
max
(
document
.
body
.
scrollHeight
,
document
.
body
.
offsetHeight
);
else
if
(
document
.
documentElement
&&
document
.
documentElement
.
clientHeight
)
return
document
.
documentElement
.
clientHeight
;
else
if
(
document
.
body
)
return
document
.
body
.
clientHeight
;
}
if
(
this
.
get
(
0
)
==
document
)
{
var
test1
=
document
.
body
.
scrollHeight
;
var
test2
=
document
.
body
.
offsetHeight
;
if
(
test1
>
test2
)
return
document
.
body
.
scrollHeight
;
else
return
document
.
body
.
offsetHeight
;
}
return
this
.
css
(
"height"
);
return
this
.
css
(
"height"
);
}
};
/**
/**
* Returns the css width value for the first matched element.
* Returns the css width value for the first matched element.
* If used on document, returns the document's width (innerWidth)
* If used on document, returns the document's width (innerWidth)
* If used on window, returns the viewport
s (window's
) width
* If used on window, returns the viewport
's (window
) width
*
*
* @example $("#testdiv").width()
* @example $("#testdiv").width()
* @result [ 200px ]
* @result "200px"
*
* @example $(document).width();
* @result 800
*
* @example $(window).width();
* @result 400
*
*
* @name width
* @name width
* @type
jQuery
* @type
Object
* @cat Dimensions
* @cat Dimensions
*/
*/
$
.
fn
.
width
=
function
()
{
$
.
fn
.
width
=
function
()
{
if
(
this
.
get
(
0
)
==
window
)
return
self
.
innerWidth
||
jQuery
.
boxModel
&&
document
.
documentElement
.
clientWidth
||
document
.
body
.
clientWidth
;
if
(
this
.
get
(
0
)
==
window
)
{
if
(
this
.
get
(
0
)
==
document
)
if
(
self
.
innerWidth
)
return
self
.
innerWidth
;
return
Math
.
max
(
document
.
body
.
scrollWidth
,
document
.
body
.
offsetWidth
);
else
if
(
document
.
documentElement
&&
document
.
documentElement
.
clientWidth
)
return
document
.
documentElement
.
clientWidth
;
else
if
(
document
.
body
)
return
document
.
body
.
clientWidth
;
}
if
(
this
.
get
(
0
)
==
document
)
{
var
test1
=
document
.
body
.
scrollWidth
;
var
test2
=
document
.
body
.
offsetWidth
;
if
(
test1
>
test2
)
return
document
.
body
.
scrollWidth
;
else
return
document
.
body
.
offsetWidth
;
}
return
this
.
css
(
"width"
);
return
this
.
css
(
"width"
);
}
};
/**
/**
* Returns the inner height value (without border) for the first matched element.
* Returns the inner height value (without border) for the first matched element.
* If used on document, returns the document's height (innerHeight)
* If used on document, returns the document's height (innerHeight)
* If used on window, returns the viewport
s (window's
) height
* If used on window, returns the viewport
's (window
) height
*
*
* @example $("#testdiv").innerHeight()
* @example $("#testdiv").innerHeight()
* @result
[ 800px ]
* @result
800
*
*
* @name innerHeight
* @name innerHeight
* @type
jQuery
* @type
Number
* @cat Dimensions
* @cat Dimensions
*/
*/
$
.
fn
.
innerHeight
=
function
()
{
$
.
fn
.
innerHeight
=
function
()
{
if
(
this
.
get
(
0
)
==
window
||
this
.
get
(
0
)
==
document
)
return
this
.
height
();
return
this
.
get
(
0
)
==
window
||
this
.
get
(
0
)
==
document
?
return
this
.
get
(
0
).
offsetHeight
-
(
parseInt
(
this
.
css
(
"borderTop"
))
+
parseInt
(
this
.
css
(
"borderBottom"
)));
this
.
height
()
:
}
this
.
get
(
0
).
offsetHeight
-
parseInt
(
this
.
css
(
"borderTop"
))
-
parseInt
(
this
.
css
(
"borderBottom"
));
};
/**
/**
* Returns the inner width value (without border) for the first matched element.
* Returns the inner width value (without border) for the first matched element.
* If used on document, returns the document's Width (innerWidth)
* If used on document, returns the document's Width (innerWidth)
* If used on window, returns the viewport
s (window's
) width
* If used on window, returns the viewport
's (window
) width
*
*
* @example $("#testdiv").innerWidth()
* @example $("#testdiv").innerWidth()
* @result
[ 1000px ]
* @result
1000
*
*
* @name innerWidth
* @name innerWidth
* @type
jQuery
* @type
Number
* @cat Dimensions
* @cat Dimensions
*/
*/
$
.
fn
.
innerWidth
=
function
()
{
$
.
fn
.
innerWidth
=
function
()
{
if
(
this
.
get
(
0
)
==
window
||
this
.
get
(
0
)
==
document
)
return
this
.
width
();
return
this
.
get
(
0
)
==
window
||
this
.
get
(
0
)
==
document
?
return
this
.
get
(
0
).
offsetWidth
-
(
parseInt
(
this
.
css
(
"borderLeft"
))
+
parseInt
(
this
.
css
(
"borderRight"
)));
this
.
width
()
:
}
this
.
get
(
0
).
offsetWidth
-
parseInt
(
this
.
css
(
"borderLeft"
))
-
parseInt
(
this
.
css
(
"borderRight"
));
};
/**
/**
* Returns the outer height value (including border) for the first matched element.
* Returns the outer height value (including border) for the first matched element.
* Cannot be used on document or window.
* Cannot be used on document or window.
*
*
* @example $("#testdiv").outerHeight()
* @example $("#testdiv").outerHeight()
* @result
[ 1000px ]
* @result
1000
*
*
* @name outerHeight
* @name outerHeight
* @type
jQuery
* @type
Number
* @cat Dimensions
* @cat Dimensions
*/
*/
$
.
fn
.
outerHeight
=
function
()
{
$
.
fn
.
outerHeight
=
function
()
{
if
(
this
.
get
(
0
)
==
window
||
this
.
get
(
0
)
==
document
)
return
0
;
return
this
.
get
(
0
)
==
window
||
this
.
get
(
0
)
==
document
?
return
this
.
get
(
0
).
offsetHeight
;
this
.
height
()
:
}
this
.
get
(
0
).
offsetHeight
;
};
/**
/**
* Returns the outer width value (including border) for the first matched element.
* Returns the outer width value (including border) for the first matched element.
* Cannot be used on document or window.
* Cannot be used on document or window.
*
*
* @example $("#testdiv").outerWidth()
* @example $("#testdiv").outerWidth()
* @result
[ 1000px ]
* @result
1000
*
*
* @name outerWidth
* @name outerWidth
* @type
jQuery
* @type
Number
* @cat Dimensions
* @cat Dimensions
*/
*/
$
.
fn
.
outerWidth
=
function
()
{
$
.
fn
.
outerWidth
=
function
()
{
if
(
this
.
get
(
0
)
==
window
||
this
.
get
(
0
)
==
document
)
return
0
;
return
this
.
get
(
0
)
==
window
||
this
.
get
(
0
)
==
document
?
return
this
.
get
(
0
).
offsetWidth
;
this
.
width
()
:
}
this
.
get
(
0
).
offsetWidth
;
};
/**
/**
* Returns how many pixels the user has scrolled to the right (scrollLeft).
* Returns how many pixels the user has scrolled to the right (scrollLeft).
* Works on containers with overflow: auto and window/document.
* Works on containers with overflow: auto and window/document.
*
*
* @example $("#testdiv").scrollLeft()
* @example $("#testdiv").scrollLeft()
* @result
[ 100px ]
* @result
100
*
*
* @name scrollLeft
* @name scrollLeft
* @type
jQuery
* @type
Number
* @cat Dimensions
* @cat Dimensions
*/
*/
$
.
fn
.
scrollLeft
=
function
()
{
$
.
fn
.
scrollLeft
=
function
()
{
if
(
this
.
get
(
0
)
==
window
||
this
.
get
(
0
)
==
document
)
{
if
(
this
.
get
(
0
)
==
window
||
this
.
get
(
0
)
==
document
)
if
(
self
.
pageXOffset
)
return
self
.
pageXOffset
;
return
self
.
pageXOffset
||
else
if
(
document
.
documentElement
&&
document
.
documentElement
.
scrollLeft
)
return
document
.
documentElement
.
scrollLeft
;
jQuery
.
boxModel
&&
document
.
documentElement
.
scrollLeft
||
else
if
(
document
.
body
)
return
document
.
body
.
scrollLeft
;
document
.
body
.
scrollLeft
;
}
return
this
.
get
(
0
).
scrollLeft
;
return
this
.
get
(
0
).
scrollLeft
;
}
};
/**
/**
* Returns how many pixels the user has scrolled to the bottom (scrollTop).
* Returns how many pixels the user has scrolled to the bottom (scrollTop).
* Works on containers with overflow: auto and window/document.
* Works on containers with overflow: auto and window/document.
*
*
* @example $("#testdiv").scrollTop()
* @example $("#testdiv").scrollTop()
* @result
[ 100px ]
* @result
100
*
*
* @name scrollTop
* @name scrollTop
* @type
jQuery
* @type
Number
* @cat Dimensions
* @cat Dimensions
*/
*/
$
.
fn
.
scrollTop
=
function
()
{
$
.
fn
.
scrollTop
=
function
()
{
if
(
this
.
get
(
0
)
==
window
||
this
.
get
(
0
)
==
document
)
{
if
(
this
.
get
(
0
)
==
window
||
this
.
get
(
0
)
==
document
)
if
(
self
.
pageYOffset
)
return
self
.
pageYOffset
;
return
self
.
pageYOffset
||
else
if
(
document
.
documentElement
&&
document
.
documentElement
.
scrollTop
)
return
document
.
documentElement
.
scrollTop
;
jQuery
.
boxModel
&&
document
.
documentElement
.
scrollTop
||
else
if
(
document
.
body
)
return
document
.
body
.
scrollTop
;
document
.
body
.
scrollTop
;
}
return
this
.
get
(
0
).
scrollTop
;
return
this
.
get
(
0
).
scrollTop
;
}
};
\ No newline at end of file
\ No newline at end of file
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