Skip to content

Commit 85238ef

Browse files
Merge pull request #23 from vaadin-component-factory/feat/dynamic-zoom-labels
Feat/dynamic zoom labels
2 parents c11cbec + 5869d31 commit 85238ef

File tree

2 files changed

+41
-35
lines changed

2 files changed

+41
-35
lines changed

package.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vaadin-component-factory/vcf-pdf-viewer",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "Polymer element providing pdf viewer",
55
"main": "vcf-pdf-viewer.js",
66
"repository": {
@@ -25,47 +25,47 @@
2525
],
2626
"dependencies": {
2727
"@polymer/polymer": "^3.4.1",
28+
"@vaadin/button": "^24.1.1",
2829
"@vaadin/component-base": "^24.1.1",
29-
"@vaadin/vaadin-lumo-styles": "^24.1.1",
30-
"@vaadin/vaadin-material-styles": "^24.1.1",
31-
"@vaadin/text-field": "^24.1.1",
32-
"@vaadin/vaadin-themable-mixin": "^24.1.1",
30+
"@vaadin/icon": "^24.1.1",
3331
"@vaadin/item": "^24.1.1",
3432
"@vaadin/list-box": "^24.1.1",
3533
"@vaadin/select": "^24.1.1",
36-
"@vaadin/button": "^24.1.1",
37-
"@vaadin/icon": "^24.1.1",
34+
"@vaadin/text-field": "^24.1.1",
35+
"@vaadin/vaadin-lumo-styles": "^24.1.1",
36+
"@vaadin/vaadin-material-styles": "^24.1.1",
37+
"@vaadin/vaadin-themable-mixin": "^24.1.1",
3838
"core-js": "^3.19.0",
3939
"dommatrix": "^0.0.6",
4040
"web-streams-polyfill": "^3.1.1"
4141
},
4242
"devDependencies": {
43+
"@babel/core": "^7.16.0",
44+
"@babel/plugin-proposal-logical-assignment-operators": "^7.16.0",
45+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
46+
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
47+
"@babel/plugin-transform-runtime": "^7.16.0",
48+
"@babel/preset-env": "^7.16.0",
49+
"@babel/runtime-corejs3": "^7.16.3",
4350
"@polymer/iron-component-page": "^4.0.0",
4451
"@polymer/iron-demo-helpers": "^3.0.0-pre.19",
52+
"@rollup/plugin-babel": "5.3.0",
53+
"@rollup/plugin-commonjs": "^21.0.1",
54+
"@rollup/plugin-node-resolve": "^13.0.6",
4555
"@vaadin/polymer-legacy-adapter": "22.0.1",
4656
"@webcomponents/webcomponentsjs": "^2.6.0",
47-
"regenerator-runtime": "^0.13.5",
48-
"@babel/core": "^7.16.0",
49-
"@babel/preset-env": "^7.16.0",
50-
"@babel/plugin-transform-runtime": "^7.16.0",
51-
"@babel/runtime-corejs3": "^7.16.3",
52-
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
53-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
54-
"@babel/plugin-proposal-logical-assignment-operators": "^7.16.0",
5557
"babel-loader": "^8.2.3",
5658
"html-webpack-plugin": "^5.5.0",
57-
"webpack": "^5.61.0",
58-
"webpack-cli": "^4.9.1",
59-
"webpack-dev-server": "^4.4.0",
59+
"regenerator-runtime": "^0.13.5",
6060
"rimraf": "^3.0.2",
6161
"rollup": "^2.59.0",
62-
"@rollup/plugin-babel": "5.3.0",
63-
"@rollup/plugin-node-resolve": "^13.0.6",
64-
"@rollup/plugin-commonjs": "^21.0.1",
6562
"rollup-plugin-copy": "^3.4.0",
6663
"rollup-plugin-filesize": "^9.1.1",
6764
"rollup-plugin-minify-html-literals": "^1.2.6",
68-
"rollup-plugin-terser": "^7.0.2"
65+
"rollup-plugin-terser": "^7.0.2",
66+
"webpack": "^5.61.0",
67+
"webpack-cli": "^4.9.1",
68+
"webpack-dev-server": "^4.4.0"
6969
},
7070
"scripts": {
7171
"test": "wct",

src/vcf-pdf-viewer.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ class PdfViewerElement extends
263263
<vaadin-icon part="toggle-button-icon" slot="prefix"></vaadin-icon>
264264
</vaadin-button>
265265
<span id="title" part="toolbar-text toolbar-title">{{__title}}</span>
266-
<vaadin-select id="zoom" part="toolbar-zoom" value="{{zoom}}">
266+
<vaadin-select id="zoom" part="toolbar-zoom" value="{{zoom}}" items="[[__zoomItems]]">
267267
</vaadin-select>
268268
<div part="toolbar-pages">
269269
<vaadin-text-field id="currentPage" part="toolbar-current-page" value="{{currentPage}}" on-change="__pageChange"></vaadin-text-field>
@@ -432,9 +432,27 @@ class PdfViewerElement extends
432432
type: Boolean,
433433
value: false
434434
},
435+
__zoomItems: {
436+
computed: '__computeZoomItems(autoZoomOptionLabel, fitZoomOptionLabel)'
437+
}
435438
};
436439
}
437440

441+
__computeZoomItems(autoZoomOptionLabel, fitZoomOptionLabel) {
442+
return [
443+
{ label: autoZoomOptionLabel, value:'auto' },
444+
{ label: fitZoomOptionLabel, value:'page-fit' },
445+
{ label: '50%', value:'0.5' },
446+
{ label: '75%', value:'0.75' },
447+
{ label: '100%', value:'1.0' },
448+
{ label: '125%', value:'1.25' },
449+
{ label: '150%', value:'1.5' },
450+
{ label: '200%', value:'2.0' },
451+
{ label: '300%', value:'3.0' },
452+
{ label: '400%', value:'4.0' }
453+
]
454+
}
455+
438456
static get observers() {
439457
return [
440458
'__setTitle(__pdfTitle, __filename)',
@@ -536,18 +554,6 @@ class PdfViewerElement extends
536554
this.__resizeObserver = new ResizeObserver(() => {
537555
requestAnimationFrame(() => this.__recalculateSizes());
538556
});
539-
this.$.zoom.items = [
540-
{ label: this.autoZoomOptionLabel, value:'auto' },
541-
{ label: this.fitZoomOptionLabel, value:'page-fit' },
542-
{ label: '50%', value:'0.5' },
543-
{ label: '75%', value:'0.75' },
544-
{ label: '100%', value:'1.0' },
545-
{ label: '125%', value:'1.25' },
546-
{ label: '150%', value:'1.5' },
547-
{ label: '200%', value:'2.0' },
548-
{ label: '300%', value:'3.0' },
549-
{ label: '400%', value:'4.0' }
550-
];
551557

552558
this.__resizeObserver.observe(this);
553559
}

0 commit comments

Comments
 (0)