adobe / balance-text

A plugin for implementing balancing of wrapping text in a web page
Other
1.39k stars 79 forks source link

balanceText isn't called on resize for manually triggered elements #55

Closed rileyjshaw closed 9 years ago

rileyjshaw commented 9 years ago

This might be by design, but calling $('.my-class').balanceText() doesn't attach resize handlers to the balanced element. This is unexpected behaviour for a polyfill, since alignment generally responds to resizing.

Not attaching a listener could be useful in some cases; for example, if hundreds of elements are dynamically added to the page, balanced, then replaced with other elements. This is an edge-case, and can be handled with a skipResize flag: $el.balanceText(true).

Users can implement their own debounce function in the meantime, but it's not ideal. Happy to make a PR if this is something you're interested in!

rileyjshaw commented 9 years ago

Thinking about this more, adding a skipResize flag seems like a bad idea - it complicates the polyfill for very little gain. The plugin should just handle resizes by default.

Would love to hear your thoughts!

redmunds commented 9 years ago

Yes, that would be cool but I haven't thought about how to implement it. Resizing is already de-bounced, so I don't see why not to always do it.

redmunds commented 9 years ago

Fixed by https://github.com/adobe-webplatform/balance-text/pull/58. Closing.