metafizzy / outlayer

:construction_worker: the brains & guts of a layout library
163 stars 63 forks source link

Populate "stamps" on Outlayer.prototype.reloadItems #36

Closed druellan closed 8 years ago

druellan commented 9 years ago

Not sure if this is a bug or workflow decision, but when you reinitialize the items with Outlayer.prototype.reloadItems, new stamped items are not refreshed.

Why is not implemented this way?

Outlayer.prototype._create = function() {
  // get items from children
  this.reloadItems();
  // set container style
  utils.extend( this.element.style, this.options.containerStyle );

  // bind resize method
  if ( this.options.isResizeBound ) {
    this.bindResize();
  }
};

// goes through all children again and gets bricks in proper order
Outlayer.prototype.reloadItems = function() {
  // collection of item elements
  this.items = this._itemize( this.element.children );
  // elements that affect layout, but are not laid out
  this.stamps = [];
  this.stamp( this.options.stamp );
};
desandro commented 9 years ago

Thanks for your interest. Two reasons:

Outlayer.prototype.reloadContent = function() {
  // collection of item elements
  this.reloadItems();
  // elements that affect layout, but are not laid out
  this.stamps = [];
  this.stamp( this.options.stamp );
};
druellan commented 9 years ago

Thanks for the reply.

Yes, my problem is that this.stamp( this.options.stamp ); it is only called from Outlayer.prototype._create. So, if you are adding new "stamped" items on Packery for example, you need to use addItems or appended methods, otherwise new stamped items are not recognized. Thats OK BUT, I'm relying on `reloadItems' just because I need to maintain a custom order for the items, so, it is much easier to just layout the bricks and call ´reloadItems´. I don't know if that makes sense.

I'm going to implement reloadContent as you suggest.

BTW, I'm also working on a new item property, "locked". The idea is to have an item that flow with the layout, but has some restrictions. For example, can't be dragged and can't be displaced if you drag another item over it.

Thanks again!

desandro commented 9 years ago

Sounds interesting. I'd love to see the results and how you're putting Outlayer to use

druellan commented 9 years ago

Thanks! I have dirty hack working, but I want to implement this into Outlayer and Packery's source to allow other users to use/fork or patch the code, since it looks that a couple of devs already asked for something like this.