@internetarchive/bookreader 5.0.0-68 → 5.0.0-69

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 5.0.0-69
2
+ - Fix: Handle ppi incorrectly set to one @cdrini
3
+
1
4
  # 5.0.0-68
2
5
  - Fix: 1up zoom wrong on start/entering full screen @cdrini
3
6
  - Dev: BREAKING: delete `plugin.mobile_nav.js` no longer used @cdrini
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/bookreader",
3
- "version": "5.0.0-68",
3
+ "version": "5.0.0-69",
4
4
  "description": "The Internet Archive BookReader.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -352,8 +352,9 @@ export class PageModel {
352
352
  * @param {PageIndex} index
353
353
  */
354
354
  constructor(book, index) {
355
- // TODO: Get default from config
356
- this.ppi = book._getDataProp(index, 'ppi', book.ppi);
355
+ // Values less than 10 cause the UI to not work correctly
356
+ const pagePPI = book._getDataProp(index, 'ppi', book.ppi);
357
+ this.ppi = Math.max(pagePPI < 10 ? book.ppi : pagePPI, 10);
357
358
  this.book = book;
358
359
  this.index = index;
359
360
  this.width = book.getPageWidth(index);
@@ -24,8 +24,8 @@ const SAMPLE_DATA = [
24
24
 
25
25
  describe('getMedianPageSizeInches', () => {
26
26
  test('handles single page data', () => {
27
- const bm = new BookModel({ data: SAMPLE_DATA.slice(0, 1), options: {ppi: 1} });
28
- expect(bm.getMedianPageSizeInches()).toEqual({ width: 123, height: 123 });
27
+ const bm = new BookModel({ data: SAMPLE_DATA.slice(0, 1), options: {ppi: 10} });
28
+ expect(bm.getMedianPageSizeInches()).toEqual({ width: 12.3, height: 12.3 });
29
29
  });
30
30
 
31
31
  test('handles odd pages data', () => {
@@ -39,8 +39,8 @@ describe('getMedianPageSizeInches', () => {
39
39
  Object.assign(data[0][0], sizes[0]);
40
40
  Object.assign(data[1][0], sizes[1]);
41
41
  Object.assign(data[1][1], sizes[2]);
42
- const bm = new BookModel({ data, options: {ppi: 1} });
43
- expect(bm.getMedianPageSizeInches()).toEqual({ width: 200, height: 2200 });
42
+ const bm = new BookModel({ data, options: {ppi: 10} });
43
+ expect(bm.getMedianPageSizeInches()).toEqual({ width: 20, height: 220 });
44
44
  });
45
45
 
46
46
 
@@ -56,8 +56,8 @@ describe('getMedianPageSizeInches', () => {
56
56
  Object.assign(data[1][0], sizes[1]);
57
57
  Object.assign(data[1][1], sizes[2]);
58
58
  Object.assign(data[2][0], sizes[3]);
59
- const bm = new BookModel({ data, options: {ppi: 1} });
60
- expect(bm.getMedianPageSizeInches()).toEqual({ width: 300, height: 2300 });
59
+ const bm = new BookModel({ data, options: {ppi: 10} });
60
+ expect(bm.getMedianPageSizeInches()).toEqual({ width: 30, height: 230 });
61
61
  });
62
62
 
63
63
  test('does not lexicographic sort for median', () => {
@@ -71,8 +71,8 @@ describe('getMedianPageSizeInches', () => {
71
71
  Object.assign(data[0][0], sizes[0]);
72
72
  Object.assign(data[1][0], sizes[1]);
73
73
  Object.assign(data[1][1], sizes[2]);
74
- const bm = new BookModel({ data, options: {ppi: 1} });
75
- expect(bm.getMedianPageSizeInches()).toEqual({ width: 30, height: 30 });
74
+ const bm = new BookModel({ data, options: {ppi: 10} });
75
+ expect(bm.getMedianPageSizeInches()).toEqual({ width: 3, height: 3 });
76
76
  });
77
77
 
78
78
  test('caches result', () => {