react-zoom-pan-pinch vs react-svg-pan-zoom
React 圖形縮放與平移庫
react-zoom-pan-pinchreact-svg-pan-zoom類似套件:

React 圖形縮放與平移庫

這些庫提供了在 React 應用中實現圖形縮放和平移的功能,特別適合需要互動式視覺化的應用。這些庫允許用戶通過滑鼠或觸控手勢來縮放和移動 SVG 圖形,增強了用戶體驗,並使得複雜的圖形操作變得更加直觀和易於使用。

npm下載趨勢

3 年

GitHub Stars 排名

統計詳情

套件
下載數
Stars
大小
Issues
發布時間
許可
react-zoom-pan-pinch4,146,4541,9621.2 MB223 個月前MIT
react-svg-pan-zoom25,8926951.02 MB412 年前MIT

功能比較: react-zoom-pan-pinch vs react-svg-pan-zoom

支持的元素類型

  • react-zoom-pan-pinch:

    支持多種 HTML 元素,包括圖片和畫布,提供更廣泛的應用場景,適合需要處理不同類型內容的情況。

  • react-svg-pan-zoom:

    專門針對 SVG 元素設計,能夠處理 SVG 的特性,如路徑、形狀和文本,並提供對這些元素的精確控制。

使用簡便性

  • react-zoom-pan-pinch:

    設計上更加輕量,簡單的用法使得開發者能夠快速實現基本的縮放和平移功能,適合快速開發和原型設計。

  • react-svg-pan-zoom:

    提供了直觀的 API,易於集成到現有的 React 應用中,並且有詳細的文檔和範例,方便開發者上手。

自定義能力

  • react-zoom-pan-pinch:

    雖然自定義能力不如前者強大,但仍然提供了一些基本的選項來調整縮放和移動的行為,適合大多數基本需求。

  • react-svg-pan-zoom:

    提供了豐富的自定義選項,開發者可以根據需求調整縮放和移動的行為,並能夠綁定自定義事件。

性能

  • react-zoom-pan-pinch:

    性能表現良好,但在處理大量元素時可能會出現性能瓶頸,適合中小型應用。

  • react-svg-pan-zoom:

    專為處理 SVG 設計,性能優化良好,能夠在複雜的圖形上流暢運行,適合需要高性能的應用。

社群支持與維護

  • react-zoom-pan-pinch:

    社群也相當活躍,並且有穩定的更新頻率,適合需要持續支持的項目。

  • react-svg-pan-zoom:

    擁有活躍的社群和定期的更新,能夠快速響應使用者的需求和問題。

如何選擇: react-zoom-pan-pinch vs react-svg-pan-zoom

  • react-zoom-pan-pinch:

    如果你需要一個更通用的解決方案,支持多種元素(如圖片、畫布等)的縮放和平移,選擇 react-zoom-pan-pinch。它簡單易用,適合快速開發和原型設計。

  • react-svg-pan-zoom:

    如果你的應用主要處理 SVG 圖形,並且需要精確的縮放和平移控制,選擇 react-svg-pan-zoom。它提供了豐富的 API 和事件處理功能,適合需要高自定義的場景。

react-zoom-pan-pinch 的 README

react-zoom-pan-pinch

Super fast and light react npm package for zooming, panning and pinching html elements in easy way

Twitter Follow

Join our Discord community

🏢 Using this library in production?

If your application depends on react-zoom-pan-pinch, I offer paid support to help you resolve issues quickly and avoid blocking releases.

Sources

Premium sponsor banner

Premium sponsor banner

Key Features

  • 🚀 Fast and easy to use
  • 🏭 Light, without external dependencies
  • 💎 Mobile gestures, touchpad gestures and desktop mouse events support
  • 🎁 Powerful context usage, which gives you a lot of freedom
  • 🔧 Highly customizable
  • 👑 Animations and Utils to create own tools
  • 🔮 Advanced hooks and components

Try other BetterTyped projects

Do you like this library? Here is what else I build and maintain.

Build your SaaS on Hype Stack

Connect any API with Hyper Fetch


Installation

npm install --save react-zoom-pan-pinch
or
yarn add react-zoom-pan-pinch

Premium sponsor banner

Premium sponsor banner

Examples

import React, { Component } from "react";

import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";

const Example = () => {
  return (
    <TransformWrapper>
      <TransformComponent>
        <img src="https://raw.githubusercontent.com/BetterTyped/react-zoom-pan-pinch/HEAD/image.jpg" alt="test" />
      </TransformComponent>
    </TransformWrapper>
  );
};

or

import {
  TransformWrapper,
  TransformComponent,
  useControls,
} from "react-zoom-pan-pinch";

const Controls = () => {
  const { zoomIn, zoomOut, resetTransform } = useControls();

  return (
    <div className="tools">
      <button type="button" onClick={() => zoomIn()}>
        +
      </button>
      <button type="button" onClick={() => zoomOut()}>
        -
      </button>
      <button type="button" onClick={() => resetTransform()}>
        x
      </button>
    </div>
  );
};

const Example = () => {
  return (
    <TransformWrapper
      initialScale={1}
      initialPositionX={200}
      initialPositionY={100}
    >
      <Controls />
      <TransformComponent>
        <img src="https://raw.githubusercontent.com/BetterTyped/react-zoom-pan-pinch/HEAD/image.jpg" alt="test" />
        <div>Example text</div>
      </TransformComponent>
    </TransformWrapper>
  );
};

Premium sponsor banner

Premium sponsor banner

Help me keep working on this project ❤️

💖 Our sponsors

My Sponsors

🏢 Commercial Support

If you're using this library in production, I offer paid support:

  • Priority issue resolution
  • Help with debugging production issues
  • Direct contact with the maintainer

Plans start at $400/month.

📩 Contact: [email protected]

License

MIT © prc5