rviscomi / trunk8

jQuery Truncation Plugin -- THIS PROJECT IS NO LONGER MAINTAINED
MIT License
703 stars 95 forks source link

Uncaught Error: Invalid bite size "-16" #71

Open ChrisCapasso opened 8 years ago

ChrisCapasso commented 8 years ago

After trying to write my own code I decided to use trunk8. I cannot get it to fire for some reason, and I am not sure what the issue is. I made the title the console error it throws. Here is the implementation: $(document).ready(function(){ $('.ui-tabs-anchor').each(function(){ $('.ui-tabs-anchor').trunk8({ width: 30 }); }); }); and the page it should be working on: http://nmhc.dev.1over0.com/Content.aspx?id=8500#tabs-2

Thanks for your help! Chris

rviscomi commented 8 years ago

Could you reproduce the issue in a jsfiddle? Also, you don't need the each().

Nefaro commented 8 years ago

http://jsfiddle.net/jL2g4qox/2/

The problem here is that the width can be larger than the actual input, in case, for example, where the width is calculated by javascript or where the input is variable-width.

While it is possible to do the width calculation before asking trunk8 to work its magic (that's what we do currently) it would be nice, if trunk8 would be the one to decide if truncation is needed or not.

Tnx for Your time and trunk8

rviscomi commented 8 years ago

Confirmed. Could you submit a pull request?

The else if block to handle fixed width truncation should have a check for negative bite_size and return early.