Skip to content

Instantly share code, notes, and snippets.

@jiraiyame
Created June 5, 2017 05:47
Show Gist options
  • Save jiraiyame/04473eeef504e840e77c46af2d6e730a to your computer and use it in GitHub Desktop.
Save jiraiyame/04473eeef504e840e77c46af2d6e730a to your computer and use it in GitHub Desktop.
responsive layout powered by flickr's justified layout
@jiraiyame
Copy link
Author

<div id="photoView"></div>

<script type="text/template" id="photoItemTemplate">
  <div class="photo-view-interaction">
    <div class="photo-view-meta">
      <h4 class="photo-view-title">{title}</h4>
      <p class="photo-view-summary">{summary}</p>
    </div>
  </div>
</script>

<script>
  const dataset = [{
    photoUrl: 'xxx.png',
    title: 'xxx',
    summary: 'xxx',
    ...
  }];

  const gallery = new Gallery({
    baseUrl: appConfig.assetsUrl || '/public/assets',
    dataset,
    ratios: [1.1, 1.5, 1.3, 1.3, 1.1, 1.5],
  });

  gallery.init();
</script>

@jimblue
Copy link

jimblue commented Jul 14, 2017

Hello @jiraiyame,

Thanks to make this Gist public, it is exactly what I was looking for.

Coding is absolutely not my job but I understand a bit.

I would like to know if I could adapt your script to plain html (I rendered from php)

The base structure looks like this:

 <div class="photo-gallery">
          <div class="photo-card" data-width="{{ photo_width }}" data-height="{{ photo_height }}">
                <img src="{{ photo_thumbnail }}"/>
          </div>
          // ... repeat this for each images on the pages
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment