0.1.7 • Published 6 years ago

react-interactjs-wrapper v0.1.7

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

react-interactjs-wrapper

NPM version Build Status

Install:

npm install react-interactjs-wrapper --save

Props:

PropsTypeDescription
draggableBoolIs the child object supposed to be draggable?
draggableOptionsObjectOptions to pass to the draggable method
resizableBoolIs the child object supposed to be resizable?
resizableOptionsObjectOptions to pass to the resizable method

Example:

import React from 'react'
import { render } from 'react-dom'
import InteractWrapper from 'react-interactjs-wrapper'

const draggableOptions = {
     onmove: event => {
        const target = event.target
      // keep the dragged position in the data-x/data-y attributes
      const x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx
      const y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy

      // translate the element
      target.style.webkitTransform =
      target.style.transform =
        'translate(' + x + 'px, ' + y + 'px)'

      // update the posiion attributes
      target.setAttribute('data-x', x);
      target.setAttribute('data-y', y);
    }
}

const example = (
    <InteractWrapper draggable draggableOptions={draggableOptions}>
        <img src="https://pbs.twimg.com/profile_images/526421493731717120/INda0NaM.png" height={100} width={100}/>
    </InteractWrapper>
)

render(example, document.getElementById('container'));

License:

MIT

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago