【问题标题】:Drag and Drop for Semantic-UI-React component with Packery (masonary) layout使用 Packery(砌体)布局拖放 Semantic-UI-React 组件
【发布时间】:2017-03-12 12:24:27
【问题描述】:

我正在开发具有砖块布局的基于卡片的 UI。我对卡片组件使用语义 ui-react,对砌体布局使用 react-packery-component。

我的反应组件是这个。

import React from 'react';
import DisplayHomePageCardStructure from   
 './DisplayHomePageCardStructure.jsx';
import {Grid} from 'semantic-ui-react';
const Packery = require('react-packery-component')(React);

let packeryOptions = {
 // transitionDuration: 0,
    gutter: 20
};

class DisplayHomePageCard extends React.Component {
constructor() {
    super();
}

render() {
    /* Getting the values from Mongo db*/
    let Data = this.props.display.map(function(item) {
        return (
            <Grid.Column>
              <DisplayHomePageCardStructure id={item.id} displayImage= 
                {item.displayImage}
              heading={item.heading} question={item.question} postedBy=
                {item.postedBy}
              addedOn={item.addedOn} category={item.category} upVotes=
                 {item.upVotes}
              downVotes={item.downVotes} answerCounts={item.answerCounts}  '               
                  views={item.views}
              profileImage={item.profileImage}
            />
          </Grid.Column>

        );
    });
    return (
      <Packery
        elementType={'div'} options={packeryOptions} className = 'packery'>
          {Data}
        </Packery>
    );
  }
}
DisplayHomePageCard .propTypes = {
   display: React.PropTypes.func
 };
module.exports = DisplayHomePageCard;

正如https://github.com/eiriklv/react-packery-component 中所述,我得到了预期的砌体布局,类似于http://www.hearsay.me/

我现在想实现卡片的拖放,功能类似于http://packery.metafizzy.co/draggable.html#jquery-ui-draggable

我需要有关如何实现这一目标的建议。可以仅通过 React 完成(没有 JQuery)吗?如果我需要使用JQuery,我应该怎么做?

【问题讨论】:

    标签: jquery-ui reactjs drag-and-drop packery


    【解决方案1】:

    您可以使用 react-dnd 库通过相对简单的 react 来实现它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-09
      • 2018-10-01
      • 2013-03-20
      • 2019-11-11
      • 1970-01-01
      • 2014-12-13
      • 1970-01-01
      相关资源
      最近更新 更多