1.7.4 • Published 7 months ago

magnify-zone v1.7.4

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

Magnify zone

The Magnify component provides a zoom-in feature for images, similar to a magnifying glass effect. It allows the user to hover over an image and see a magnified version of a specific part of that image.

Props

Here are the props that you can provide to the Magnify component:

  • imageUrl: string (required): The source URL of the image that you want to magnify.
  • zoomFactor: number: A multiplier to determine how much the image should be zoomed. Default is 1, which means no zoom.
  • zoomPosition: string: Determines where the zoomed-in image should be positioned relative to the main image. Possible values are:

    • over (default): Over the main image.
    • left: To the left of the main image.
    • right: To the right of the main image.
    • top: Above the main image.
    • bottom: Below the main image.
  • zoomWidth: number: Width of the zoomed-in image in pixels. Default is 200.

  • zoomHeight: number: Height of the zoomed-in image in pixels. Default is 200.
  • marginSize: string: Space between the main image and the zoomed-in image, if positioned to the left, right, top, or bottom. Default is 5px.
  • mainImageWidth: string: Width of the main image. Default is 300px.

Notes on Props

  • Properties zoomWidth and zoomHeight expect numbers which will be interpreted as pixels.
  • The marginSize and mainImageWidth properties expect a string, typically representing the size in pixels (e.g., "10px").

Usage

When image in public folder:

import { Magnify } from 'magnify-zone';

const Component = () => {
    return (
        <>
            <Magnify imageUrl='/logo.png' zoomFactor={2} />
        </>
    )
}

When image in src folder

import { Magnify } from 'magnify-zone'
import logo from './logo.png' // relative path to image

const Component = () => {
    return (
        <>
            <Magnify
                imageUrl={logo}
                zoomFactor={2}
                zoomPosition="right"
                zoomWidth={250}
                zoomHeight={250}
                marginSize="10px"
                mainImageWidth="400px"
            />
        </>
    )
}

Styles

You can modify or extend the styles for the Magnify component using the provided CSS classes:

  • .magnify-container: The main container for the Magnify component.
  • .magnify-image-container: Container for the main image.
  • .magnify-zoom: The zoomed-in image.

Notes

  • Ensure that the imageUrl you provide is valid, otherwise, the component will not display the image.
  • For images in public: Use a direct path (e.g., /images/myImage.jpg).
  • For images in src: Import them and then use the imported variable.
  • If the user's cursor is outside the main image's boundaries, the zoomed-in image will automatically be hidden.
  • The zoomFactor prop controls the magnification level of the image when hovered upon. It acts as a multiplier to determine how much larger the magnified area should appear compared to the original size of the image.
    • A zoomFactor of 1 means there is no zoom; the image will be displayed at its original size.
    • A zoomFactor of 2 means the magnified portion will be displayed at twice its original size, making details within that portion more visible.
    • Similarly, a zoomFactor of 3 will magnify the image to three times its original size in the zoomed area, and so forth.
    • In essence, the higher the zoomFactor, the closer and clearer you'll be able to inspect the details of the image within the magnified area. Adjust the zoomFactor based on the level of detail you want users to see when they hover over the image.
1.6.4

7 months ago

1.6.3

7 months ago

1.6.2

7 months ago

1.6.1

7 months ago

1.6.0

7 months ago

1.7.4

7 months ago

1.5.5

8 months ago

1.5.3

8 months ago

1.5.2

8 months ago

1.5.1

8 months ago

1.5.0

8 months ago

1.6.20

7 months ago

1.6.22

7 months ago

1.6.21

7 months ago

1.6.24

7 months ago

1.6.23

7 months ago

1.6.26

7 months ago

1.6.25

7 months ago

1.6.27

7 months ago

1.6.9

7 months ago

1.6.8

7 months ago

1.6.7

7 months ago

1.6.6

7 months ago

1.6.5

7 months ago

1.5.30

8 months ago

1.5.32

8 months ago

1.5.31

8 months ago

1.5.34

7 months ago

1.5.33

8 months ago

1.5.35

7 months ago

1.6.11

7 months ago

1.5.9

8 months ago

1.6.10

7 months ago

1.5.8

8 months ago

1.6.13

7 months ago

1.5.7

8 months ago

1.6.12

7 months ago

1.5.6

8 months ago

1.6.15

7 months ago

1.6.14

7 months ago

1.6.17

7 months ago

1.6.16

7 months ago

1.6.19

7 months ago

1.6.18

7 months ago

1.7.3

7 months ago

1.7.2

7 months ago

1.7.1

7 months ago

1.7.0

7 months ago

1.5.10

8 months ago

1.5.12

8 months ago

1.5.11

8 months ago

1.5.14

8 months ago

1.5.13

8 months ago

1.5.16

8 months ago

1.5.15

8 months ago

1.5.18

8 months ago

1.5.17

8 months ago

1.5.19

8 months ago

1.5.21

8 months ago

1.5.20

8 months ago

1.5.23

8 months ago

1.5.22

8 months ago

1.5.25

8 months ago

1.5.24

8 months ago

1.5.27

8 months ago

1.5.26

8 months ago

1.5.29

8 months ago

1.5.28

8 months ago

1.4.6

8 months ago

1.4.5

8 months ago

1.4.3

8 months ago

1.4.2

8 months ago

1.4.1

9 months ago

1.4.0

9 months ago

1.3.0

9 months ago

1.2.6

9 months ago

1.2.5

9 months ago

1.2.2

9 months ago

1.2.1

9 months ago

1.2.0

9 months ago

1.1.33

9 months ago

1.1.32

9 months ago

1.1.31

9 months ago

1.1.30

9 months ago

1.1.27

9 months ago

1.1.26

9 months ago

1.1.25

9 months ago

1.1.24

9 months ago

1.1.23

9 months ago

1.1.22

9 months ago

1.1.21

9 months ago

1.1.20

9 months ago

1.1.19

9 months ago

1.1.18

9 months ago

1.1.17

9 months ago

1.1.16

9 months ago

1.1.15

9 months ago

1.1.14

9 months ago

1.1.13

9 months ago

1.1.12

9 months ago

1.1.11

9 months ago

1.1.10

9 months ago

1.1.9

9 months ago

1.1.8

9 months ago

1.1.7

9 months ago

1.1.6

9 months ago

1.1.5

9 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.54

9 months ago

1.0.52

9 months ago

1.0.51

9 months ago

1.0.50

9 months ago

1.0.49

9 months ago

1.0.48

9 months ago

1.0.47

9 months ago

1.0.45

9 months ago

1.0.44

9 months ago

1.0.43

9 months ago

1.0.42

9 months ago

1.0.41

9 months ago

1.0.40

9 months ago

1.0.39

9 months ago

1.0.38

9 months ago

1.0.37

9 months ago

1.0.36

9 months ago

1.0.35

9 months ago

1.0.34

9 months ago

1.0.33

9 months ago

1.0.31

9 months ago

1.0.30

9 months ago

1.0.29

9 months ago

1.0.28

9 months ago

1.0.27

9 months ago

1.0.26

9 months ago

1.0.25

9 months ago

1.0.24

9 months ago

1.0.23

9 months ago

1.0.22

9 months ago

1.0.21

9 months ago

1.0.20

9 months ago

1.0.17

9 months ago

1.0.16

9 months ago

1.0.15

9 months ago

1.0.14

9 months ago

1.0.13

9 months ago

1.0.12

9 months ago

1.0.11

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago