import { MapInteractionCSS } from 'react-map-interaction';
// This component uses CSS to scale your content.
// Just pass in content as children and it will take care of the rest.
const ThingMap = () => {
return (
<MapInteractionCSS>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
import { MapInteraction } from 'react-map-interaction';
// Use MapInteraction if you want to determine how to use the resulting translation.
const NotUsingCSS = () => {
return (
<MapInteraction>
{
({ translation, scale }) => { /* Use the passed values to scale content on your own. */ }
}
</MapInteraction>
);
}
import { MapInteractionCSS } from 'react-map-interaction';
// If you want to have control over the scale and translation,
// then use the `scale`, `translation`, and `onChange` props.
class Controlled extends Component {
constructor(props) {
super(props);
this.state = {
value: {
scale: 1,
translation: { x: 0, y: 0 }
}
};
}
render() {
const { scale, translation } = this.state;
return (
<MapInteractionCSS
value={this.state.value}
onChange={(value) => this.setState({ value })}
>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
}
{
value: PropTypes.shape({
// The scale applied to the dimensions of the contents. A scale of 1 means the
// contents appear at actual size, greater than 1 is zoomed, and between 0 and 1 is shrunken.
scale: PropTypes.number,
// The distance in pixels to translate the contents by.
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
defaultValue: PropTypes.shape({
scale: PropTypes.number,
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
// Stops user from being able to zoom, but will still adhere to props.scale
disableZoom: PropTypes.bool,
// Stops user from being able to pan. Note that translation can still be
// changed via zooming, in order to keep the focal point beneath the cursor. This prop does not change the behavior of the `translation` prop.
disablePan: PropTypes.bool,
// Apply a limit to the translation in any direction in pixel values. The default is unbounded.
translationBounds: PropTypes.shape({
xMin: PropTypes.number, xMax: PropTypes.number, yMin: PropTypes.number, yMax: PropTypes.number
}),
// Called with an object { scale, translation }
onChange: PropTypes.func,
// The min and max of the scale of the zoom. Must be > 0.
minScale: PropTypes.number,
maxScale: PropTypes.number,
// When 'showControls' is 'true', plus/minus buttons are rendered
// that let the user control the zoom factor
showControls: PropTypes.bool,
// Content to render in each of the control buttons (only when 'showControls' is 'true')
plusBtnContents: PropTypes.node,
minusBtnContents: PropTypes.node,
// Class applied to the controls wrapper (only when 'showControls' is 'true')
controlsClass: PropTypes.string,
// Class applied to the plus/minus buttons (only when 'showControls' is 'true')
btnClass: PropTypes.string,
// Classes applied to each button separately (only when 'showControls' is 'true')
plusBtnClass: PropTypes.string,
minusBtnClass: PropTypes.string,
};
{
// Function called with an object { translation, scale }
// translation: { x: number, y: number }, The current origin of the content
// scale: number, The current multiplier mapping original coordinates to current coordinates
children: PropTypes.func,
// The rest of the prop types are the same as MapInteractionCSS
...MapInteractionCSS.propTypes,
}
import { MapInteractionCSS } from 'react-map-interaction';
// This component uses CSS to scale your content.
// Just pass in content as children and it will take care of the rest.
const ThingMap = () => {
return (
<MapInteractionCSS>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
import { MapInteraction } from 'react-map-interaction';
// Use MapInteraction if you want to determine how to use the resulting translation.
const NotUsingCSS = () => {
return (
<MapInteraction>
{
({ translation, scale }) => { /* Use the passed values to scale content on your own. */ }
}
</MapInteraction>
);
}
import { MapInteractionCSS } from 'react-map-interaction';
// If you want to have control over the scale and translation,
// then use the `scale`, `translation`, and `onChange` props.
class Controlled extends Component {
constructor(props) {
super(props);
this.state = {
value: {
scale: 1,
translation: { x: 0, y: 0 }
}
};
}
render() {
const { scale, translation } = this.state;
return (
<MapInteractionCSS
value={this.state.value}
onChange={(value) => this.setState({ value })}
>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
}
{
value: PropTypes.shape({
// The scale applied to the dimensions of the contents. A scale of 1 means the
// contents appear at actual size, greater than 1 is zoomed, and between 0 and 1 is shrunken.
scale: PropTypes.number,
// The distance in pixels to translate the contents by.
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
defaultValue: PropTypes.shape({
scale: PropTypes.number,
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
// Stops user from being able to zoom, but will still adhere to props.scale
disableZoom: PropTypes.bool,
// Stops user from being able to pan. Note that translation can still be
// changed via zooming, in order to keep the focal point beneath the cursor. This prop does not change the behavior of the `translation` prop.
disablePan: PropTypes.bool,
// Apply a limit to the translation in any direction in pixel values. The default is unbounded.
translationBounds: PropTypes.shape({
xMin: PropTypes.number, xMax: PropTypes.number, yMin: PropTypes.number, yMax: PropTypes.number
}),
// Called with an object { scale, translation }
onChange: PropTypes.func,
// The min and max of the scale of the zoom. Must be > 0.
minScale: PropTypes.number,
maxScale: PropTypes.number,
// When 'showControls' is 'true', plus/minus buttons are rendered
// that let the user control the zoom factor
showControls: PropTypes.bool,
// Content to render in each of the control buttons (only when 'showControls' is 'true')
plusBtnContents: PropTypes.node,
minusBtnContents: PropTypes.node,
// Class applied to the controls wrapper (only when 'showControls' is 'true')
controlsClass: PropTypes.string,
// Class applied to the plus/minus buttons (only when 'showControls' is 'true')
btnClass: PropTypes.string,
// Classes applied to each button separately (only when 'showControls' is 'true')
plusBtnClass: PropTypes.string,
minusBtnClass: PropTypes.string,
};
{
// Function called with an object { translation, scale }
// translation: { x: number, y: number }, The current origin of the content
// scale: number, The current multiplier mapping original coordinates to current coordinates
children: PropTypes.func,
// The rest of the prop types are the same as MapInteractionCSS
...MapInteractionCSS.propTypes,
}
import { MapInteractionCSS } from 'react-map-interaction';
// This component uses CSS to scale your content.
// Just pass in content as children and it will take care of the rest.
const ThingMap = () => {
return (
<MapInteractionCSS>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
import { MapInteraction } from 'react-map-interaction';
// Use MapInteraction if you want to determine how to use the resulting translation.
const NotUsingCSS = () => {
return (
<MapInteraction>
{
({ translation, scale }) => { /* Use the passed values to scale content on your own. */ }
}
</MapInteraction>
);
}
import { MapInteractionCSS } from 'react-map-interaction';
// If you want to have control over the scale and translation,
// then use the `scale`, `translation`, and `onChange` props.
class Controlled extends Component {
constructor(props) {
super(props);
this.state = {
value: {
scale: 1,
translation: { x: 0, y: 0 }
}
};
}
render() {
const { scale, translation } = this.state;
return (
<MapInteractionCSS
value={this.state.value}
onChange={(value) => this.setState({ value })}
>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
}
{
value: PropTypes.shape({
// The scale applied to the dimensions of the contents. A scale of 1 means the
// contents appear at actual size, greater than 1 is zoomed, and between 0 and 1 is shrunken.
scale: PropTypes.number,
// The distance in pixels to translate the contents by.
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
defaultValue: PropTypes.shape({
scale: PropTypes.number,
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
// Stops user from being able to zoom, but will still adhere to props.scale
disableZoom: PropTypes.bool,
// Stops user from being able to pan. Note that translation can still be
// changed via zooming, in order to keep the focal point beneath the cursor. This prop does not change the behavior of the `translation` prop.
disablePan: PropTypes.bool,
// Apply a limit to the translation in any direction in pixel values. The default is unbounded.
translationBounds: PropTypes.shape({
xMin: PropTypes.number, xMax: PropTypes.number, yMin: PropTypes.number, yMax: PropTypes.number
}),
// Called with an object { scale, translation }
onChange: PropTypes.func,
// The min and max of the scale of the zoom. Must be > 0.
minScale: PropTypes.number,
maxScale: PropTypes.number,
// When 'showControls' is 'true', plus/minus buttons are rendered
// that let the user control the zoom factor
showControls: PropTypes.bool,
// Content to render in each of the control buttons (only when 'showControls' is 'true')
plusBtnContents: PropTypes.node,
minusBtnContents: PropTypes.node,
// Class applied to the controls wrapper (only when 'showControls' is 'true')
controlsClass: PropTypes.string,
// Class applied to the plus/minus buttons (only when 'showControls' is 'true')
btnClass: PropTypes.string,
// Classes applied to each button separately (only when 'showControls' is 'true')
plusBtnClass: PropTypes.string,
minusBtnClass: PropTypes.string,
};
{
// Function called with an object { translation, scale }
// translation: { x: number, y: number }, The current origin of the content
// scale: number, The current multiplier mapping original coordinates to current coordinates
children: PropTypes.func,
// The rest of the prop types are the same as MapInteractionCSS
...MapInteractionCSS.propTypes,
}
import { MapInteractionCSS } from 'react-map-interaction';
// This component uses CSS to scale your content.
// Just pass in content as children and it will take care of the rest.
const ThingMap = () => {
return (
<MapInteractionCSS>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
import { MapInteraction } from 'react-map-interaction';
// Use MapInteraction if you want to determine how to use the resulting translation.
const NotUsingCSS = () => {
return (
<MapInteraction>
{
({ translation, scale }) => { /* Use the passed values to scale content on your own. */ }
}
</MapInteraction>
);
}
import { MapInteractionCSS } from 'react-map-interaction';
// If you want to have control over the scale and translation,
// then use the `scale`, `translation`, and `onChange` props.
class Controlled extends Component {
constructor(props) {
super(props);
this.state = {
value: {
scale: 1,
translation: { x: 0, y: 0 }
}
};
}
render() {
const { scale, translation } = this.state;
return (
<MapInteractionCSS
value={this.state.value}
onChange={(value) => this.setState({ value })}
>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
}
{
value: PropTypes.shape({
// The scale applied to the dimensions of the contents. A scale of 1 means the
// contents appear at actual size, greater than 1 is zoomed, and between 0 and 1 is shrunken.
scale: PropTypes.number,
// The distance in pixels to translate the contents by.
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
defaultValue: PropTypes.shape({
scale: PropTypes.number,
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
// Stops user from being able to zoom, but will still adhere to props.scale
disableZoom: PropTypes.bool,
// Stops user from being able to pan. Note that translation can still be
// changed via zooming, in order to keep the focal point beneath the cursor. This prop does not change the behavior of the `translation` prop.
disablePan: PropTypes.bool,
// Apply a limit to the translation in any direction in pixel values. The default is unbounded.
translationBounds: PropTypes.shape({
xMin: PropTypes.number, xMax: PropTypes.number, yMin: PropTypes.number, yMax: PropTypes.number
}),
// Called with an object { scale, translation }
onChange: PropTypes.func,
// The min and max of the scale of the zoom. Must be > 0.
minScale: PropTypes.number,
maxScale: PropTypes.number,
// When 'showControls' is 'true', plus/minus buttons are rendered
// that let the user control the zoom factor
showControls: PropTypes.bool,
// Content to render in each of the control buttons (only when 'showControls' is 'true')
plusBtnContents: PropTypes.node,
minusBtnContents: PropTypes.node,
// Class applied to the controls wrapper (only when 'showControls' is 'true')
controlsClass: PropTypes.string,
// Class applied to the plus/minus buttons (only when 'showControls' is 'true')
btnClass: PropTypes.string,
// Classes applied to each button separately (only when 'showControls' is 'true')
plusBtnClass: PropTypes.string,
minusBtnClass: PropTypes.string,
};
{
// Function called with an object { translation, scale }
// translation: { x: number, y: number }, The current origin of the content
// scale: number, The current multiplier mapping original coordinates to current coordinates
children: PropTypes.func,
// The rest of the prop types are the same as MapInteractionCSS
...MapInteractionCSS.propTypes,
}
import { MapInteractionCSS } from 'react-map-interaction';
// This component uses CSS to scale your content.
// Just pass in content as children and it will take care of the rest.
const ThingMap = () => {
return (
<MapInteractionCSS>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
import { MapInteraction } from 'react-map-interaction';
// Use MapInteraction if you want to determine how to use the resulting translation.
const NotUsingCSS = () => {
return (
<MapInteraction>
{
({ translation, scale }) => { /* Use the passed values to scale content on your own. */ }
}
</MapInteraction>
);
}
import { MapInteractionCSS } from 'react-map-interaction';
// If you want to have control over the scale and translation,
// then use the `scale`, `translation`, and `onChange` props.
class Controlled extends Component {
constructor(props) {
super(props);
this.state = {
value: {
scale: 1,
translation: { x: 0, y: 0 }
}
};
}
render() {
const { scale, translation } = this.state;
return (
<MapInteractionCSS
value={this.state.value}
onChange={(value) => this.setState({ value })}
>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
}
{
value: PropTypes.shape({
// The scale applied to the dimensions of the contents. A scale of 1 means the
// contents appear at actual size, greater than 1 is zoomed, and between 0 and 1 is shrunken.
scale: PropTypes.number,
// The distance in pixels to translate the contents by.
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
defaultValue: PropTypes.shape({
scale: PropTypes.number,
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
// Stops user from being able to zoom, but will still adhere to props.scale
disableZoom: PropTypes.bool,
// Stops user from being able to pan. Note that translation can still be
// changed via zooming, in order to keep the focal point beneath the cursor. This prop does not change the behavior of the `translation` prop.
disablePan: PropTypes.bool,
// Apply a limit to the translation in any direction in pixel values. The default is unbounded.
translationBounds: PropTypes.shape({
xMin: PropTypes.number, xMax: PropTypes.number, yMin: PropTypes.number, yMax: PropTypes.number
}),
// Called with an object { scale, translation }
onChange: PropTypes.func,
// The min and max of the scale of the zoom. Must be > 0.
minScale: PropTypes.number,
maxScale: PropTypes.number,
// When 'showControls' is 'true', plus/minus buttons are rendered
// that let the user control the zoom factor
showControls: PropTypes.bool,
// Content to render in each of the control buttons (only when 'showControls' is 'true')
plusBtnContents: PropTypes.node,
minusBtnContents: PropTypes.node,
// Class applied to the controls wrapper (only when 'showControls' is 'true')
controlsClass: PropTypes.string,
// Class applied to the plus/minus buttons (only when 'showControls' is 'true')
btnClass: PropTypes.string,
// Classes applied to each button separately (only when 'showControls' is 'true')
plusBtnClass: PropTypes.string,
minusBtnClass: PropTypes.string,
};
{
// Function called with an object { translation, scale }
// translation: { x: number, y: number }, The current origin of the content
// scale: number, The current multiplier mapping original coordinates to current coordinates
children: PropTypes.func,
// The rest of the prop types are the same as MapInteractionCSS
...MapInteractionCSS.propTypes,
}
import { MapInteractionCSS } from 'react-map-interaction';
// This component uses CSS to scale your content.
// Just pass in content as children and it will take care of the rest.
const ThingMap = () => {
return (
<MapInteractionCSS>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
import { MapInteraction } from 'react-map-interaction';
// Use MapInteraction if you want to determine how to use the resulting translation.
const NotUsingCSS = () => {
return (
<MapInteraction>
{
({ translation, scale }) => { /* Use the passed values to scale content on your own. */ }
}
</MapInteraction>
);
}
import { MapInteractionCSS } from 'react-map-interaction';
// If you want to have control over the scale and translation,
// then use the `scale`, `translation`, and `onChange` props.
class Controlled extends Component {
constructor(props) {
super(props);
this.state = {
value: {
scale: 1,
translation: { x: 0, y: 0 }
}
};
}
render() {
const { scale, translation } = this.state;
return (
<MapInteractionCSS
value={this.state.value}
onChange={(value) => this.setState({ value })}
>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
}
{
value: PropTypes.shape({
// The scale applied to the dimensions of the contents. A scale of 1 means the
// contents appear at actual size, greater than 1 is zoomed, and between 0 and 1 is shrunken.
scale: PropTypes.number,
// The distance in pixels to translate the contents by.
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
defaultValue: PropTypes.shape({
scale: PropTypes.number,
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
// Stops user from being able to zoom, but will still adhere to props.scale
disableZoom: PropTypes.bool,
// Stops user from being able to pan. Note that translation can still be
// changed via zooming, in order to keep the focal point beneath the cursor. This prop does not change the behavior of the `translation` prop.
disablePan: PropTypes.bool,
// Apply a limit to the translation in any direction in pixel values. The default is unbounded.
translationBounds: PropTypes.shape({
xMin: PropTypes.number, xMax: PropTypes.number, yMin: PropTypes.number, yMax: PropTypes.number
}),
// Called with an object { scale, translation }
onChange: PropTypes.func,
// The min and max of the scale of the zoom. Must be > 0.
minScale: PropTypes.number,
maxScale: PropTypes.number,
// When 'showControls' is 'true', plus/minus buttons are rendered
// that let the user control the zoom factor
showControls: PropTypes.bool,
// Content to render in each of the control buttons (only when 'showControls' is 'true')
plusBtnContents: PropTypes.node,
minusBtnContents: PropTypes.node,
// Class applied to the controls wrapper (only when 'showControls' is 'true')
controlsClass: PropTypes.string,
// Class applied to the plus/minus buttons (only when 'showControls' is 'true')
btnClass: PropTypes.string,
// Classes applied to each button separately (only when 'showControls' is 'true')
plusBtnClass: PropTypes.string,
minusBtnClass: PropTypes.string,
};
{
// Function called with an object { translation, scale }
// translation: { x: number, y: number }, The current origin of the content
// scale: number, The current multiplier mapping original coordinates to current coordinates
children: PropTypes.func,
// The rest of the prop types are the same as MapInteractionCSS
...MapInteractionCSS.propTypes,
}
import { MapInteractionCSS } from 'react-map-interaction';
// This component uses CSS to scale your content.
// Just pass in content as children and it will take care of the rest.
const ThingMap = () => {
return (
<MapInteractionCSS>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
import { MapInteraction } from 'react-map-interaction';
// Use MapInteraction if you want to determine how to use the resulting translation.
const NotUsingCSS = () => {
return (
<MapInteraction>
{
({ translation, scale }) => { /* Use the passed values to scale content on your own. */ }
}
</MapInteraction>
);
}
import { MapInteractionCSS } from 'react-map-interaction';
// If you want to have control over the scale and translation,
// then use the `scale`, `translation`, and `onChange` props.
class Controlled extends Component {
constructor(props) {
super(props);
this.state = {
value: {
scale: 1,
translation: { x: 0, y: 0 }
}
};
}
render() {
const { scale, translation } = this.state;
return (
<MapInteractionCSS
value={this.state.value}
onChange={(value) => this.setState({ value })}
>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
}
{
value: PropTypes.shape({
// The scale applied to the dimensions of the contents. A scale of 1 means the
// contents appear at actual size, greater than 1 is zoomed, and between 0 and 1 is shrunken.
scale: PropTypes.number,
// The distance in pixels to translate the contents by.
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
defaultValue: PropTypes.shape({
scale: PropTypes.number,
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
// Stops user from being able to zoom, but will still adhere to props.scale
disableZoom: PropTypes.bool,
// Stops user from being able to pan. Note that translation can still be
// changed via zooming, in order to keep the focal point beneath the cursor. This prop does not change the behavior of the `translation` prop.
disablePan: PropTypes.bool,
// Apply a limit to the translation in any direction in pixel values. The default is unbounded.
translationBounds: PropTypes.shape({
xMin: PropTypes.number, xMax: PropTypes.number, yMin: PropTypes.number, yMax: PropTypes.number
}),
// Called with an object { scale, translation }
onChange: PropTypes.func,
// The min and max of the scale of the zoom. Must be > 0.
minScale: PropTypes.number,
maxScale: PropTypes.number,
// When 'showControls' is 'true', plus/minus buttons are rendered
// that let the user control the zoom factor
showControls: PropTypes.bool,
// Content to render in each of the control buttons (only when 'showControls' is 'true')
plusBtnContents: PropTypes.node,
minusBtnContents: PropTypes.node,
// Class applied to the controls wrapper (only when 'showControls' is 'true')
controlsClass: PropTypes.string,
// Class applied to the plus/minus buttons (only when 'showControls' is 'true')
btnClass: PropTypes.string,
// Classes applied to each button separately (only when 'showControls' is 'true')
plusBtnClass: PropTypes.string,
minusBtnClass: PropTypes.string,
};
{
// Function called with an object { translation, scale }
// translation: { x: number, y: number }, The current origin of the content
// scale: number, The current multiplier mapping original coordinates to current coordinates
children: PropTypes.func,
// The rest of the prop types are the same as MapInteractionCSS
...MapInteractionCSS.propTypes,
}
import { MapInteractionCSS } from 'react-map-interaction';
// This component uses CSS to scale your content.
// Just pass in content as children and it will take care of the rest.
const ThingMap = () => {
return (
<MapInteractionCSS>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
import { MapInteraction } from 'react-map-interaction';
// Use MapInteraction if you want to determine how to use the resulting translation.
const NotUsingCSS = () => {
return (
<MapInteraction>
{
({ translation, scale }) => { /* Use the passed values to scale content on your own. */ }
}
</MapInteraction>
);
}
import { MapInteractionCSS } from 'react-map-interaction';
// If you want to have control over the scale and translation,
// then use the `scale`, `translation`, and `onChange` props.
class Controlled extends Component {
constructor(props) {
super(props);
this.state = {
value: {
scale: 1,
translation: { x: 0, y: 0 }
}
};
}
render() {
const { scale, translation } = this.state;
return (
<MapInteractionCSS
value={this.state.value}
onChange={(value) => this.setState({ value })}
>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
}
{
value: PropTypes.shape({
// The scale applied to the dimensions of the contents. A scale of 1 means the
// contents appear at actual size, greater than 1 is zoomed, and between 0 and 1 is shrunken.
scale: PropTypes.number,
// The distance in pixels to translate the contents by.
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
defaultValue: PropTypes.shape({
scale: PropTypes.number,
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
// Stops user from being able to zoom, but will still adhere to props.scale
disableZoom: PropTypes.bool,
// Stops user from being able to pan. Note that translation can still be
// changed via zooming, in order to keep the focal point beneath the cursor. This prop does not change the behavior of the `translation` prop.
disablePan: PropTypes.bool,
// Apply a limit to the translation in any direction in pixel values. The default is unbounded.
translationBounds: PropTypes.shape({
xMin: PropTypes.number, xMax: PropTypes.number, yMin: PropTypes.number, yMax: PropTypes.number
}),
// Called with an object { scale, translation }
onChange: PropTypes.func,
// The min and max of the scale of the zoom. Must be > 0.
minScale: PropTypes.number,
maxScale: PropTypes.number,
// When 'showControls' is 'true', plus/minus buttons are rendered
// that let the user control the zoom factor
showControls: PropTypes.bool,
// Content to render in each of the control buttons (only when 'showControls' is 'true')
plusBtnContents: PropTypes.node,
minusBtnContents: PropTypes.node,
// Class applied to the controls wrapper (only when 'showControls' is 'true')
controlsClass: PropTypes.string,
// Class applied to the plus/minus buttons (only when 'showControls' is 'true')
btnClass: PropTypes.string,
// Classes applied to each button separately (only when 'showControls' is 'true')
plusBtnClass: PropTypes.string,
minusBtnClass: PropTypes.string,
};
{
// Function called with an object { translation, scale }
// translation: { x: number, y: number }, The current origin of the content
// scale: number, The current multiplier mapping original coordinates to current coordinates
children: PropTypes.func,
// The rest of the prop types are the same as MapInteractionCSS
...MapInteractionCSS.propTypes,
}
import { MapInteractionCSS } from 'react-map-interaction';
// This component uses CSS to scale your content.
// Just pass in content as children and it will take care of the rest.
const ThingMap = () => {
return (
<MapInteractionCSS>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
import { MapInteraction } from 'react-map-interaction';
// Use MapInteraction if you want to determine how to use the resulting translation.
const NotUsingCSS = () => {
return (
<MapInteraction>
{
({ translation, scale }) => { /* Use the passed values to scale content on your own. */ }
}
</MapInteraction>
);
}
import { MapInteractionCSS } from 'react-map-interaction';
// If you want to have control over the scale and translation,
// then use the `scale`, `translation`, and `onChange` props.
class Controlled extends Component {
constructor(props) {
super(props);
this.state = {
value: {
scale: 1,
translation: { x: 0, y: 0 }
}
};
}
render() {
const { scale, translation } = this.state;
return (
<MapInteractionCSS
value={this.state.value}
onChange={(value) => this.setState({ value })}
>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
}
{
value: PropTypes.shape({
// The scale applied to the dimensions of the contents. A scale of 1 means the
// contents appear at actual size, greater than 1 is zoomed, and between 0 and 1 is shrunken.
scale: PropTypes.number,
// The distance in pixels to translate the contents by.
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
defaultValue: PropTypes.shape({
scale: PropTypes.number,
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
// Stops user from being able to zoom, but will still adhere to props.scale
disableZoom: PropTypes.bool,
// Stops user from being able to pan. Note that translation can still be
// changed via zooming, in order to keep the focal point beneath the cursor. This prop does not change the behavior of the `translation` prop.
disablePan: PropTypes.bool,
// Apply a limit to the translation in any direction in pixel values. The default is unbounded.
translationBounds: PropTypes.shape({
xMin: PropTypes.number, xMax: PropTypes.number, yMin: PropTypes.number, yMax: PropTypes.number
}),
// Called with an object { scale, translation }
onChange: PropTypes.func,
// The min and max of the scale of the zoom. Must be > 0.
minScale: PropTypes.number,
maxScale: PropTypes.number,
// When 'showControls' is 'true', plus/minus buttons are rendered
// that let the user control the zoom factor
showControls: PropTypes.bool,
// Content to render in each of the control buttons (only when 'showControls' is 'true')
plusBtnContents: PropTypes.node,
minusBtnContents: PropTypes.node,
// Class applied to the controls wrapper (only when 'showControls' is 'true')
controlsClass: PropTypes.string,
// Class applied to the plus/minus buttons (only when 'showControls' is 'true')
btnClass: PropTypes.string,
// Classes applied to each button separately (only when 'showControls' is 'true')
plusBtnClass: PropTypes.string,
minusBtnClass: PropTypes.string,
};
{
// Function called with an object { translation, scale }
// translation: { x: number, y: number }, The current origin of the content
// scale: number, The current multiplier mapping original coordinates to current coordinates
children: PropTypes.func,
// The rest of the prop types are the same as MapInteractionCSS
...MapInteractionCSS.propTypes,
}
import { MapInteractionCSS } from 'react-map-interaction';
// This component uses CSS to scale your content.
// Just pass in content as children and it will take care of the rest.
const ThingMap = () => {
return (
<MapInteractionCSS>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
import { MapInteraction } from 'react-map-interaction';
// Use MapInteraction if you want to determine how to use the resulting translation.
const NotUsingCSS = () => {
return (
<MapInteraction>
{
({ translation, scale }) => { /* Use the passed values to scale content on your own. */ }
}
</MapInteraction>
);
}
import { MapInteractionCSS } from 'react-map-interaction';
// If you want to have control over the scale and translation,
// then use the `scale`, `translation`, and `onChange` props.
class Controlled extends Component {
constructor(props) {
super(props);
this.state = {
value: {
scale: 1,
translation: { x: 0, y: 0 }
}
};
}
render() {
const { scale, translation } = this.state;
return (
<MapInteractionCSS
value={this.state.value}
onChange={(value) => this.setState({ value })}
>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
}
{
value: PropTypes.shape({
// The scale applied to the dimensions of the contents. A scale of 1 means the
// contents appear at actual size, greater than 1 is zoomed, and between 0 and 1 is shrunken.
scale: PropTypes.number,
// The distance in pixels to translate the contents by.
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
defaultValue: PropTypes.shape({
scale: PropTypes.number,
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
// Stops user from being able to zoom, but will still adhere to props.scale
disableZoom: PropTypes.bool,
// Stops user from being able to pan. Note that translation can still be
// changed via zooming, in order to keep the focal point beneath the cursor. This prop does not change the behavior of the `translation` prop.
disablePan: PropTypes.bool,
// Apply a limit to the translation in any direction in pixel values. The default is unbounded.
translationBounds: PropTypes.shape({
xMin: PropTypes.number, xMax: PropTypes.number, yMin: PropTypes.number, yMax: PropTypes.number
}),
// Called with an object { scale, translation }
onChange: PropTypes.func,
// The min and max of the scale of the zoom. Must be > 0.
minScale: PropTypes.number,
maxScale: PropTypes.number,
// When 'showControls' is 'true', plus/minus buttons are rendered
// that let the user control the zoom factor
showControls: PropTypes.bool,
// Content to render in each of the control buttons (only when 'showControls' is 'true')
plusBtnContents: PropTypes.node,
minusBtnContents: PropTypes.node,
// Class applied to the controls wrapper (only when 'showControls' is 'true')
controlsClass: PropTypes.string,
// Class applied to the plus/minus buttons (only when 'showControls' is 'true')
btnClass: PropTypes.string,
// Classes applied to each button separately (only when 'showControls' is 'true')
plusBtnClass: PropTypes.string,
minusBtnClass: PropTypes.string,
};
{
// Function called with an object { translation, scale }
// translation: { x: number, y: number }, The current origin of the content
// scale: number, The current multiplier mapping original coordinates to current coordinates
children: PropTypes.func,
// The rest of the prop types are the same as MapInteractionCSS
...MapInteractionCSS.propTypes,
}
import { MapInteractionCSS } from 'react-map-interaction';
// This component uses CSS to scale your content.
// Just pass in content as children and it will take care of the rest.
const ThingMap = () => {
return (
<MapInteractionCSS>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
import { MapInteraction } from 'react-map-interaction';
// Use MapInteraction if you want to determine how to use the resulting translation.
const NotUsingCSS = () => {
return (
<MapInteraction>
{
({ translation, scale }) => { /* Use the passed values to scale content on your own. */ }
}
</MapInteraction>
);
}
import { MapInteractionCSS } from 'react-map-interaction';
// If you want to have control over the scale and translation,
// then use the `scale`, `translation`, and `onChange` props.
class Controlled extends Component {
constructor(props) {
super(props);
this.state = {
value: {
scale: 1,
translation: { x: 0, y: 0 }
}
};
}
render() {
const { scale, translation } = this.state;
return (
<MapInteractionCSS
value={this.state.value}
onChange={(value) => this.setState({ value })}
>
<img src="path/to/thing.png" />
</MapInteractionCSS>
);
}
}
{
value: PropTypes.shape({
// The scale applied to the dimensions of the contents. A scale of 1 means the
// contents appear at actual size, greater than 1 is zoomed, and between 0 and 1 is shrunken.
scale: PropTypes.number,
// The distance in pixels to translate the contents by.
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
defaultValue: PropTypes.shape({
scale: PropTypes.number,
translation: PropTypes.shape({ x: PropTypes.number, y: PropTypes.number }),
}),
// Stops user from being able to zoom, but will still adhere to props.scale
disableZoom: PropTypes.bool,
// Stops user from being able to pan. Note that translation can still be
// changed via zooming, in order to keep the focal point beneath the cursor. This prop does not change the behavior of the `translation` prop.
disablePan: PropTypes.bool,
// Apply a limit to the translation in any direction in pixel values. The default is unbounded.
translationBounds: PropTypes.shape({
xMin: PropTypes.number, xMax: PropTypes.number, yMin: PropTypes.number, yMax: PropTypes.number
}),
// Called with an object { scale, translation }
onChange: PropTypes.func,
// The min and max of the scale of the zoom. Must be > 0.
minScale: PropTypes.number,
maxScale: PropTypes.number,
// When 'showControls' is 'true', plus/minus buttons are rendered
// that let the user control the zoom factor
showControls: PropTypes.bool,
// Content to render in each of the control buttons (only when 'showControls' is 'true')
plusBtnContents: PropTypes.node,
minusBtnContents: PropTypes.node,
// Class applied to the controls wrapper (only when 'showControls' is 'true')
controlsClass: PropTypes.string,
// Class applied to the plus/minus buttons (only when 'showControls' is 'true')
btnClass: PropTypes.string,
// Classes applied to each button separately (only when 'showControls' is 'true')
plusBtnClass: PropTypes.string,
minusBtnClass: PropTypes.string,
};