0.0.4 • Published 3 years ago

react-iframe-drag v0.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

react-iframe-drag

react-iframe-drag is Implementation of online visual iframe drag and drop scheme

Installing

npm install react-iframe-drag

Exports

import {useSortable, useDrag, useIframeDrop, DragView, DropView } from 'react-iframe-drag

export const componentList = [
  {
    id: '1',
    title: 'ImageList',
    name: 'ImageList',
  },
  {
    id: '2',
    title: 'Goods',
    name: 'Goods',
  },
  {
    id: '3',
    title: 'Box',
    name: 'Box',
  },
];
function DragList() {
  const postMessage = (data) => {
    try {
      const iframe = document.getElementById('iframe-wrr');
      console.log(iframe.contentWindow);
      iframe.contentWindow.postMessage(data, '*');
    } catch (error) {
      console.log(error);
    }
  };
  useDrag({
    refDom: refDom.current,
    id:  "iframe-wrr",
    onDrag: (data) => {
      postMessage({ ...data, type: 1 });
    },
    onDragEnd: (data) => {
      postMessage({ ...data, type: 1, isAdd: true });
    },
    onDragOver: () => {},
    onDragLeave: () => {
      postMessage({ type: -1 });
    },
  });
  return (
    <div className={styles.dragList} ref={refDom}>
      {componentList.map((item, index) => (
        <DragView id={item?.id} item={item}>
          <div className={styles.box}>{item.name}</div>
        </DragView>
      ))}
    </div>
  );
}
0.0.4

3 years ago

0.0.395

3 years ago

0.0.394

3 years ago

0.0.393

3 years ago

0.0.392

3 years ago

0.0.396

3 years ago

0.0.391

3 years ago

0.0.39

3 years ago

0.0.38

3 years ago

0.0.37

3 years ago

0.0.36

3 years ago

0.0.35

3 years ago

0.0.34

3 years ago

0.0.33

3 years ago

0.0.32

3 years ago

0.0.31

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago