npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-dark-photo

v1.0.28

Published

![demo1.gif](https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/3248bfb1e99e4e798c8fdb60cdf1dfbc~tplv-k3u1fbpfcp-watermark.image)

Readme

先上效果图

demo1.gif

demo2 .gif

demo3.gif

演示地址(vue版和react版一样)

https://dark2017.github.io/vue-dark-photo.github.io/

react-dark-photo

  • 基于 react17.x 开发的预览图片组件
  • 支持 放大、缩小、复原、下载、打印、旋转、拖拽等功能
  • 支持png、jpg、jpge、bmp、gif等常见图片格式
  • 支持查看多个图片
  • 开箱即用 只需传图片数据 轻便简单
  • GitHub地址:https://github.com/Dark2017/react-dark-photo
  • vue同款:https://github.com/Dark2017/vue-dark-photo

安装使用说明

react-dark-photo

npm i react-dark-photo

// 引入组件和样式
import { ReactDarkPhoto } from 'react-dark-photo'
import 'react-dark-photo/lib/style.css'

例1:
var imgData = 'xxx'
export default class App extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      showBox: true
    }
  }
  close = () => {
    this.setState({
      showBox: false
    })
  }
  open = () => {
    this.setState({
      showBox: true
    })
  }
  render() {
    return (
      <div>
        <button onClick={this.open}>open</button>
        <ReactDarkPhoto 
          showBox={this.state.showBox}
          imgData={imgData}
          close={this.close}
        />
      </div>
    )
  }
}

api

属性

| 属性值 | 类型 | 描述 | 默认值 | | --- | --- | --- | --- | imgData | string | 图片地址(url) | - | imgArr | Array | 图片地址(数组) | - | showBox | Boolean | 控制图片预览器显隐 | false | customAction | Object | 自定义操作栏 | null | isHint | Boolean | 是否展示提示(第一张或最后一张) | true | ifWave | Boolean | 是否点击波纹特效 | false | isAnimation | Boolean | 是否动画特效 | false

customAction

| 属性值 | 类型 | 描述 | 默认值 | | --- | --- | --- | --- | lastCard | Boolean | 是否需要上一张 | true | narrow | Boolean | 是否需要缩小 | true | reduction | Boolean | 是否需要复原 | true | enlarge | Boolean | 是否需要放大 | true | leftRotate | Boolean | 是否需要逆时针旋转 | true | rightRotate | Boolean | 是否需要顺时针旋转 | true | downloadFile | Boolean | 是否需要下载 | true | publish | Boolean | 是否需要打印 | true | nextCard | Boolean | 是否需要下一张 | true | mouseWheel | Boolean | 是否需要滚轮缩放 | true | mouseDown | Boolean | 是否需要拖拽功能 | true

事件

| 事件名 | 说明 | 回调参数 | --- | --- | --- | close | 关闭回调 | -

注意

  • 若引用图片地址,相对地址使用require()包裹或使用绝对地址
  • 若imgData 和 imgArr 同时传了 则只有imgData生效
  • 不支持 base64

最后

  • 如果对你有帮助,请star一个哦,你的鼓励是我创作的动力
  • 欢迎来到我的博客,希望能对你有所帮助
  • 掘金:https://juejin.cn/user/2339399368751325/posts
  • csdn:https://blog.csdn.net/weixin_44083712?spm=1010.2135.3001.5343
  • csdn | 掘金 | 知乎 同名: 饼干_ 或 饼干