Skip to content

Packery and infinitescroll, including draggabilly in the callback #50

@macsupport

Description

@macsupport

I am using packery with infinitescroll and it works well but I can't get draggabilly to work with the appended elements. I'm sure I am wrong on the callback to include dtaggabilly on the new elements

Packery code:

var $container = $('#container');
var pckry = new Packery( container, {
  // options
  itemSelector: '.item',
  gutter: 10,
  columnWidth: 185,
  rowHeight: 185
});
imagesLoaded( container, function() {
  pckry = new Packery( container );
});
var itemElems = pckry.getItemElements();
// for each item...
for ( var i=0, len = itemElems.length; i < len; i++ ) {
  var elem = itemElems[i];
  // make element draggable with Draggabilly
  var draggie = new Draggabilly( elem );
  // bind Draggabilly events to Packery
  pckry.bindDraggabillyEvents( draggie );
}

my infinite scroll callback:

 function( newElements ) {
     $(newElements).imagesLoaded( function() {
    pckry.appended( newElements ); 
  });
var itemElems = pckry.getItemElements();
// for each item...
for ( var i=0, len = itemElems.length; i < len; i++ ) {
  var elem = itemElems[i];
  // make element draggable with Draggabilly
  var draggie = new Draggabilly( elem );
  // bind Draggabilly events to Packery
  pckry.bindDraggabillyEvents( draggie );
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions