1.0.0 • Published 3 years ago

fastlion-picture-viewer v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

react-picture-viewer

An picture viewer for React with no dependencies.

ReactPictureViewer Demo

English | 简体中文

Features

  • You can freely drag picture within the viewport
  • You can freely zoom picture within the viewport
  • Min/max zoom size
  • No dependencies

Installation

npm install react-picture-viewer --save

or

yarn add react-picture-viewer

Demo

You can run the project locally to see the demo.

yarn start

or

npm run start

Usage

Include the main js module:

import ReactPictureViewer from 'react-picture-viewer'

Example

class PicViewer extends React.Component {
  // ...
  render() {
    return (
      <div>
        <PictureViewer>
          <img src="..." alt="picture" draggable="false" />
        </PictureViewer>
      </div>
     )
  }
  // ...
}

Props

children (required)

<PictureViewer>
  <img src="..." alt="picture" draggable="false" />
</PictureViewer>

You should always pass an <Img /> element as its children.

id (optional)

<div>
  <PictureViewer id="picture-viewer1">...</PictureViewer>
  <PictureViewer id="picture-viewer2">...</PictureViewer>
</div>

Unique identifier for components, useful when rendering multiple components on a page

className (optional)

<PictureViewer className="picture-viewer">...</PictureViewer>

ClassName

center (optional)

<PictureViewer center>...</PictureViewer>

If true then the pictures will be displayed in the middle of the viewport, default to true.

contain (optional)

<PictureViewer contain>...</PictureViewer>

If true then the initial size of the picture will be limited to the viewport, else the image will be displayed in the original size, default to true.

width (optional)

<PictureViewer width={500}>...</PictureViewer>
<PictureViewer width="50vw">...</PictureViewer>

Width of viewport, it can be string or number.

height (optional)

<PictureViewer height={400}>...</PictureViewer>
<PictureViewer width="40%">...</PictureViewer>

Height of viewport, it can be string or number.

minimum (optional)

<PictureViewer minimum={1}>...</PictureViewer>

Minimum scaling ratio, default to 0.8

maximum (optional)

<PictureViewer maximum={5}>...</PictureViewer>

Maximum scaling ratio, default to 8

rate (optional)

<PictureViewer rate={20}>...</PictureViewer>

The rate of Image Scaling, default to 10. Bigger the number you set, faster the image will zoom in.

acceptsacornajvajv-errorsajv-keywordsansi-colorsansi-htmlansi-regexansi-stylesanymatchaprobaarr-diffarr-flattenarr-unionarray-flattenarray-unionarray-uniqarray-uniqueasn1.jsassertassign-symbolsasyncasync-eachasync-limiteratobbabel-plugin-dynamic-import-nodebalanced-matchbasebase64-jsbatchbig.jsbinary-extensionsbindingsbluebirdbn.jsbody-parserbonjourboolbasebrace-expansionbracesbrorandbrowserify-aesbrowserify-cipherbrowserify-desbrowserify-rsabrowserify-signbrowserify-zlibbrowserslistbufferbuffer-frombuffer-indexofbuffer-xorbuiltin-status-codesbytescacachecache-basecamel-casecamelcasecaniuse-litechalkchokidarchownrchrome-trace-eventcipher-baseclass-utilsclean-csscliuicode-point-atcollection-visitcolor-convertcolor-namecommandercommondircomponent-emittercompressiblecompressionconcat-mapconcat-streamconnect-history-api-fallbackconsole-browserifyconstants-browserifycontent-dispositioncontent-typeconvert-source-mapcookiecookie-signaturecopy-concurrentlycopy-descriptorcore-js-compatcore-util-iscreate-ecdhcreate-hashcreate-hmaccross-spawncrypto-browserifycss-selectcss-whatcssesccyclistdebugdecamelizedecode-uri-componentdeep-equaldefault-gatewaydefine-propertiesdefine-propertydeldepddes.jsdestroydetect-filedetect-nodediffie-hellmandns-equaldns-packetdns-txtdom-converterdom-serializerdomain-browserdomelementtypedomhandlerdomutilsduplexifyee-firstelectron-to-chromiumellipticemoji-regexemojis-listencodeurlend-of-streamenhanced-resolveentitieserrnoes-abstractes-to-primitiveescape-htmlescape-string-regexpeslint-scopeesrecurseestraverseesutilsetageventemitter3eventseventsourceevp_bytestokeyexecaexpand-bracketsexpand-tildeexpressextend-shallowextglobfast-deep-equalfast-json-stable-stringifyfaye-websocketfiggy-puddingfile-uri-to-pathfill-rangefinalhandlerfind-cache-dirfind-upfindup-syncflush-write-streamfollow-redirectsfor-inforwardedfragment-cachefreshfrom2fs-readdir-recursivefs-write-stream-atomicfs.realpathfunction-bindgensyncget-caller-fileget-streamget-valueglobglob-parentglobal-modulesglobal-prefixglobalsglobbygraceful-fshandle-thinghashas-flaghas-symbolshas-valuehas-valueshash-basehash.jshehmac-drbghomedir-polyfillhpack.jshtml-entitieshtml-minifierhtmlparser2http-deceiverhttp-errorshttp-parser-jshttp-proxyhttp-proxy-middlewarehttps-browserifyiconv-liteicss-replace-symbolsicss-utilsieee754iferrimport-localimurmurhashindexes-ofinfer-ownerinflightinheritsiniinternal-ipinterpretinvariantinvert-kvipip-regexipaddr.jsis-absolute-urlis-accessor-descriptoris-argumentsis-binary-pathis-bufferis-callableis-data-descriptoris-date-objectis-descriptoris-extendableis-extglobis-fullwidth-code-pointis-globis-numberis-path-cwdis-path-in-cwdis-path-insideis-plain-objectis-regexis-streamis-symbolis-windowsis-wslisarrayisexeisobjectjs-tokensjsescjson-parse-better-errorsjson-schema-traversejson3json5killablekind-oflcidlevenlevenaryloader-runnerloader-utilslocate-pathlodashloglevelloose-envifylower-caselru-cachemake-dirmamacromap-age-cleanermap-cachemap-visitmd5.jsmedia-typermemmemory-fsmerge-descriptorsmethodsmicromatchmiller-rabinmimemime-dbmime-typesmimic-fnminimalistic-assertminimalistic-crypto-utilsminimatchminimistmississippimixin-deepmkdirpmove-concurrentlymsmulticast-dnsmulticast-dns-service-typesnannanomatchnegotiatorneo-asyncnice-tryno-casenode-forgenode-libs-browsernode-releasesnormalize-pathnpm-run-pathnrmnth-checknumber-is-nanobject-assignobject-copyobject-inspectobject-isobject-keysobject-visitobject.assignobject.getownpropertydescriptorsobject.pickobufon-finishedon-headersonceopnoriginalos-browserifyos-localep-deferp-finallyp-is-promisep-limitp-locatep-mapp-retryp-trypakoparallel-transformparam-caseparse-asn1parse-passwdparseurlpascalcasepath-browserifypath-dirnamepath-existspath-is-absolutepath-is-insidepath-keypath-parsepath-to-regexppbkdf2pifypinkiepinkie-promisepkg-dirportfinderposix-character-classespostcsspostcss-modules-extract-importspostcss-modules-local-by-defaultpostcss-modules-scopepostcss-modules-valuespostcss-selector-parserpostcss-value-parserpretty-errorprivateprocessprocess-nextick-argspromise-inflightproxy-addrprrpublic-encryptpumppumpifypunycodeqsquerystringquerystring-es3querystringifyrandombytesrandomfillrange-parserraw-bodyreact-isreadable-streamreaddirpregenerateregenerate-unicode-propertiesregenerator-runtimeregenerator-transformregex-notregexp.prototype.flagsregexpu-coreregjsgenregjsparserrelateurlremove-trailing-separatorrenderkidrepeat-elementrepeat-stringrequire-directoryrequire-main-filenamerequires-portresolveresolve-cwdresolve-dirresolve-fromresolve-urlretretryrimrafripemd160run-queuesafe-buffersafe-regexsafer-bufferschedulerschema-utilsselect-hoseselfsignedsemversendserialize-javascriptserve-indexserve-staticset-blockingset-valuesetimmediatesetprototypeofsha.jsshebang-commandshebang-regexsignal-exitslashsnapdragonsnapdragon-nodesnapdragon-utilsockjssockjs-clientsource-list-mapsource-mapsource-map-resolvesource-map-supportsource-map-urlspdyspdy-transportsplit-stringssristatic-extendstatusesstream-browserifystream-eachstream-httpstream-shiftstring-widthstring.prototype.trimleftstring.prototype.trimrightstring_decoderstrip-ansistrip-eofsupports-colortapableterserterser-webpack-pluginthrough2thunkytimers-browserifyto-arraybufferto-fast-propertiesto-object-pathto-regexto-regex-rangetoidentifiertoposorttslibtty-browserifytype-istypedarrayuglify-jsunicode-canonical-property-names-ecmascriptunicode-match-property-ecmascriptunicode-match-property-value-ecmascriptunicode-property-aliases-ecmascriptunion-valueuniqunique-filenameunique-slugunpipeunset-valueupathupper-caseuri-jsurixurlurl-parseuseutilutil-deprecateutil.promisifyutilautils-mergeuuidv8-compile-cachevaryvm-browserifywatchpackwbufwebpack-dev-middlewarewebpack-logwebpack-sourceswebsocket-driverwebsocket-extensionswhichwhich-moduleworker-farmwrap-ansiwrappywsxtendy18nyallistyargsyargs-parserfsevents
1.0.0

3 years ago