0.0.4 • Published 5 years ago

@l1nyanm1ng/react-picture-viewer v0.0.4

Weekly downloads
9
License
ISC
Repository
github
Last release
5 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.

ajv-keywordsajv-errorsacornacceptsansi-regexansi-colorsansi-htmlajvarr-diffanymatchansi-stylesarr-flattenaprobaarr-unionarray-flattenarray-uniquearray-unionarray-uniqasn1.jsassertassign-symbolsasync-limiterasyncasync-eachatobbalanced-matchbase64-jsbabel-plugin-dynamic-import-nodebasebinary-extensionsbatchbig.jsbody-parserbn.jsbluebirdboolbasebindingsbrace-expansionbonjourbracesbrowserify-cipherbrowserify-aesbrorandbrowserify-desbrowserify-rsabrowserify-zlibbufferbrowserslistbrowserify-signbuffer-indexofcacachebuffer-xorbuiltin-status-codesbuffer-fromcamel-casebytescache-basecamelcasecaniuse-litechalkchownrchokidarcipher-baseclass-utilsclean-csschrome-trace-eventcliuicollection-visitcode-point-atcolor-convertcolor-namecommandercommondircompressioncomponent-emittercompressibleconcat-mapconsole-browserifyconcat-streamconnect-history-api-fallbackcontent-dispositionconstants-browserifycontent-typecookieconvert-source-mapcookie-signaturecopy-concurrentlycopy-descriptorcore-js-compatcreate-ecdhcore-util-iscreate-hashcreate-hmaccross-spawncrypto-browserifycss-selectcssesccyclistdebugdecamelizecss-whatdecode-uri-componentdefault-gatewaydeep-equaldefine-propertydefine-propertiesdepddes.jsdestroydeldetect-filedetect-nodedns-equaldns-packetdns-txtdomain-browserdiffie-hellmandom-converterdom-serializerdomutilsdomhandlerdomelementtypeduplexifyee-firstelectron-to-chromiumencodeurlellipticemojis-listenhanced-resolveend-of-streamerrnoemoji-regexentitiesescape-htmles-to-primitiveesrecursees-abstractescape-string-regexpesutilsetagestraverseeslint-scopeeventemitter3eventsexpand-bracketsevp_bytestokeyexpand-tildeexecaexpressextend-shallowextglobeventsourcefast-deep-equalfast-json-stable-stringifyfaye-websocketfiggy-puddingfill-rangefile-uri-to-pathfinalhandlerfind-cache-dirfindup-syncfind-upflush-write-streamfor-infragment-cachefollow-redirectsfrom2forwardedfs-readdir-recursivefreshfs-write-stream-atomicfs.realpathget-streamgensyncfunction-bindget-valueglobget-caller-fileglobal-modulesglobalsglob-parentglobbyhandle-thingglobal-prefixgraceful-fshas-flaghashas-symbolshas-valueshas-valuehash-basehehash.jshomedir-polyfillhmac-drbghtml-entitieshpack.jshtmlparser2html-minifierhttp-errorshttp-deceiverhttp-parser-jshttp-proxy-middlewarehttps-browserifyhttp-proxyicss-replace-symbolsicss-utilsiconv-liteiferrieee754import-localimurmurhashinflightinfer-ownerindexes-ofiniinterpretinheritsinternal-ipinvariantinvert-kvipipaddr.jsip-regexis-absolute-urlis-accessor-descriptoris-argumentsis-bufferis-binary-pathis-data-descriptoris-date-objectis-descriptoris-callableis-extglobis-extendableis-fullwidth-code-pointis-globis-numberis-plain-objectis-path-insideis-path-cwdis-path-in-cwdis-streamis-regexis-symbolis-windowsis-wslisarrayisobjectisexejs-tokensjson-parse-better-errorsjsesckillablejson5kind-ofjson-schema-traversejson3lcidloader-utilslevenarylevenloglevelloader-runnerlodashlower-caselocate-pathloose-envifylru-cachemamacromake-dirmap-age-cleanermap-cachemd5.jsmap-visitmemmedia-typermemory-fsmicromatchmiller-rabinmerge-descriptorsmethodsmimemime-dbminimalistic-assertmimic-fnmime-typesminimalistic-crypto-utilsminimatchminimistmississippimkdirpmixin-deepmove-concurrentlymsmulticast-dnsnanomatchmulticast-dns-service-typesnegotiatornanno-casenice-tryneo-asyncnode-forgenode-libs-browsernormalize-pathnode-releasesnth-checknpm-run-pathobject-copyobject-inspectobject-assignobject-isnumber-is-nanobject-keysobject-visitobject.assignobject.getownpropertydescriptorsobject.pickon-finishedon-headersobufopnos-browserifyos-localeoriginaloncep-deferp-is-promisep-locatep-finallyp-limitp-mapp-tryp-retrypakoparseurlparse-asn1parallel-transformpascalcasepath-browserifyparse-passwdparam-casepath-dirnamepath-is-insidepath-is-absolutepath-existspbkdf2path-keypifypath-to-regexppath-parsepinkie-promisepinkiepkg-dirportfinderpostcssposix-character-classespostcss-modules-valuespostcss-modules-local-by-defaultpostcss-modules-extract-importspostcss-modules-scopepostcss-selector-parserpostcss-value-parserpretty-errorprivateprocessprrprocess-nextick-argsproxy-addrpublic-encryptpromise-inflightpumpifypumpqspunycodequerystring-es3randomfillquerystringrandombytesrange-parserquerystringifyraw-bodyreact-isreadable-streamregeneratereaddirpregenerate-unicode-propertiesregenerator-transformregex-notregenerator-runtimeregexp.prototype.flagsregjsgenrelateurlrenderkidregexpu-coreregjsparserremove-trailing-separatorrepeat-stringrepeat-elementrequire-directoryrequires-portrequire-main-filenameresolve-cwdresolve-dirresolve-fromresolveresolve-urlretryretrimrafripemd160safe-regexrun-queuesafe-buffersafer-bufferschedulerschema-utilsselect-hoseserialize-javascriptselfsignedsendsemverserve-indexserve-staticsetimmediatesetprototypeofset-blockingsha.jsshebang-commandshebang-regexset-valuesignal-exitsnapdragon-nodesnapdragonslashsnapdragon-utilsockjssockjs-clientsource-mapsource-list-mapsource-map-supportsource-map-urlsource-map-resolvespdyspdy-transportssrisplit-stringstatic-extendstream-browserifystream-eachstatusesstream-shiftstream-httpstring-widthstring.prototype.trimleftstrip-ansistring_decoderstring.prototype.trimrightstrip-eofsupports-colorterser-webpack-plugintapableterserthrough2thunkyto-fast-propertiesto-arraybufferto-object-pathtimers-browserifyto-regextoidentifiertoposortto-regex-rangetslibtype-istty-browserifyunicode-canonical-property-names-ecmascripttypedarrayunicode-match-property-ecmascriptuglify-jsuniqunicode-match-property-value-ecmascriptunicode-property-aliases-ecmascriptunique-filenameunion-valueunique-slugunpipeunset-valueupathupper-caseurixurl-parseuri-jsurlutiluseutil-deprecateutil.promisifyuuidutilautils-mergewatchpackvm-browserifywbufwebpack-dev-middlewarewebpack-sourcesv8-compile-cachewebpack-logwebsocket-drivervarywhichwebsocket-extensionsworker-farmwhich-modulewrap-ansiwswrappyyallistxtendyargsy18nyargs-parserfsevents
0.0.4

5 years ago

0.0.3

5 years ago

0.0.1

5 years ago