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

@vearvip/react-picture-preview

v1.0.0-beta.4

Published

一个基于 React 和 rc-image 的图片预览组件,具备图片旋转、翻转、缩放和下载等功能。

Downloads

16

Readme

@vearvip/react-picture-preview

@vearvip/react-picture-preview 是一个基于 Reactrc-image 的图片预览组件,具备图片旋转、翻转、缩放和下载等功能。

安装

使用 npm 安装:

npm install @vearvip/react-picture-preview

或使用 yarn 安装:

yarn add @vearvip/react-picture-preview

使用方法

导入组件

import { preview } from '@vearvip/react-picture-preview';

使用示例

import React from 'react';
import { preview } from '@vearvip/react-picture-preview';

const imageList = [
  'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
  'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*ngiJQaLQELEAAAAAAAAAAABkARQnAQ',
];


const App = () => {
  return (
    <div>
      <div>

        <button
          onClick={() => {
            preview({
              src: imageList[0],
              actions: {
                rotateLeft: false,
                rotateRight: false,
                zoomIn: false,
                zoomOut: false,
                flipX: false,
                flipY: false,
                // download: false
              }
            });
          }}
        >
          查看图片1-单张
        </button>
        <button
          onClick={() => {
            preview({
              src: imageList[1],
            });
          }}
        >
          查看图片2-单张
        </button>
      </div>
      <div>

        <button
          onClick={() => {
            preview({
              src: imageList[0],
              images: imageList
            });
          }}
        >
          查看图片1-多张
        </button>
        <button
          onClick={() => {
            preview({
              src: imageList[1],
              images: imageList
            });
          }}
        >
          查看图片2-多张
        </button>
      </div>
    </div>
  );
};

export default App;

API

preview(options) 函数参数

preview 函数接收一个对象,该对象包含以下属性:

| 属性名 | 类型 | 必填 | 描述 | | --------- | -------- | ----- | --------------------------------------------------------------------------------------------------------------------- | | src | string | 是 | 要预览的图片地址。 | | images | string[] | 否 | 图片地址数组,如果不提供,则预览单张图片。 | | onClose | function | 否 | 关闭预览时的回调函数。 | | actions | object | 否 | 配置哪些功能按钮是可用的,具体属性详见下表。 |

actions 对象属性

actions 对象包含以下可选布尔属性,指示对应的功能按钮是否显示(默认都显示):

| 属性名 | 类型 | 描述 | | ----------- | ----- | ------------------------------------ | | rotateLeft | bool | 是否显示向左旋转按钮 | | rotateRight | bool | 是否显示向右旋转按钮 | | zoomIn | bool | 是否显示放大按钮 | | zoomOut | bool | 是否显示缩小按钮 | | flipX | bool | 是否显示水平翻转按钮 | | flipY | bool | 是否显示垂直翻转按钮 | | download | bool | 是否显示下载按钮 |

贡献

欢迎贡献以及反馈问题。请在提交 Pull Request 之前先创建一个 Issue 以便讨论。