jeffchan / truncate.js

fast, intelligent javascript text truncation
MIT License
98 stars 45 forks source link

Modify .update() to work when called on an expanded container. #4

Closed aron closed 11 years ago

aron commented 11 years ago

Now rather than always truncating when calling .update() we update the cached property as before but if the content was originally expanded we restore it at the end of the method.

We also split out the collapsed and truncated states into separate variables as they are individual properties of the object. It is sometimes useful to know when the content is truncated even though it is expanded for example.

This pull makes it much easier to recalculate truncations when the window is resized.

jQuery(window).on('resize', function () { $truncated.truncate('update'); });