eiriklv / react-packery-component

A React.js component for using @desandro's Packery
MIT License
43 stars 35 forks source link

Trying to add the draggabilly to the pbackerty-comonent #3

Closed geohuz closed 8 years ago

geohuz commented 8 years ago

I don't find way to implement this, I am trying to use packery.bindDraggabillyEvents(draggie) in container item Dismount event , but where can I find the instance of the packery?

john-osullivan commented 8 years ago

I also wanted to do this once and couldn't figure out how to.

geohuz commented 8 years ago

I finally choose to incorporate jquery-ui into it, coz I need both drag and resize, I put the logic into componentDidUpdate coz I have items dyanmically adding into the packery container,

  componentDidUpdate(prevProps, prevState) {
    var pckry = this.refs.pckry

    // get item elements, jQuery-ify them
    var $itemElems = $('.packery').find('.item')
    // make item elements draggable
    $itemElems.draggable().resizable();
    // bind Draggable events to Packery
    pckry.packery.bindUIDraggableEvents( $itemElems );

    // handle resizing
    var resizeTimeout;
    $itemElems.on('resize', function(event, ui) {
      // debounce
      if ( resizeTimeout ) {
        clearTimeout( resizeTimeout );
      }
      resizeTimeout = setTimeout( function() {
        pckry.packery.fit( ui.element[0] );
      }, 80 );
    });

  },
kubante commented 8 years ago

Could you post the complete component pls?

kubante commented 8 years ago

Especially, it would be interesting to see to what you assigned the ref=pckry..