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 🙏

© 2024 – Pkg Stats / Ryan Hefner

dww-img-preview

v1.0.0

Published

图片预览查看

Downloads

5

Readme

图片查看,放大缩小旋转,上一张下一张

参考链接 https://github.com/fengyuanchen/viewerjs

调用方式

  • upload图片回显
import React from 'react';
import { Upload } from 'antd';
import { ImagePreview } from 'lina';

class PicturesWall extends React.Component {
  state = {
    previewVisible: false,
    previewImage: '',
    fileList: [
      {
        uid: '-1',
        name: 'image.png',
        status: 'done',
        url: '图片地址'
      },
      {
        uid: '2',
        name: 'image.png',
        status: 'done',
        url: '图片地址'
      }
    ]
  };

  handleCancel = () => {
    this.setState({
      previewVisible: false,
    })
  };
  handlePreview = file => {
    this.setState({
      previewImage: file.url || file.preview,
      previewVisible: true,
    });
  };

  handleChange = ({ fileList }) => this.setState({ fileList });

  render() {
    const { previewVisible, previewImage, fileList } = this.state;
    return (
      <div className="clearfix">
        <Upload
          action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
          listType="picture-card"
          fileList={fileList}
          onPreview={this.handlePreview}
          onChange={this.handleChange}
        >
        </Upload>
        {
          previewVisible && 
          <ImagePreview
            imageList={[previewImage]} // 必须,图片url,数组
            callBack={this.handleCancel} // 必须 关闭事件 把previewVisible修改为false
            isClickShow={true}  // 必须
            showIndex={0}  // 非必须  当前展示的图片index 
            options={options} // 非必须
          />
        }
      </div>
    );
  }
}

export default PicturesWall;
  • 图片预览
          <ImagePreview
            imageList={[previewImage]} // 必须 图片url,数组
            imgBgColor={'#f5f7f9'} // 非必须  图片背景颜色
            callBack={this.handleCancel} // 非必须  关闭事件
            options={options} // 非必须
            previewClass={} // 非必须,,样式可以修改ul li img得布局
            showIndex={0}  // 非必须  当前展示的图片index 
            width={200} // 非必须 图片宽度
            height={200}  // 非必须  图片高度
          />

option配置参数

  • option中回调函数当前this得作用域即viewer本身; this.viewer;
  • 调用一个viewer例如初始化图片放大,旋转,一般使用viewed改变图片初始化得大小;
    option{
        inline: false, //	布尔值	启用 inline 模式
        button: true, //	布尔值	显示右上角关闭按钮(jQuery 版本无效)
        navbar: true ,// 	布尔值/整型	true	显示缩略图导航
        title:	true, // 布尔值/整型	显示当前图片的标题(现实 alt 属性及图片尺寸)
        toolbar: true //	布尔值/整型		显示工具栏
        tooltip: true,  // 布尔值		显示缩放百分比
        movable: true, //	布尔值		图片是否可移动
        zoomable: true, //	布尔值		图片是否可缩放
        rotatable: true, //	布尔值		图片是否可旋转
        scalable: true, //	布尔值		图片是否可翻转
        transition: true, //	布尔值		使用 CSS3 过度
        fullscreen: true, //	布尔值		播放时是否全屏
        keyboard: true, //	布尔值		是否支持键盘
        interval: 5000, //	整型		播放间隔,单位为毫秒
        zoomRatio:0.1, //	浮点型		鼠标滚动时的缩放比例
        minZoomRatio:	0.01, //	浮点型	最小缩放比例
        maxZoomRatio: 100, //	数字		最大缩放比例
        zIndex: 2015 //	数字		设置图片查看器 modal 模式时的 z-index
        zIndexInline:	0 //	数字	设置图片查看器 inline 模式时的 z-index
        view(){}, //当观看者开始显示(查看)图像时,此事件将触发。
        viewed() {  // 当观看者显示(查看)图像时,该事件触发。
            this.viewer.zoomTo(1).rotateTo(180);
          },
        show(){}, // 当观察者模式准备使用时
        shown(){},// 当观察这模式使用时
        hide(){}, // 开始隐藏时回调函数
        hidden(){}, // 隐藏时回调函数
        zoom(){}, //开始缩大放小时粗放
        zoomed(){}, //当观看者缩放(放入或缩小)图像时,此事件将触发。
    }