jonom / jquery-focuspoint

jQuery plugin for 'responsive cropping'. Dynamically crop images to fill available space without cutting out the image's subject. Great for full-screen images.
Other
3.14k stars 211 forks source link

doesn't play well with ajaxified sites #19

Closed constb closed 10 years ago

constb commented 10 years ago

focuspoint doesn't have any "unfocus" method. on ajaxified site where content comes and goes there's no way to unbind focuspoint's "resize" handler so it'll stay forever trying to adjust non-existent containers.

the only workaround I see is to disable automatic adjust and trigger it manually for every "focuspointed" image in a single handwritten resize handler.

this also seems to be a good idea in case of multiple focuspointed images, since plugin creates separate resize handlers for each one of them. I wonder if this is any good for performance.

I think code structure should be different. You should have a single "resize" handler and an array of focuspointed elements, so calling $.fn.focuspoint would only add and remove elements from this array. And $(xxx).focuspoint({disable: true}) maybe?

jonom commented 10 years ago

@constb the latest update should help you out but feel free to submit a pull request if you want to take it further