@react-pdf-viewer/zoom
Advanced tools
Comparing version 2.3.2 to 2.4.0
@@ -231,2 +231,8 @@ 'use strict'; | ||
}, | ||
zoomTo: function (scale) { | ||
var zoom = store.get('zoom'); | ||
if (zoom) { | ||
zoom(scale); | ||
} | ||
}, | ||
CurrentScale: CurrentScaleDecorator, | ||
@@ -233,0 +239,0 @@ ZoomIn: ZoomInDecorator, |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@react-pdf-viewer/core"),n=function(){return e.createElement(t.Icon,{size:16},e.createElement("path",{d:"M10.5,0.499c5.523,0,10,4.477,10,10s-4.477,10-10,10s-10-4.477-10-10S4.977,0.499,10.5,0.499z\n M23.5,23.499\n l-5.929-5.929\n M5.5,10.499h10\n M10.5,5.499v10"}))},o=function(){return e.createElement(t.Icon,{size:16},e.createElement("path",{d:"M10.5,0.499c5.523,0,10,4.477,10,10s-4.477,10-10,10s-10-4.477-10-10S4.977,0.499,10.5,0.499z\n M23.5,23.499\n l-5.929-5.929\n M5.5,10.499h10"}))},r=function(){return(r=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},c=function(t){var n=e.useState(t.get("scale")||0),o=n[0],r=n[1],c=function(e){r(e)};return e.useEffect((function(){return t.subscribe("scale",c),function(){t.unsubscribe("scale",c)}}),[]),{scale:o}},u=function(t){var n=t.children,o=t.store;return(n||function(t){return e.createElement(e.Fragment,null,Math.round(100*t.scale)+"%")})({scale:c(o).scale})},a=[.5,.75,1,1.25,1.5,2,3,4],i={left:0,top:8},l=function(n){var o=n.scale,r=n.onZoom,c=e.useContext(t.LocalizationContext);return e.createElement(t.Popover,{position:t.Position.BottomCenter,target:function(t){return e.createElement("span",{className:"rpv-zoom-popover-target",onClick:function(){t()}},e.createElement("span",{className:"rpv-zoom-popover-target-scale"},Math.round(100*o),"%"),e.createElement("span",{className:"rpv-zoom-popover-target-arrow"}))},content:function(n){return e.createElement(t.Menu,null,Object.keys(t.SpecialZoomLevel).map((function(o){var u=o;return e.createElement(t.MenuItem,{key:u,onClick:function(){n(),r(u)}},function(e){switch(e){case t.SpecialZoomLevel.ActualSize:return c&&c.zoom?c.zoom.actualSize:"Actual size";case t.SpecialZoomLevel.PageFit:return c&&c.zoom?c.zoom.pageFit:"Page fit";case t.SpecialZoomLevel.PageWidth:return c&&c.zoom?c.zoom.pageWidth:"Page width"}}(u))})),e.createElement(t.MenuDivider,null),a.map((function(o){return e.createElement(t.MenuItem,{key:o,onClick:function(){n(),r(o)}},Math.round(100*o)+"%")})))},offset:i,closeOnClickOutside:!0,closeOnEscape:!0})},m=function(t){var n=t.children,o=t.store;return(n||function(t){return e.createElement(l,{scale:t.scale,onZoom:t.onZoom})})({scale:c(o).scale,onZoom:function(e){var t=o.get("zoom");t&&t(e)}})},s={left:0,top:8},f=function(o){var r=o.onClick,c=e.useContext(t.LocalizationContext),u=c&&c.zoom?c.zoom.zoomIn:"Zoom in";return e.createElement(t.Tooltip,{position:t.Position.BottomCenter,target:e.createElement(t.Button,{onClick:r},e.createElement(n,null)),content:function(){return u},offset:s})},p=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.3,1.5,1.7,1.9,2.1,2.4,2.7,3,3.3,3.7,4.1,4.6,5.1,5.7,6.3,7,7.7,8.5,9.4,10],E=function(t){var n=t.children,o=t.store,r=c(o).scale;return(n||function(t){return e.createElement(f,{onClick:t.onClick})})({onClick:function(){var e,t=o.get("zoom");t&&t((e=r,p.find((function(t){return t>e}))||e))}})},v={left:0,top:8},z=function(n){var r=n.onClick,c=e.useContext(t.LocalizationContext),u=c&&c.zoom?c.zoom.zoomOut:"Zoom out";return e.createElement(t.Tooltip,{position:t.Position.BottomCenter,target:e.createElement(t.Button,{onClick:r},e.createElement(o,null)),content:function(){return u},offset:v})},C=function(t){var n=t.children,o=t.store,r=c(o).scale;return(n||function(t){return e.createElement(z,{onClick:t.onClick})})({onClick:function(){var e,t,n=o.get("zoom");n&&n((e=r,-1===(t=p.findIndex((function(t){return t>=e})))||0===t?e:p[t-1]))}})};exports.ZoomInIcon=n,exports.ZoomOutIcon=o,exports.zoomPlugin=function(){var n=e.useMemo((function(){return t.createStore({})}),[]),o=function(t){return e.createElement(E,r({},t,{store:n}))},c=function(t){return e.createElement(C,r({},t,{store:n}))},a=function(t){return e.createElement(m,r({},t,{store:n}))};return{install:function(e){n.update("zoom",e.zoom)},onViewerStateChange:function(e){return n.update("scale",e.scale),e},CurrentScale:function(t){return e.createElement(u,r({},t,{store:n}))},ZoomIn:o,ZoomInButton:function(){return e.createElement(o,null,(function(t){return e.createElement(f,r({},t))}))},ZoomOut:c,ZoomOutButton:function(){return e.createElement(c,null,(function(t){return e.createElement(z,r({},t))}))},Zoom:a,ZoomPopover:function(){return e.createElement(a,null,(function(t){return e.createElement(l,r({},t))}))}}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@react-pdf-viewer/core"),n=function(){return e.createElement(t.Icon,{size:16},e.createElement("path",{d:"M10.5,0.499c5.523,0,10,4.477,10,10s-4.477,10-10,10s-10-4.477-10-10S4.977,0.499,10.5,0.499z\n M23.5,23.499\n l-5.929-5.929\n M5.5,10.499h10\n M10.5,5.499v10"}))},o=function(){return e.createElement(t.Icon,{size:16},e.createElement("path",{d:"M10.5,0.499c5.523,0,10,4.477,10,10s-4.477,10-10,10s-10-4.477-10-10S4.977,0.499,10.5,0.499z\n M23.5,23.499\n l-5.929-5.929\n M5.5,10.499h10"}))},r=function(){return(r=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},c=function(t){var n=e.useState(t.get("scale")||0),o=n[0],r=n[1],c=function(e){r(e)};return e.useEffect((function(){return t.subscribe("scale",c),function(){t.unsubscribe("scale",c)}}),[]),{scale:o}},u=function(t){var n=t.children,o=t.store;return(n||function(t){return e.createElement(e.Fragment,null,Math.round(100*t.scale)+"%")})({scale:c(o).scale})},a=[.5,.75,1,1.25,1.5,2,3,4],i={left:0,top:8},l=function(n){var o=n.scale,r=n.onZoom,c=e.useContext(t.LocalizationContext);return e.createElement(t.Popover,{position:t.Position.BottomCenter,target:function(t){return e.createElement("span",{className:"rpv-zoom-popover-target",onClick:function(){t()}},e.createElement("span",{className:"rpv-zoom-popover-target-scale"},Math.round(100*o),"%"),e.createElement("span",{className:"rpv-zoom-popover-target-arrow"}))},content:function(n){return e.createElement(t.Menu,null,Object.keys(t.SpecialZoomLevel).map((function(o){var u=o;return e.createElement(t.MenuItem,{key:u,onClick:function(){n(),r(u)}},function(e){switch(e){case t.SpecialZoomLevel.ActualSize:return c&&c.zoom?c.zoom.actualSize:"Actual size";case t.SpecialZoomLevel.PageFit:return c&&c.zoom?c.zoom.pageFit:"Page fit";case t.SpecialZoomLevel.PageWidth:return c&&c.zoom?c.zoom.pageWidth:"Page width"}}(u))})),e.createElement(t.MenuDivider,null),a.map((function(o){return e.createElement(t.MenuItem,{key:o,onClick:function(){n(),r(o)}},Math.round(100*o)+"%")})))},offset:i,closeOnClickOutside:!0,closeOnEscape:!0})},m=function(t){var n=t.children,o=t.store;return(n||function(t){return e.createElement(l,{scale:t.scale,onZoom:t.onZoom})})({scale:c(o).scale,onZoom:function(e){var t=o.get("zoom");t&&t(e)}})},s={left:0,top:8},f=function(o){var r=o.onClick,c=e.useContext(t.LocalizationContext),u=c&&c.zoom?c.zoom.zoomIn:"Zoom in";return e.createElement(t.Tooltip,{position:t.Position.BottomCenter,target:e.createElement(t.Button,{onClick:r},e.createElement(n,null)),content:function(){return u},offset:s})},p=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.3,1.5,1.7,1.9,2.1,2.4,2.7,3,3.3,3.7,4.1,4.6,5.1,5.7,6.3,7,7.7,8.5,9.4,10],E=function(t){var n=t.children,o=t.store,r=c(o).scale;return(n||function(t){return e.createElement(f,{onClick:t.onClick})})({onClick:function(){var e,t=o.get("zoom");t&&t((e=r,p.find((function(t){return t>e}))||e))}})},v={left:0,top:8},z=function(n){var r=n.onClick,c=e.useContext(t.LocalizationContext),u=c&&c.zoom?c.zoom.zoomOut:"Zoom out";return e.createElement(t.Tooltip,{position:t.Position.BottomCenter,target:e.createElement(t.Button,{onClick:r},e.createElement(o,null)),content:function(){return u},offset:v})},C=function(t){var n=t.children,o=t.store,r=c(o).scale;return(n||function(t){return e.createElement(z,{onClick:t.onClick})})({onClick:function(){var e,t,n=o.get("zoom");n&&n((e=r,-1===(t=p.findIndex((function(t){return t>=e})))||0===t?e:p[t-1]))}})};exports.ZoomInIcon=n,exports.ZoomOutIcon=o,exports.zoomPlugin=function(){var n=e.useMemo((function(){return t.createStore({})}),[]),o=function(t){return e.createElement(E,r({},t,{store:n}))},c=function(t){return e.createElement(C,r({},t,{store:n}))},a=function(t){return e.createElement(m,r({},t,{store:n}))};return{install:function(e){n.update("zoom",e.zoom)},onViewerStateChange:function(e){return n.update("scale",e.scale),e},zoomTo:function(e){var t=n.get("zoom");t&&t(e)},CurrentScale:function(t){return e.createElement(u,r({},t,{store:n}))},ZoomIn:o,ZoomInButton:function(){return e.createElement(o,null,(function(t){return e.createElement(f,r({},t))}))},ZoomOut:c,ZoomOutButton:function(){return e.createElement(c,null,(function(t){return e.createElement(z,r({},t))}))},Zoom:a,ZoomPopover:function(){return e.createElement(a,null,(function(t){return e.createElement(l,r({},t))}))}}}; |
@@ -66,2 +66,3 @@ /** | ||
export interface ZoomPlugin extends Plugin { | ||
zoomTo: (scale: number | SpecialZoomLevel) => void; | ||
CurrentScale: (props: CurrentScaleProps) => React.ReactElement; | ||
@@ -68,0 +69,0 @@ ZoomIn: (props: ZoomInProps) => React.ReactElement; |
{ | ||
"name": "@react-pdf-viewer/zoom", | ||
"version": "2.3.2", | ||
"version": "2.4.0", | ||
"description": "A React component to view a PDF document", | ||
@@ -36,3 +36,3 @@ "license": "https://react-pdf-viewer.dev/license", | ||
"dependencies": { | ||
"@react-pdf-viewer/core": "2.3.2" | ||
"@react-pdf-viewer/core": "2.4.0" | ||
}, | ||
@@ -50,5 +50,6 @@ "peerDependencies": { | ||
"js": "cp src/index.d.ts lib && cp dist/index.js lib && rollup -c ../../rollup.config.js", | ||
"css": "rm lib/styles/index.less && postcss lib/styles/index.css > lib/styles/index.min.css" | ||
"css": "lessc src/styles/index.less lib/styles/index.temp.css && postcss lib/styles/index.temp.css > lib/styles/index.css && rm -rf lib/styles/index.temp.css", | ||
"test": "jest --config ../../jest.config.js" | ||
}, | ||
"gitHead": "6c911fcc09cbd5cff03c3c9ebb3c3a7736e40fae" | ||
"gitHead": "09ee35ddfbac935d8e6b266f2c1cd1421171db93" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19094
7
323
+ Added@react-pdf-viewer/core@2.4.0(transitive)
- Removed@react-pdf-viewer/core@2.3.2(transitive)
Updated@react-pdf-viewer/core@2.4.0