项目作者: filipecorrea

项目描述 :
React component for rendering images with zoom controls and hotspots
高级语言: JavaScript
项目地址: git://github.com/filipecorrea/react-image-hotspots.git
创建时间: 2019-07-04T13:45:00Z
项目社区:https://github.com/filipecorrea/react-image-hotspots

开源协议:MIT License

下载


react-image-hotspots

React component for rendering images with zoom controls and hotspots.

Live demo

Install

Install from npm and include it in your project build process:

  1. npm install react-image-hotspots --save

Or install from yarn running:

  1. yarn add react-image-hotspots

Usage

  1. import ImageHotspots from 'react-image-hotspots'
  2. <ImageHotspots
  3. src='https://raw.githubusercontent.com/filipecorrea/react-image-hotspots/master/src/landscape.jpg'
  4. alt='Sample image'
  5. hotspots={
  6. [
  7. { x: 10, y: 30, content: <span>Hotspot 1</span> },
  8. { x: 40, y: 70, content: <span>Hotspot 2</span> },
  9. { x: 80, y: 30, content: <span>Hotspot 2</span> }
  10. ]
  11. }
  12. />

Component properties

Props Type Default Description
src String, required Image source
alt String, optional Image alternative info
hideFullscreenControl Boolean, optional false Hide fullscreen control
hideZoomControls Boolean, optional false Hide zoom controls
hideMinimap Boolean, optional false Hide minimap
hotspots Array of objects, optional [] Hotspots
background String, optional Container background color

If image size is smaller than the container size, zoom controls and minimap will be hidden.

Hotspot properties

Props Type Default Description
x Number, required Percentage vertical position
y Number, required Percentage horizontal position
content React or HTML element, required Hotspot content

Development

Prerequisites

Start

Start the project running:

  1. npm start

Test

Test the project running:

  1. npm test

Build

Build the project running:

  1. npm run build