Socket
Socket
Sign inDemoInstall

image-drag-and-scale

Package Overview
Dependencies
91
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    image-drag-and-scale

This is a library that allows you to drag and scale an image within a div element


Version published
Maintainers
1
Created

Readme

Source

image-drag-and-scale

This is a library that allows you to drag and scale an image within a div element

NPM JavaScript Style Guide

Install

npm install --save image-drag-and-scale

Usage

import React from "react";
import Image from "image-drag-and-scale";
import * as MaterialUI from "@material-ui/core";

const useStyles = MaterialUI.makeStyles(theme => {
  return {
    container: {
      position: "relative",
      width: 500,
      height: 500,
      border: "2px solid red",
      overflow: "hidden",
      transform: "translate(100px, 200px)"
    }
  };
});

const App = props => {
  const imageData = {
    x: 50,
    y: 50,
    translateX: 0,
    translateY: 0,
    scaledWidth: 100,
    scaledHeight: 100,
    width: 100,
    height: 100,
    src: "https://source.unsplash.com/random/1000x1000",
    alt: "random",
    id: "124",
    index: 2
  };

  const classes = useStyles();
  const containerRef = React.useRef();

  return (
    <div className="App">
      <div ref={containerRef} className={classes.container}>
        <Image data={imageData} containerRef={containerRef} />
      </div>
    </div>
  );
};

export default App;

Version Update

v1.1.3

Performance for multiple images is much better Tested with 40 images inside a container

License

MIT © lgdelacruz92

FAQs

Last updated on 15 Nov 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc