Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any ways to add icons to custom buttons? #20

Closed
No5972 opened this issue Feb 25, 2021 · 1 comment
Closed

Any ways to add icons to custom buttons? #20

No5972 opened this issue Feb 25, 2021 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@No5972
Copy link

No5972 commented Feb 25, 2021

Tried adding the keys of the custom buttons to icons but nothing happened.

var viewer = new PhotoViewer(items, {
  index: 0,
  footerToolbar: ['zoomIn','zoomOut','prev','fullscreen','next','actualSize','rotateRight','openInNew'],
  customButtons: {
    openInNew: {
      text: "新标签打开",
      title: "新标签打开",
      click: function (context, e) {
        window.open(context.img.src);
      }
    }
  },
  icons: {
	"openInNew": "<svg t=\"1614215430739\" class=\"icon\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"4559\" width=\"16\" height=\"16\"><path d=\"M810.666667 810.666667H213.333333V213.333333h298.666667V128H213.333333a85.333333 85.333333 0 0 0-85.333333 85.333333v597.333334a85.333333 85.333333 0 0 0 85.333333 85.333333h597.333334c46.933333 0 85.333333-38.4 85.333333-85.333333v-298.666667h-85.333333v298.666667zM597.333333 128v85.333333h153.173334l-419.413334 419.413334 60.16 60.16L810.666667 273.493333V426.666667h85.333333V128h-298.666667z\" p-id=\"4560\"></path></svg>"
}});

yjuiXq.png

@nzbin nzbin added the help wanted Extra attention is needed label Feb 25, 2021
@nzbin
Copy link
Owner

nzbin commented Feb 25, 2021

The custom buttons support html.

new PhotoViewer(items, {
  footerToolbar: [
    ...
    'myCustomButton'
  ],
  customButtons: {
    myCustomButton: {
      text: '<svg>...</svg>', // add your own svg icon
      title: 'custom!',
      click: function (context, e) {
        alert('clicked the custom button!');
      }
    }
  }
});

Demo: https://codepen.io/nzbin/pen/dyOJKXP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants