MIT License

项目介绍

miromannino/Justified-Gallery 是一个托管在 GitHub 上的开源项目,主要使用 HTML 编写,采用 MIT License 许可证,目前获得 1.7k 个 Star、289 次 Fork。

仓库全名
miromannino/Justified-Gallery
开源许可证
MIT License
Star 数
1.7k
Fork 数
289
未关闭 Issue
124

README 摘要

Justified Gallery is a JavaScript library that allows you to create an high quality justified gallery of images. This is a common problem for people who create websites: you have a series of images to display, but you are not sure how to arrange them in an elegant way. Important websites such as 500px, Flickr, or Google display images in an excellent way, justifying them similarly to brick wall. Justified Gallery…

完整内容见 GitHub 原始 README 或本页 。

常见问题

Justified-Gallery 用什么语言开发?

主要使用 HTML 编写,采用 MIT License 许可证,目前有 1.7k 个 Star。

Justified-Gallery 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 Justified-Gallery 的源码?

可以直接克隆仓库:git clone https://github.com/miromannino/Justified-Gallery.git,默认分支为 master;安装与运行步骤见仓库 README。

Justified-Gallery 最近还在维护吗?

仓库最近一次更新为 1 周前,当前有 124 个未关闭 Issue;Star 数为 1.7k,可作为社区活跃度的参考。

README

Justified Gallery is a JavaScript library that allows you to create an high quality justified gallery of images.

Official project page

This is a common problem for people who create websites: you have a series of images to display, but you are not sure how to arrange them in an elegant way. Important websites such as 500px, Flickr, or Google display images in an excellent way, justifying them similarly to brick wall. Justified Gallery will give you the power to do that too.
Justified Gallery is a professional and open source library that even 500px chose for displaying their images!

npm version license

open issues closed issues unit tests e2e tests

GitHub stars total downloads

Monthly npm downloads (last 24 months)

(combined across justified-gallery and legacy justifiedGallery npm packages)

Usage

import { JustifiedGallery } from "justified-gallery";
import "justified-gallery/style.css";

const gallery = document.getElementById("gallery");
const jg = new JustifiedGallery(gallery);
jg.init();

// later, on unmount:
jg.destroy();

JustifiedGallery is a plain class working against a real HTMLElement, so it integrates the same way in any framework: get a ref to the container, call init() once it’s mounted, and call destroy() on cleanup. See test/browser/html/react_gallery.tsx and test/browser/html/vue_gallery.vue for working React and Vue examples.

The stylesheet keeps entries hidden until they’re positioned, so you don’t see a flash of raw, unpositioned images. This only applies inside a container with the justified-gallery class, since that’s what the CSS targets:

.justified-gallery > a,
.justified-gallery > div,
.justified-gallery > figure {
  opacity: 0;
  /* ... */
}

init() adds that class for you, but not until your script runs. So the hiding won’t actually happen before then unless you also add the class yourself, directly in your markup:

<div id="gallery" class="justified-gallery">...</div>

init() adding the class again is harmless; destroy() still removes it.

This also depends on the CSS itself being loaded before your script runs. The import "justified-gallery/style.css" above takes care of that for bundler setups (bundlers usually put CSS imports into a <link> that loads ahead of your JS). If you’re loading the library from a plain <script> tag or CDN with no build step, link the stylesheet the same way, directly in <head>, before your script tag:

<link
  rel="stylesheet"
  href="https://.../justified-gallery/dist/assets/justified-gallery.css"
/>

Contributing

  • Prerequisites:

    • Node.js
    • npm install to install all dependencies.
  • Develop:

    • npm run dev starts a Vite dev server against test/browser, serving the source directly (no build step needed while iterating). In this mode /text/browser/html pages can be explored. These are the same pages used by the e2e tests.
  • Build:

    • npm run build compiles the library for distribution: bundles src/justified-gallery.ts with Vite into dist/justified-gallery.js and dist/assets/justified-gallery.css, and emits type declarations (dist/*.d.ts) with tsc.
    • npm run preview serves the built dist output locally.
  • Test:

    • npm test runs the full suite (unit tests, then browser/e2e tests).
    • npm run test:unit runs the Vitest unit tests in test/unit.
    • npm run test:e2e runs the Playwright browser tests in test/browser.
  • Try the built package as a real npm dependency:

    • scripts/test-local-package.sh builds the library, npm links it, and links/serves it from sandbox-consumer/ (a throwaway, gitignored Vite project) — useful to confirm the published package resolves and works the way a downstream consumer would experience it.

评论

暂无评论