Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@react-pdf-viewer/scroll-mode

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-pdf-viewer/scroll-mode - npm Package Compare versions

Comparing version 2.10.1 to 2.11.0

28

lib/cjs/scroll-mode.js

@@ -102,2 +102,3 @@ 'use strict';

var switchTo = function (newScrollMode) {
setScrollMode(newScrollMode);
var getPagesContainer = store.get('getPagesContainer');

@@ -128,13 +129,3 @@ if (!getPagesContainer) {

}
store.update('scrollMode', newScrollMode);
};
var handleScrollModeChanged = function (newScrollMode) {
setScrollMode(newScrollMode);
};
React__namespace.useEffect(function () {
store.subscribe('scrollMode', handleScrollModeChanged);
return function () {
store.unsubscribe('scrollMode', handleScrollModeChanged);
};
}, []);
return { scrollMode: scrollMode, switchTo: switchTo };

@@ -146,3 +137,6 @@ };

var _b = useScrollMode(store), scrollMode = _b.scrollMode, switchTo = _b.switchTo;
var onClick = function () { return switchTo(mode); };
var onClick = function () {
switchTo(mode);
store.update('scrollMode', mode);
};
var isSelected = scrollMode === mode;

@@ -167,3 +161,3 @@ var defaultChildren = function (props) { return (React__namespace.createElement(SwitchScrollModeButton, { isSelected: isSelected, mode: props.mode, onClick: props.onClick })); };

var isRtl = direction === core.TextDirection.RightToLeft;
var switchTo = useScrollMode(store).switchTo;
var _b = useScrollMode(store), scrollMode = _b.scrollMode, switchTo = _b.switchTo;
var handlePagesContainer = function (getPagesContainer) {

@@ -180,6 +174,13 @@ var pagesEle = getPagesContainer();

};
var handleScrollModeChanged = function (newScrollMode) {
if (newScrollMode !== scrollMode) {
switchTo(newScrollMode);
}
};
React__namespace.useEffect(function () {
store.subscribe('getPagesContainer', handlePagesContainer);
store.subscribe('scrollMode', handleScrollModeChanged);
return function () {
store.unsubscribe('getPagesContainer', handlePagesContainer);
store.unsubscribe('scrollMode', handleScrollModeChanged);
};

@@ -218,2 +219,5 @@ }, []);

renderViewer: renderViewer,
switchScrollMode: function (mode) {
store.update('scrollMode', mode);
},
SwitchScrollMode: SwitchScrollModeDecorator,

@@ -220,0 +224,0 @@ SwitchScrollModeButton: SwitchScrollModeButtonDecorator,

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("@react-pdf-viewer/core");function t(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var o,c=t(e);exports.ScrollMode=void 0,(o=exports.ScrollMode||(exports.ScrollMode={})).Horizontal="Horizontal",o.Vertical="Vertical",o.Wrapped="Wrapped";
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("@react-pdf-viewer/core");function o(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var t=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,t.get?t:{enumerable:!0,get:function(){return e[o]}})}})),r.default=e,Object.freeze(r)}var t,c=o(e);exports.ScrollMode=void 0,(t=exports.ScrollMode||(exports.ScrollMode={})).Horizontal="Horizontal",t.Vertical="Vertical",t.Wrapped="Wrapped";
/*! *****************************************************************************

@@ -16,2 +16,2 @@ Copyright (c) Microsoft Corporation.

***************************************************************************** */
var l=function(){return l=Object.assign||function(e){for(var r,t=1,o=arguments.length;t<o;t++)for(var c in r=arguments[t])Object.prototype.hasOwnProperty.call(r,c)&&(e[c]=r[c]);return e},l.apply(this,arguments)},n=function(){return c.createElement(r.Icon,{size:16},c.createElement("path",{d:"M6.5,21.5c0,0.552-0.448,1-1,1h-4c-0.552,0-1-0.448-1-1v-20c0-0.552,0.448-1,1-1h4c0.552,0,1,0.448,1,1V21.5z\n M14.5,21.5c0,0.552-0.448,1-1,1h-4c-0.552,0-1-0.448-1-1v-20c0-0.552,0.448-1,1-1h4c0.552,0,1,0.448,1,1V21.5z\n M22.5,21.5 c0,0.552-0.448,1-1,1h-4c-0.552,0-1-0.448-1-1v-20c0-0.552,0.448-1,1-1h4c0.552,0,1,0.448,1,1V21.5z"}))},i=function(){return c.createElement(r.Icon,{size:16},c.createElement("path",{d:"M23.5,5.5c0,0.552-0.448,1-1,1h-21c-0.552,0-1-0.448-1-1v-3c0-0.552,0.448-1,1-1h21c0.552,0,1,0.448,1,1V5.5z\n M23.5,13.5c0,0.552-0.448,1-1,1h-21c-0.552,0-1-0.448-1-1v-3c0-0.552,0.448-1,1-1h21c0.552,0,1,0.448,1,1V13.5z\n M23.5,21.5 c0,0.552-0.448,1-1,1h-21c-0.552,0-1-0.448-1-1v-3c0-0.552,0.448-1,1-1h21c0.552,0,1,0.448,1,1V21.5z"}))},a=function(){return c.createElement(r.Icon,{size:16},c.createElement("path",{d:"M10.5,9.5c0,0.552-0.448,1-1,1h-8c-0.552,0-1-0.448-1-1v-8c0-0.552,0.448-1,1-1h8c0.552,0,1,0.448,1,1V9.5z\n M23.5,9.5c0,0.552-0.448,1-1,1h-8c-0.552,0-1-0.448-1-1v-8c0-0.552,0.448-1,1-1h8c0.552,0,1,0.448,1,1V9.5z\n M10.5,22.5 c0,0.552-0.448,1-1,1h-8c-0.552,0-1-0.448-1-1v-8c0-0.552,0.448-1,1-1h8c0.552,0,1,0.448,1,1V22.5z\n M23.5,22.5c0,0.552-0.448,1-1,1 h-8c-0.552,0-1-0.448-1-1v-8c0-0.552,0.448-1,1-1h8c0.552,0,1,0.448,1,1V22.5z"}))},s=function(e){var t=e.children,o=e.mode,l=e.onClick,s=c.useContext(r.LocalizationContext).l10n,d="",u=c.createElement(i,null);switch(o){case exports.ScrollMode.Horizontal:d=s&&s.scrollMode?s.scrollMode.horizontalScrolling:"Horizontal scrolling",u=c.createElement(n,null);break;case exports.ScrollMode.Wrapped:d=s&&s.scrollMode?s.scrollMode.wrappedScrolling:"Wrapped scrolling",u=c.createElement(a,null);break;case exports.ScrollMode.Vertical:default:d=s&&s.scrollMode?s.scrollMode.verticalScrolling:"Vertical scrolling",u=c.createElement(i,null)}return t({icon:u,label:d,onClick:l})},d={left:0,top:8},u=function(e){var t=e.isSelected,o=e.mode,l=e.onClick;return c.createElement(s,{mode:o,onClick:l},(function(e){return c.createElement(r.Tooltip,{ariaControlsSuffix:"scroll-mode-switch",position:r.Position.BottomCenter,target:c.createElement(r.MinimalButton,{ariaLabel:e.label,isSelected:t,onClick:e.onClick},e.icon),content:function(){return e.label},offset:d})}))},m=function(e){var r=c.useState(e.get("scrollMode")||exports.ScrollMode.Vertical),t=r[0],o=r[1],l=function(e){o(e)};return c.useEffect((function(){return e.subscribe("scrollMode",l),function(){e.unsubscribe("scrollMode",l)}}),[]),{scrollMode:t,switchTo:function(r){var t=e.get("getPagesContainer");if(t){var o=t();if(o){switch(r){case exports.ScrollMode.Vertical:o.classList.add("rpv-scroll-mode__vertical"),o.classList.remove("rpv-scroll-mode__horizontal"),o.classList.remove("rpv-scroll-mode__wrapped");break;case exports.ScrollMode.Horizontal:o.classList.add("rpv-scroll-mode__horizontal"),o.classList.remove("rpv-scroll-mode__vertical"),o.classList.remove("rpv-scroll-mode__wrapped");break;case exports.ScrollMode.Wrapped:o.classList.add("rpv-scroll-mode__wrapped"),o.classList.remove("rpv-scroll-mode__vertical"),o.classList.remove("rpv-scroll-mode__horizontal")}e.update("scrollMode",r)}}}}},p=function(e){var r=e.children,t=e.mode,o=e.store,l=m(o),n=l.scrollMode,i=l.switchTo,a=n===t;return(r||function(e){return c.createElement(u,{isSelected:a,mode:e.mode,onClick:e.onClick})})({isSelected:a,mode:t,onClick:function(){return i(t)}})},f=function(e){var t=e.isSelected,o=e.mode,l=e.onClick;return c.createElement(s,{mode:o,onClick:l},(function(e){return c.createElement(r.MenuItem,{checked:t,icon:e.icon,onClick:e.onClick},e.label)}))},v=function(e){var t=e.store,o=c.useContext(r.ThemeContext).direction===r.TextDirection.RightToLeft,l=m(t).switchTo,n=function(e){var r=e();if(r){o?r.classList.add("rpv-scroll-mode--rtl"):r.classList.remove("rpv-scroll-mode--rtl");var c=t.get("scrollMode")||exports.ScrollMode.Vertical;c!==exports.ScrollMode.Vertical&&l(c)}};return c.useEffect((function(){return t.subscribe("getPagesContainer",n),function(){t.unsubscribe("getPagesContainer",n)}}),[]),c.createElement(c.Fragment,null)};exports.HorizontalScrollingIcon=n,exports.VerticalScrollingIcon=i,exports.WrappedScrollingIcon=a,exports.scrollModePlugin=function(e){var t=c.useMemo((function(){return r.createStore({scrollMode:e&&e.scrollMode?e.scrollMode:exports.ScrollMode.Vertical})}),[]),o=function(e){return c.createElement(p,l({},e,{store:t}))};return{install:function(e){t.update("getPagesContainer",e.getPagesContainer)},renderViewer:function(e){var r=e.slot;return r&&r.children&&(r.children=c.createElement(c.Fragment,null,c.createElement(v,{store:t}),r.children)),r},SwitchScrollMode:o,SwitchScrollModeButton:function(e){return c.createElement(o,{mode:e.mode},(function(e){return c.createElement(u,{isSelected:e.isSelected,mode:e.mode,onClick:function(){e.onClick()}})}))},SwitchScrollModeMenuItem:function(e){return c.createElement(o,{mode:e.mode},(function(r){return c.createElement(f,{isSelected:r.isSelected,mode:r.mode,onClick:function(){r.onClick(),e.onClick()}})}))}}};
var l=function(){return l=Object.assign||function(e){for(var r,o=1,t=arguments.length;o<t;o++)for(var c in r=arguments[o])Object.prototype.hasOwnProperty.call(r,c)&&(e[c]=r[c]);return e},l.apply(this,arguments)},n=function(){return c.createElement(r.Icon,{size:16},c.createElement("path",{d:"M6.5,21.5c0,0.552-0.448,1-1,1h-4c-0.552,0-1-0.448-1-1v-20c0-0.552,0.448-1,1-1h4c0.552,0,1,0.448,1,1V21.5z\n M14.5,21.5c0,0.552-0.448,1-1,1h-4c-0.552,0-1-0.448-1-1v-20c0-0.552,0.448-1,1-1h4c0.552,0,1,0.448,1,1V21.5z\n M22.5,21.5 c0,0.552-0.448,1-1,1h-4c-0.552,0-1-0.448-1-1v-20c0-0.552,0.448-1,1-1h4c0.552,0,1,0.448,1,1V21.5z"}))},i=function(){return c.createElement(r.Icon,{size:16},c.createElement("path",{d:"M23.5,5.5c0,0.552-0.448,1-1,1h-21c-0.552,0-1-0.448-1-1v-3c0-0.552,0.448-1,1-1h21c0.552,0,1,0.448,1,1V5.5z\n M23.5,13.5c0,0.552-0.448,1-1,1h-21c-0.552,0-1-0.448-1-1v-3c0-0.552,0.448-1,1-1h21c0.552,0,1,0.448,1,1V13.5z\n M23.5,21.5 c0,0.552-0.448,1-1,1h-21c-0.552,0-1-0.448-1-1v-3c0-0.552,0.448-1,1-1h21c0.552,0,1,0.448,1,1V21.5z"}))},a=function(){return c.createElement(r.Icon,{size:16},c.createElement("path",{d:"M10.5,9.5c0,0.552-0.448,1-1,1h-8c-0.552,0-1-0.448-1-1v-8c0-0.552,0.448-1,1-1h8c0.552,0,1,0.448,1,1V9.5z\n M23.5,9.5c0,0.552-0.448,1-1,1h-8c-0.552,0-1-0.448-1-1v-8c0-0.552,0.448-1,1-1h8c0.552,0,1,0.448,1,1V9.5z\n M10.5,22.5 c0,0.552-0.448,1-1,1h-8c-0.552,0-1-0.448-1-1v-8c0-0.552,0.448-1,1-1h8c0.552,0,1,0.448,1,1V22.5z\n M23.5,22.5c0,0.552-0.448,1-1,1 h-8c-0.552,0-1-0.448-1-1v-8c0-0.552,0.448-1,1-1h8c0.552,0,1,0.448,1,1V22.5z"}))},s=function(e){var o=e.children,t=e.mode,l=e.onClick,s=c.useContext(r.LocalizationContext).l10n,d="",u=c.createElement(i,null);switch(t){case exports.ScrollMode.Horizontal:d=s&&s.scrollMode?s.scrollMode.horizontalScrolling:"Horizontal scrolling",u=c.createElement(n,null);break;case exports.ScrollMode.Wrapped:d=s&&s.scrollMode?s.scrollMode.wrappedScrolling:"Wrapped scrolling",u=c.createElement(a,null);break;case exports.ScrollMode.Vertical:default:d=s&&s.scrollMode?s.scrollMode.verticalScrolling:"Vertical scrolling",u=c.createElement(i,null)}return o({icon:u,label:d,onClick:l})},d={left:0,top:8},u=function(e){var o=e.isSelected,t=e.mode,l=e.onClick;return c.createElement(s,{mode:t,onClick:l},(function(e){return c.createElement(r.Tooltip,{ariaControlsSuffix:"scroll-mode-switch",position:r.Position.BottomCenter,target:c.createElement(r.MinimalButton,{ariaLabel:e.label,isSelected:o,onClick:e.onClick},e.icon),content:function(){return e.label},offset:d})}))},m=function(e){var r=c.useState(e.get("scrollMode")||exports.ScrollMode.Vertical),o=r[0],t=r[1];return{scrollMode:o,switchTo:function(r){t(r);var o=e.get("getPagesContainer");if(o){var c=o();if(c)switch(r){case exports.ScrollMode.Vertical:c.classList.add("rpv-scroll-mode__vertical"),c.classList.remove("rpv-scroll-mode__horizontal"),c.classList.remove("rpv-scroll-mode__wrapped");break;case exports.ScrollMode.Horizontal:c.classList.add("rpv-scroll-mode__horizontal"),c.classList.remove("rpv-scroll-mode__vertical"),c.classList.remove("rpv-scroll-mode__wrapped");break;case exports.ScrollMode.Wrapped:c.classList.add("rpv-scroll-mode__wrapped"),c.classList.remove("rpv-scroll-mode__vertical"),c.classList.remove("rpv-scroll-mode__horizontal")}}}}},p=function(e){var r=e.children,o=e.mode,t=e.store,l=m(t),n=l.scrollMode,i=l.switchTo,a=n===o;return(r||function(e){return c.createElement(u,{isSelected:a,mode:e.mode,onClick:e.onClick})})({isSelected:a,mode:o,onClick:function(){i(o),t.update("scrollMode",o)}})},f=function(e){var o=e.isSelected,t=e.mode,l=e.onClick;return c.createElement(s,{mode:t,onClick:l},(function(e){return c.createElement(r.MenuItem,{checked:o,icon:e.icon,onClick:e.onClick},e.label)}))},v=function(e){var o=e.store,t=c.useContext(r.ThemeContext).direction===r.TextDirection.RightToLeft,l=m(o),n=l.scrollMode,i=l.switchTo,a=function(e){var r=e();if(r){t?r.classList.add("rpv-scroll-mode--rtl"):r.classList.remove("rpv-scroll-mode--rtl");var c=o.get("scrollMode")||exports.ScrollMode.Vertical;c!==exports.ScrollMode.Vertical&&i(c)}},s=function(e){e!==n&&i(e)};return c.useEffect((function(){return o.subscribe("getPagesContainer",a),o.subscribe("scrollMode",s),function(){o.unsubscribe("getPagesContainer",a),o.unsubscribe("scrollMode",s)}}),[]),c.createElement(c.Fragment,null)};exports.HorizontalScrollingIcon=n,exports.VerticalScrollingIcon=i,exports.WrappedScrollingIcon=a,exports.scrollModePlugin=function(e){var o=c.useMemo((function(){return r.createStore({scrollMode:e&&e.scrollMode?e.scrollMode:exports.ScrollMode.Vertical})}),[]),t=function(e){return c.createElement(p,l({},e,{store:o}))};return{install:function(e){o.update("getPagesContainer",e.getPagesContainer)},renderViewer:function(e){var r=e.slot;return r&&r.children&&(r.children=c.createElement(c.Fragment,null,c.createElement(v,{store:o}),r.children)),r},switchScrollMode:function(e){o.update("scrollMode",e)},SwitchScrollMode:t,SwitchScrollModeButton:function(e){return c.createElement(t,{mode:e.mode},(function(e){return c.createElement(u,{isSelected:e.isSelected,mode:e.mode,onClick:function(){e.onClick()}})}))},SwitchScrollModeMenuItem:function(e){return c.createElement(t,{mode:e.mode},(function(r){return c.createElement(f,{isSelected:r.isSelected,mode:r.mode,onClick:function(){r.onClick(),e.onClick()}})}))}}};

@@ -42,2 +42,3 @@ /**

export interface ScrollModePlugin extends Plugin {
switchScrollMode(mode: ScrollMode): void;
SwitchScrollMode(props: SwitchScrollModeProps): React.ReactElement;

@@ -44,0 +45,0 @@ SwitchScrollModeButton(props: SwitchScrollModeButtonProps): React.ReactElement;

{
"name": "@react-pdf-viewer/scroll-mode",
"version": "2.10.1",
"version": "2.11.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.10.1"
"@react-pdf-viewer/core": "2.11.0"
},

@@ -52,3 +52,3 @@ "peerDependencies": {

},
"gitHead": "1a83b6bdf2c509cccfca2c53cb946c4dd9ebffc7"
"gitHead": "5e4074055f48210e89c1fdf5b1cc53d78d56be44"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc