Plugins

User login
Can't find a Plugin?

Can't find a Plugin you are looking for? Check out the jQuery Wiki page.

Are you a plugin developer? Please move your plugin over to this site.

Website Bug or Feature Request?

Found a bug on the new jQuery Plugin website? Have a feature request?

Submit it to the jQuery Plugin website issue queue to ensure it is noticed!

scrollWidth


Project:Dimensions
Version:1.1.2
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:brandon
Status:active
Description

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 :).

AttachmentSize
jquery.dimensions.js_.txt3.9 KB

Comments

#1

Assigned to:Anonymous» brandon

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.