1.6.1 • Published 10 months ago

react-svg-pan-zoom-loader v1.6.1

Weekly downloads
351
License
MIT
Repository
github
Last release
10 months ago

react-svg-pan-zoom-loader

This package allows us to load a SVG file remotely into react-svg-pan-zoom component.

Installation

YARN

yarn add react-svg-pan-zoom-loader

NPM

npm install --save react-svg-pan-zoom-loader

Usage

Example using src prop:

import {ReactSvgPanZoomLoader} from 'react-svg-pan-zoom-loader'

...

return (
    <ReactSvgPanZoomLoader src="file/path/image.svg" className="my-container-class-name" render= {(content) => (
        <ReactSVGPanZoom width={500} height={500}>
            <svg width={500} height={500} >
                {content}
            </svg>
        </ReactSVGPanZoom>
    )}/>
)

Example using svgXML prop:

import {ReactSvgPanZoomLoader} from 'react-svg-pan-zoom-loader'

...

return (
    <ReactSvgPanZoomLoader svgXML={svgAsString} render= {(content) => (
        <ReactSVGPanZoom width={500} height={500}>
            <svg width={500} height={500} >
                {content}
            </svg>
        </ReactSVGPanZoom>
    )}/>
)

Example using src prop with proxy node prop type, under here we can manipulate svg element attributes <SvgLoaderSelectElement/> component.

import {ReactSvgPanZoomLoader, SvgLoaderSelectElement} from 'react-svg-pan-zoom-loader'

...

return (
    <ReactSvgPanZoomLoader src="file/path/image.svg" proxy = {
        <>
            <SvgLoaderSelectElement selector="#tree" onClick={onItemClick}
            stroke={props.strokeColor}/>
        </>
    } render= {(content) => (

        <ReactSVGPanZoom width={500} height={500}>
            <svg width={500} height={500} >
                {content}
            </svg>
        </ReactSVGPanZoom>

    )}/>
)

Example using svgXML prop with proxy node prop type, under here we can manipulate svg element attributes <SvgLoaderSelectElement/> component.

import {ReactSvgPanZoomLoader, SvgLoaderSelectElement} from 'react-svg-pan-zoom-loader'

...
const svgAsString = '<svg xmlns="http://www.w3.org/2000/svg...'

return (
    <ReactSvgPanZoomLoader svgXML={svgAsString} proxy = {
        <>
            <SvgLoaderSelectElement selector="#tree" onClick={onItemClick}
            stroke={props.strokeColor}/>
        </>
    } render= {(content) => (

        <ReactSVGPanZoom width={500} height={500}>
            <svg width={500} height={500} >
                {content}
            </svg>
        </ReactSVGPanZoom>

    )}/>
)

Typescript type definitions

Contributed by Rafal Witczak

npm i @types/react-svg-pan-zoom-loader

Live Demo

Edit react-svg-pan-zoom-loader

Contributors

1.4.4

10 months ago

1.6.1

10 months ago

1.4.3

10 months ago

1.6.0

10 months ago

1.5.1

10 months ago

1.5.0

10 months ago

1.5.0-dev

10 months ago

1.4.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago