Skip to content

Commit

Permalink
added min width and height
Browse files Browse the repository at this point in the history
  • Loading branch information
benlumley committed Feb 2, 2011
1 parent dfd9cfa commit f477bda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 6 additions & 1 deletion README.md
Expand Up @@ -76,6 +76,10 @@ Pass in jQuery dom nodes for the form elements to read/write the position of the

Percentage of the image's dimensions to zoom/pan at once when the controls are clicked. In short, increase to make the plugin zoom/pan in larger steps, and vice versa

### min\_width, min\_height (20, 20)

The width/height of the image (according to the output co-ordinates) can't be less than the respective value here.

### debug

The plugin will console.log the current co-ordinates. Beware, will break things if console.log isn't available in your browser.
Expand Down Expand Up @@ -158,6 +162,7 @@ You can manually change the image position using something like:

Few extra utility methods
Rotation (supported browsers only)

Min and max size
Draggable snap


9 changes: 5 additions & 4 deletions jquery-panzoom-0.9.0.js
Expand Up @@ -39,6 +39,8 @@
out_y1 : false,
out_x2 : false,
out_y2 : false,
min_width : 20,
min_height : 20,
zoom_step : 5,
pan_step : 5,
debug : false,
Expand Down Expand Up @@ -215,7 +217,6 @@

// direct form input
if (settings.directedit) {
console.log('bindy');
$(settings.out_x1).add(settings.out_y1).add(settings.out_x2).add(settings.out_y2).bind('change.panZoom blur.panZoom', eventData, function(event) { event.data.target.panZoom('readPosition') } );
}

Expand Down Expand Up @@ -257,15 +258,15 @@
function validatePosition() {
var data = this.data('panZoom');
// if dimensions are zero...
if ( data.position.x2 - data.position.x1 < 1 || data.position.y2 - data.position.y1 < 1 ) {
if ( data.position.x2 - data.position.x1 < settings.min_width || data.position.y2 - data.position.y1 < settings.min_height ) {
// and second co-ords are zero (IE: no dims set), fit image
if (data.position.x2 == 0 || data.position.y2 == 0) {
methods.fit.apply(this);
}
// otherwise, backout a bit
else {
data.position.x2 = data.position.x1*1+1;
data.position.y2 = data.position.y1*1+1;
data.position.x2 = data.position.x1*1+settings.min_width;
data.position.y2 = data.position.y1*1+settings.min_height;
}
}

Expand Down

0 comments on commit f477bda

Please sign in to comment.