adobe / balance-text

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

Provide configuration options via the interface #99

Open BrianGenisio opened 7 years ago

BrianGenisio commented 7 years ago

One limitation I've hit a couple of times has been the 5000 character limit which is somewhat arbitrary. I changed some copy from 4990 to 5010 characters the other day and it all-of-a-sudden stopped working.

Is there a philosophical reason for a limit that large? Is it based on empirical evidence? Or is it mostly just arbitrary?

Was thinking we could have a way of changing that default? Perhaps globally, as well as per-call.

balanceText.config({maxTextWidth: 12345}); // global setting
balanceText(el, {maxTextWidth: 12345}); // per-call
balanceText(el, {anyTextWidth: true}); // perhaps just disable the check?

I'm happy to do the work if we decide this is the way to go... just thought I'd put it out there as a discussion point. Will there be other config settings we care about such that we setup a good pattern for it?

redmunds commented 7 years ago

@BrianGenisio Totally arbitrary. Making this configurable would be great!

redmunds commented 7 years ago

I think a global config setting would be sufficient:

balanceText.config({maxTextWidth: 12345}); // global setting

This could be set to a very high value to effectively turn off check. This is mostly a fail safe for people that accidentally add the setting to a ridiculously long piece of text to prevent page from "freezing". I don't know why anyone would want to have a different value for different parts of page (i.e. setting per call).