Skip to content

Commit

Permalink
fix angular-pdf: patch issue #67
Browse files Browse the repository at this point in the history
- [X] use more verbose `pageToDisplay` instead `pageNum`
- [X] on init use `pageToDiplay` instead 1
- [X] add a check on parse the attrs to ensure it's an int (else fallback to 1)

fix #67
  • Loading branch information
simobasso committed Nov 19, 2015
1 parent 6362966 commit 1c963ec
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions dist/angular-pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
link: function(scope, element, attrs) {
var url = scope.pdfUrl;
var pdfDoc = null;
var pageNum = (attrs.page ? attrs.page : 1);
var pageToDisplay = isFinite(attrs.page) ? parseInt(attrs.page) : 1;
var pageFit = attrs.scale === 'page-fit';
var scale = attrs.scale > 0 ? attrs.scale : 1;
var canvasid = attrs.canvasid || 'pdf-canvas';
Expand All @@ -53,7 +53,7 @@
});

PDFJS.disableWorker = true;
scope.pageNum = pageNum;
scope.pageNum = pageToDisplay;

scope.renderPage = function(num) {
if (renderTask) {
Expand Down Expand Up @@ -190,7 +190,7 @@
if (newVal !== '') {
console.log('pdfUrl value change detected: ', scope.pdfUrl);
url = newVal;
scope.pageToDisplay = 1;
scope.pageToDisplay = pageToDisplay;
if (pdfLoaderTask) {
pdfLoaderTask.destroy().then(function () {
renderPDF();
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-pdf.min.js

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

6 changes: 3 additions & 3 deletions example/js/directives/angular-pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
link: function(scope, element, attrs) {
var url = scope.pdfUrl;
var pdfDoc = null;
var pageNum = (attrs.page ? attrs.page : 1);
var pageToDisplay = isFinite(attrs.page) ? parseInt(attrs.page) : 1;
var pageFit = attrs.scale === 'page-fit';
var scale = attrs.scale > 0 ? attrs.scale : 1;
var canvasid = attrs.canvasid || 'pdf-canvas';
Expand All @@ -53,7 +53,7 @@
});

PDFJS.disableWorker = true;
scope.pageNum = pageNum;
scope.pageNum = pageToDisplay;

scope.renderPage = function(num) {
if (renderTask) {
Expand Down Expand Up @@ -190,7 +190,7 @@
if (newVal !== '') {
console.log('pdfUrl value change detected: ', scope.pdfUrl);
url = newVal;
scope.pageToDisplay = 1;
scope.pageToDisplay = pageToDisplay;
if (pdfLoaderTask) {
pdfLoaderTask.destroy().then(function () {
renderPDF();
Expand Down

0 comments on commit 1c963ec

Please sign in to comment.