1.3.3 • Published 4 years ago

react-jimage v1.3.3

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

React JiMage

Touch enabled, pan and zoom image container for React.

  • Zoom with mouseWheel or pinch
  • Drag with mouse or touch
  • Preloading included

See demo.

Install

yarn add react-jimage

Usage

import Image from 'react-jimage'

<div style={{ width: .., height: .., background: .. }}>
    <Image
        image={'https://image.com/yourimage.jpg'}
        preloader={<i>Loading...</i>}
    />
</div>

The Image component is a div with these styling:

{
  width: '100%',
  height: '100%',
  overflow: 'hidden',
  position: 'relative',
  userSelect: 'none',
}

inside that div, we have a preloader or an img. The preloader is optional, and will be displayed as is. You will be the one controlling the styling for the preloader.

After the image have been loaded, we will have the image displayed inside the container.

Props

Functional | Name | Description | Optional | |---|---|---| | image | String, image src | no | | preloader | ReactComponent, or String | yes |

Event

Sometimes you need to know when zoom or drag happens. The Image component also accepts these props:

NameDescription
onActionStartFunction({ type, touch })
onActionEndFunction({ type, touch })
type: [String] 'drag' || 'zoom'
touch: [Boolean]

Cheers, jujiyangasli

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago