mirror of
https://github.com/infeng/react-viewer.git
synced 2025-12-08 17:36:40 +00:00
add total name
This commit is contained in:
parent
3f37ab13ae
commit
1d7f81048d
@ -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 |
|
||||
|
||||
|
||||
@ -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 || (
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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})`}
|
||||
</span>}
|
||||
{props.showTotal
|
||||
&& <span className={`${props.prefixCls}-showTotal`}>{`${props.activeIndex + 1} of ${props.count}`}</span>}
|
||||
&& <span className={`${props.prefixCls}-showTotal`}>
|
||||
{`${props.activeIndex + 1} ${props.totalName} ${props.count}`}</span>}
|
||||
</p>
|
||||
) : null;
|
||||
let toolbars = props.toolbars;
|
||||
|
||||
@ -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',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user