LeaVerou / inspire.js

Lean, hackable, extensible slide deck framework. Previously known as CSSS.
https://inspirejs.org
MIT License
1.73k stars 254 forks source link

Optimize font resizing process performances #18

Closed sleeper closed 12 years ago

sleeper commented 12 years ago

Previous font resizing for individual template was slow when there's a lot of content or 'non-resizable' items (i.e. only an image).

This change introduced 2 things:

LeaVerou commented 12 years ago

There's already a class to avoid resizing, it's called "dont-resize".

As for improving the resizing algorithm, I know it's slow and I'm all in for improvements. However, I'm not sure about this code. a) It uses functions where they're not really needed (only used in one place and not externally reusable as part of its API) b) I'm pretty sure the code could be shorter/cleaner.

So, I'm going to close this pull request. However, I think the font resizing algorithm is an area that needs LOTS of improvement in CSSS (it's slow and buggy), so I'd welcome future contributions. Maybe this one, after some refactoring?

Btw, my main reason for not using binary search to begin with was that it might end resizing it much more than needed. How does your code handle this case?

sleeper commented 12 years ago

Oki doki, I'm going to refactor it a bit: I did it in an hurry, while preparing a presentation at the last minute as usual.

Regarding your last question, actually I handled the case in a genuine manner: the criteria to end the search is mainly the distance between the 2 boundaries: the search will ends as soon as the difference between the boundaries is =< 1. This mainly ensure:

1) search ends ;)

2) in the favorable case, the font is "too large" for one of the boundaries, and just OK for the other one

3) in the not favorable case, the font is too large for both boundaries, meaning there's no font size in the start interval that could help resizing properly (agreed, this can be detected before, I guess, by checking the lower boundary).

Anyway, as said before, I'm going to give a try to a better refactoring, because these templates/slides are really good :)