diff --git a/README.md b/README.md index 996eac5..15f73b9 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ I'm sorry, ssr is not currently supported in `3.x`, it will be fixed in `4.0`. | downloadInNewWindow | boolean | false | whether to download in a new window | false | | className | string | - | customized CSS class | false | | showTotal | boolean | true | whether to display the total number and range | false | +| totalName | string | 'of' | total image separator name | false | | maxScale | number | - | maximum scaling | false | | minScale | number | 0.1 | minimum scaling | false | diff --git a/src/ViewerCore.tsx b/src/ViewerCore.tsx index 9197954..7835332 100644 --- a/src/ViewerCore.tsx +++ b/src/ViewerCore.tsx @@ -71,6 +71,7 @@ export default (props: ViewerProps) => { noImgDetails = false, noToolbar = false, showTotal = true, + totalName = 'of', minScale = 0.1, } = props; @@ -704,6 +705,7 @@ export default (props: ViewerProps) => { activeIndex={state.activeIndex} count={images.length} showTotal={showTotal} + totalName={totalName} /> )} {props.noNavbar || ( diff --git a/src/ViewerProps.ts b/src/ViewerProps.ts index 83efdc2..ea1574b 100644 --- a/src/ViewerProps.ts +++ b/src/ViewerProps.ts @@ -109,6 +109,9 @@ interface ViewerProps { // whether to display the total number and range showTotal?: boolean; + // total indicator name. + totalName?: string; + // max scale maxScale?: number; diff --git a/src/ViewerToolbar.tsx b/src/ViewerToolbar.tsx index 13aa0f1..d4715f7 100644 --- a/src/ViewerToolbar.tsx +++ b/src/ViewerToolbar.tsx @@ -19,6 +19,7 @@ export interface ViewerToolbarProps { activeIndex: number; count: number; showTotal: boolean; + totalName: string; } export const defaultToolbars: ToolbarConfig[] = [ @@ -103,7 +104,8 @@ export default function ViewerToolbar(props: ViewerToolbarProps) { {`(${props.width} x ${props.height})`} } {props.showTotal - && {`${props.activeIndex + 1} of ${props.count}`}} + && + {`${props.activeIndex + 1} ${props.totalName} ${props.count}`}}

) : null; let toolbars = props.toolbars; diff --git a/src/__tests__/viewer.test.tsx b/src/__tests__/viewer.test.tsx index 4e34efd..9172f80 100644 --- a/src/__tests__/viewer.test.tsx +++ b/src/__tests__/viewer.test.tsx @@ -768,6 +768,18 @@ describe('Viewer', () => { expect($$('.react-viewer-showTotal')[0].innerHTML).toBe('2 of 2'); }); + it('showTotal', () => { + viewerHelper.new({ + className: 'my-react-viewer', + totalName: 'de', + }); + viewerHelper.open(); + + expect($$('.react-viewer-showTotal')[0].innerHTML).toBe('1 de 2'); + triggerKeyboard(document, 'keydown', 39); + expect($$('.react-viewer-showTotal')[0].innerHTML).toBe('2 de 2'); + }); + it('max scale and min scale', () => { viewerHelper.new({ className: 'my-react-viewer',