Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

[DISCUSS] Remove packery - custom js #304

Open
wants to merge 4 commits into
base: production
Choose a base branch
from

Conversation

h-lame
Copy link
Contributor

@h-lame h-lame commented Apr 21, 2017

We're using the packery library to layout the blog posts in a condensed gird, something that at the time of development was impossible to do with pure css. However, I'm almost certain that we've not paid the license fee to be allowed to do so on the site, so we should remove it. This PR replaces it with a custom JS alternative. We don't need to do as much work as packery as our ruby Tiler makes sure each blog tile is in the right place and we have the grid locations as data attributes in the HTML. This JS tiler just needs to go through and absolutely position each tile rather than doing the more complex work that packery does. We may need to do some performance comparisons though to make sure it's not slow.

This is an alternative to #300 and #299

h-lame added 4 commits April 19, 2017 11:42
I don't think we've been using it in correct terms of the license, and I also
think it has some performance issues in the browser as it condenses the
grid.
This class is to replace packery by doing the tiling at html render time,
rather than in JS on the browser.  We construct a Tiler with a number of
rows and columns.  When we add a tile we say what size it is (default is
1x1) and when we layout the tiles the tiler will fit things in and fill
up spaces created by adding larger tiles using any future smaller
tiles if possible.
The HTML now includes data attributes telling the JS tiler the grid
location of each tile, it's size, and the gap between tiles (this data
lives on the container, not each tile).  The tiler then iterates over
each tile and absolutely positions each tile accordingly.
@h-lame h-lame force-pushed the remove-packery-custom-js branch from 1f311a6 to 6a31d24 Compare April 21, 2017 12:14
@h-lame
Copy link
Contributor Author

h-lame commented Apr 21, 2017

TODO:

  • it's not responsive (as in if you resize the window it doesn't, but it does only kick in after the tablet breakpoint)
  • it could probably detect the width / height of the rows better than it does (by looking at the rendered size of the first tile)
  • it might want to be more capable of dealing with missing data attributes (right now it'll halt early or ignore a tile entirely rather than trying to fit it into the grid)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant