openseadragon/openseadragon — pull request #423 by henri-astre-msft (2014-06-18 18:39:53+00:00)
Title: add fitBoundsWithConstraints() to the viewport.

Hi,

I've added fitBoundsWithConstraints() to the viewport.
IMO this should be the default behavior of fitBounds() and fitBounds() should be renamed to fitBoundsWithoutConstraints() :smile:

fitBoundsWithConstraints() is basically a mix of fitBounds() and applyConstraints().
If you call:
```javascript
viewport.fitBounds(bounds).applyConstraints();
```
you won't have the same result as with:
```javascript
viewport.fitBoundsWithConstraints(bounds);
```

I'm using this for the [new highlight feature](http://blogs.msdn.com/b/photosynth/archive/2014/06/10/highlights-and-geo-browsing-come-to-the-photosynth-tech-preview.aspx) of [photosynth2] (http://photosynth.net/preview/). Well, right now I've implemented fitBoundsWithConstraints() outside of Openseadragon but I think that it should be part of it.

Basically right now if you call:
```javascript
viewport.fitBounds(bounds);
```
Then the highlight is centered on the screen but can be too zoomed in or out of screen (= is not respecting constraints).

And if you call:
```javascript
viewport.fitBounds(bounds).applyConstraints();
```
Then the motion is respecting constraints but the highlight is not centered :disappointed:

I understand that you would need a test case to accept this change...
But let me know what you think of this change.

Thanks,
--Henri