react-zoom-pan-pinch vs react-svg-pan-zoom
ズームおよびパン機能ライブラリ
react-zoom-pan-pinchreact-svg-pan-zoom類似パッケージ:
ズームおよびパン機能ライブラリ

これらのライブラリは、ReactアプリケーションにおいてSVGやその他のコンテンツをズームおよびパンする機能を提供します。ユーザーがインタラクティブにコンテンツを操作できるようにし、特に地図や画像の表示に便利です。これにより、ユーザーエクスペリエンスが向上し、視覚的な情報の探索が容易になります。

npmのダウンロードトレンド
3 年
GitHub Starsランキング
統計詳細
パッケージ
ダウンロード数
Stars
サイズ
Issues
公開日時
ライセンス
react-zoom-pan-pinch729,5701,807441 kB15710ヶ月前MIT
react-svg-pan-zoom89,6116951.02 MB411年前MIT
機能比較: react-zoom-pan-pinch vs react-svg-pan-zoom

ズーム機能

  • react-zoom-pan-pinch:

    react-zoom-pan-pinchは、画像や他のコンテンツに対してズーム機能を提供し、ユーザーがピンチやドラッグでインタラクションできるようにします。このライブラリは、タッチデバイスやデスクトップ環境の両方でスムーズなズーム体験を実現します。

  • react-svg-pan-zoom:

    react-svg-pan-zoomは、SVG要素に対して高精度なズーム機能を提供します。ユーザーはマウスホイールやタッチジェスチャーを使用して、SVGの特定の部分を拡大したり縮小したりできます。ズームレベルは、SVGのビューポートに基づいて計算され、ピクセル単位での精密な操作が可能です。

パン機能

  • react-zoom-pan-pinch:

    react-zoom-pan-pinchは、パン機能もサポートしており、ユーザーがコンテンツを自由に移動させることができます。特に大きな画像や地図を扱う際に便利で、ユーザーが必要な情報に簡単にアクセスできるようになります。

  • react-svg-pan-zoom:

    このライブラリでは、SVGコンテンツをパンするための直感的な操作が可能です。ユーザーはドラッグ操作でSVGを移動させ、特定の領域に焦点を当てることができます。SVGの特性を活かしたパン機能が実装されています。

インタラクティブ性

  • react-zoom-pan-pinch:

    このライブラリは、一般的なコンテンツに対してもインタラクティブな体験を提供します。ユーザーは画像をズームイン・アウトし、パン操作を行うことで、コンテンツを詳細に探索することができます。

  • react-svg-pan-zoom:

    react-svg-pan-zoomは、SVG要素に対してインタラクティブな操作を提供します。ユーザーはズームやパンだけでなく、SVG内の特定の要素に対しても操作を行うことができ、インタラクティブなデータビジュアライゼーションに最適です。

パフォーマンス

  • react-zoom-pan-pinch:

    react-zoom-pan-pinchは、さまざまなコンテンツタイプに対応しており、パフォーマンスに優れています。特に、画像や大きなコンテンツを扱う際に、スムーズなズームとパンが可能です。

  • react-svg-pan-zoom:

    react-svg-pan-zoomは、SVGの特性を考慮した設計がされており、大規模なSVGコンテンツでもパフォーマンスが最適化されています。ズームやパン操作においてもスムーズな体験を提供します。

カスタマイズ性

  • react-zoom-pan-pinch:

    react-zoom-pan-pinchは、カスタマイズ可能なオプションが豊富で、ユーザーはズームの速度やパンの挙動を調整できます。また、イベントハンドリングも柔軟に設定でき、独自のインタラクションを実装することができます。

  • react-svg-pan-zoom:

    このライブラリは、SVG特有のカスタマイズオプションを提供しており、ユーザーはズームやパンの動作を細かく設定できます。SVGのスタイルやアニメーションも自由にカスタマイズ可能です。

選び方: react-zoom-pan-pinch vs react-svg-pan-zoom
  • react-zoom-pan-pinch:

    より一般的なコンテンツや画像のズームとパンが必要な場合は、react-zoom-pan-pinchを選択してください。このライブラリは、さまざまなコンテンツタイプに対応しており、より柔軟なインタラクションを提供します。

  • react-svg-pan-zoom:

    SVGコンテンツを扱う場合や、SVGの特定の機能を活用したい場合は、react-svg-pan-zoomを選択してください。このライブラリはSVG要素に特化しており、SVGの特性を最大限に活かすことができます。

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

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? Try out other projects

Hyper Fetch

⚡Hyper Fetch - Fetching and realtime data exchange framework.


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="image.jpg" alt="test" />
      </TransformComponent>
    </TransformWrapper>
  );
};

or

import React, { Component } from "react";

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

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

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

const Example = () => {
  return (
    <TransformWrapper
      initialScale={1}
      initialPositionX={200}
      initialPositionY={100}
    >
      {({ zoomIn, zoomOut, resetTransform, ...rest }) => (
        <>
          <Controls />
          <TransformComponent>
            <img src="image.jpg" alt="test" />
            <div>Example text</div>
          </TransformComponent>
        </>
      )}
    </TransformWrapper>
  );
};

Premium sponsor banner

Premium sponsor banner

License

MIT © prc5

Help me keep working on this project ❤️

💖 Our sponsors

My Sponsors