Sha256: 546d7d9abc3b3bbb8aa9269716a9c3a0110e00144b5bb195252e3fc928bbb410

Contents?: true

Size: 905 Bytes

Versions: 15

Compression:

Stored size: 905 Bytes

Contents

import React from "react";
import PropTypes from "prop-types";

export default function DragElement(props) {
  const { draggable, dragState, container } = props;

  if (draggable === "Files") {
    return "";
  } else {
    const containerSize = container.current.getBoundingClientRect();
    const x = dragState.x - (containerSize.x || containerSize.left);
    const y = dragState.y - (containerSize.y || containerSize.top);
    const translateStyle = {
      transform: `translate3d(${x}px, ${y}px, 0)`
    };
    return (
      <div className="drag-image" style={translateStyle}>
        {draggable.record.image && (
          <img src={draggable.record.src || draggable.record.image.thumbnail_url} />
        )}
      </div>
    );
  }
}

DragElement.propTypes = {
  draggable: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
  dragState: PropTypes.object,
  container: PropTypes.object
};

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
pages_core-3.12.1 app/javascript/components/ImageGrid/DragElement.jsx
pages_core-3.12.0 app/javascript/components/ImageGrid/DragElement.jsx
pages_core-3.11.3 app/javascript/components/ImageGrid/DragElement.jsx
pages_core-3.11.2 app/javascript/components/ImageGrid/DragElement.jsx
pages_core-3.11.1 app/javascript/components/ImageGrid/DragElement.jsx
pages_core-3.11.0 app/javascript/components/ImageGrid/DragElement.jsx
pages_core-3.10.2 app/javascript/components/ImageGrid/DragElement.jsx
pages_core-3.10.1 app/javascript/components/ImageGrid/DragElement.jsx
pages_core-3.9.2 app/javascript/components/ImageGrid/DragElement.jsx
pages_core-3.9.1 app/javascript/components/ImageGrid/DragElement.jsx
pages_core-3.9.0 app/javascript/components/ImageGrid/DragElement.jsx
pages_core-3.8.3 app/javascript/components/ImageGrid/DragElement.jsx
pages_core-3.8.2 app/javascript/components/ImageGrid/DragElement.jsx
pages_core-3.8.1 app/javascript/components/ImageGrid/DragElement.jsx
pages_core-3.8.0 app/javascript/components/ImageGrid/DragElement.jsx