0.0.8 • Published 7 months ago

js-img-magnify v0.0.8

Weekly downloads
-
License
-
Repository
github
Last release
7 months ago

js-img-magnify

npm npm bundle size npm

Pure JavaScript utility enabling magnifying glass effect on an images. No external dependencies required.

So you can use it in any web application, such as Vue, React,Angular, Svelte, or any other application.

support Typescript

Demo

view Demo

How to use

  • npm or yarn

    • install
      npm i js-img-magnify
      # or
      yarn js-img-magnify
    • use
      import magnifyImg from 'js-img-magnify';
      import img from './assets/waterDrop.jpg';
      magnifyImg({
          src: img,   // or img url
          zoom: 3,
          target: document.getElementById('example'),
          width: 500, // img width, Can also '50%'
          MagnifyDomStyles: {"borderRadius":"50%","border":"4px solid red"},
          MagnifyDom: document.getElementById('show'),
          ...
      })
  • cdn

    • install
      <script src="https://cdn.jsdelivr.net/npm/js-img-magnify@latest/lib/js-img-magnify.umd.js"></script>
    • use
      magnifyImg({
          src: imgURL,
          zoom: 3,
          target: document.getElementById('example'),
          width: 500, // img width, Can also '50%'
          MagnifyDom: document.getElementById('show'),
          ...
      })

Props

propNametyperequireddescdefault
srcstringtrueimg tag src prop
zoomnumberfalsemagnification times3
targetHTMLElementtruetarget HTMLElement
widthstring/numberfalseimgTag width,100 or "50%""auto"
MagnifyDomWidthnumberfalsejs created magnifying glass dom, if MagnifyDom has value, This will not work.200
MagnifyDomStylespartialCSSStyleDeclarationfalseit will merge js created magnifying glass dom styles, if MagnifyDom has value, This will not work{}
MagnifyDomHTMLElementfalseuser custom magnify Dom
overflowBooleanfalseWhether or not to allow exceeding the image range at the image edgestrue
0.0.8

7 months ago

0.0.7

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago