Skip to content

Commit

Permalink
Merge pull request #29 from leff/master
Browse files Browse the repository at this point in the history
Enhancement: Zoom amount and ZoomTo
  • Loading branch information
winkerVSbecks committed May 30, 2015
2 parents 3f60910 + 8ac0aab commit 4bc9c7c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/angular-pdf-viewer.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ pdfDelegate.$getByHandle('my-pdf-container').zoomIn();
The following methods are available to the delegate:
- prev
- next
- zoomIn
- zoomOut
- zoomIn(amount) *default amount = 0.2*
- zoomOut(amount) *default amount = 0.2*
- zoomTo(amount)
- rotate *(clockwise by 90 degrees)*
- getPageCount
- getCurrentPage
Expand Down
18 changes: 14 additions & 4 deletions src/js/pdf-ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,24 @@ angular.module('pdf')
renderPage(currentPage);
};

self.zoomIn = function() {
scale = parseFloat(scale) + 0.2;
self.zoomIn = function(amount) {
amount = amount || 0.2;
scale = parseFloat(scale) + amount;
renderPage(currentPage);
return scale;
};

self.zoomOut = function() {
scale = parseFloat(scale) - 0.2;
self.zoomOut = function(amount) {
amount = amount || 0.2;
scale = parseFloat(scale) - amount;
scale = (scale > 0) ? scale : 0.1;
renderPage(currentPage);
return scale;
};

self.zoomTo = function(zoomToScale) {
zoomToScale = (zoomToScale) ? zoomToScale : 1.0;
scale = parseFloat(zoomToScale);
renderPage(currentPage);
return scale;
};
Expand Down
1 change: 1 addition & 0 deletions src/js/pdf-viewer-delegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ angular.module('pdf', [])
'next',
'zoomIn',
'zoomOut',
'zoomTo',
'rotate',
'getPageCount',
'getCurrentPage',
Expand Down

0 comments on commit 4bc9c7c

Please sign in to comment.