scrollWidth
| Project: | Dimensions |
| Version: | 1.1.2 |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | brandon |
| Status: | active |
Jump to:
Hi! I needed a way to get and set the scrollWidth of an element. But it wasn't in dimensions. So I copy-pasted the scrollLeft/scrollTop method and rearranged it for scrollWidth. I don't know if my "patch" is the best ever but it works fine :) (perfect for something made in 2 minits :p).
// Create scrollWidth method
$.fn[ 'scrollWidth' ] = function(val) {
if (!this[0]) return;
return val != undefined ?
// Set the scrollWidth
this.each(function() {
this == window || this == document ?
window.scrollWidth( val ) :
this[ 'scrollWidth' ] = val;
}) :
// Return the scrollWidth
this[0] == window || this[0] == document ?
self[ 'scrollWidth' ] ||
$.boxModel && document.documentElement[ 'scrollWidth' ] ||
document.body[ 'scrollWidth' ] :
this[0][ 'scrollWidth' ];
};So, include it in the next release if you think it's useful for the World ^^. Anyway it helped me.
Thanks for your work :).
| Attachment | Size |
|---|---|
| jquery.dimensions.js_.txt | 3.9 KB |

Comments
#1
I've been thinking about including a scrollWidth/Height method into Dimensions. The one issue keeping it out right now is the nasty Firefox bug where scrollWidth reports the offsetWidth. We just fixed this issue in the Core for width/height of the document but still need a solution for regular elements.