New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mokahr/react-zoom

Package Overview
Dependencies
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mokahr/react-zoom

zoom component for react

  • 0.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

react-zoom

一个可缩放、拖动的react组件 支持mac双指手势

使用手册

  1. 安装依赖 npm install --save @mokahr/react-zoom
  2. 组件使用
import Zoom from '@mokahr/react-zoom';

/**
 * toolbarRender 自定义toolbar render函数
 *
 * @param {Number} zoom 当前缩放比例 基数是100
 * @param {Function} onZoom 改变缩放比例的function
 * @param {Function} onReset 重置缩放 会根据当前children的宽高 计算出 合适的比例(刚好全显示 除去留白)
 *                           位置(水平居中,垂直置顶在顶部留白下)的function
 * @param {Number} minZoom 当前最小缩放比例
 * @param {Number} minZoom 当前最大缩放比例
*/
// demo
const toolbarRender = (zoom, onZoom, onReset, minZoom = 10, maxZoom = 200) => (
  <div>
    <div onClick={onReset}>复位</div>
    <div
      onClick={
        zoom > minZoom
        ? () => onZoom(Math.ceil(zoom / 10) * 10 - 10)
        : null
      }
    >-</div>
    <div>{zoom}%</div>
    <div
      onClick={
        zoom < maxZoom
        ? () => onZoom(Math.floor(zoom / 10) * 10 + 10)
        : null
      }
    >+</div>
  </div>
);

<Zoom
  // 最小缩放比例 基数 100
  minZoom={10}
  // 最大缩放比例 基数 100
  maxZoom={200}
  // 顶部底部留白 xx px
  padding={20}
  // 自定义toolbar
  toolbarRender={toolbarRender}
>
  <div>需要缩放的组件</div>
</Zoom>

Keywords

FAQs

Package last updated on 29 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc