GithubHelp home page GithubHelp logo

homaly's Introduction

Homaly

jQuery plugin Horizontal Masonry Layout for Photo Gallery. This project is forked from jLightroom (https://github.com/falkmueller/jLightroom).

Requirements

  • jQuery
  • One of these two plugins: imagesLoaded (for basic usage) or lazysizes (for advanced usage). If none of them is included, Homaly does not work properly.

Basic Usage

Basic usage shoud be used when the gallery does not have too many images so that the browser can load all of them at once. If there are more than 20 images, consider using lazyload technique as mentioned at Advanced Usage section below.

HTML

<div class="homaly-wrapper">
    <div class="homaly_item">
        <img class="homaly_img" src="https://dummyimage.com/900x600/98EF36/fff.jpg&text=Homaly" />
    </div>
    <div class="homaly_item">
        <img class="homaly_img" src="https://dummyimage.com/1000x600/B4A761/fff.jpg&text=Homaly" />
    </div>
</div>

CSS

Just for smooth animation

.homaly_img {
    opacity: 0;
}
.homaly_loaded {
    opacity: 1;
    transition-duration: 2s;
}

Javascript

Homaly requires jQuery and imagesLoaded plugin

<script src="jquery.min.js"></script>
<script src="imagesloaded.pkgd.min.js"></script>
<script src="homaly.min.js"></script>
<!-- Homaly Init -->
<script>
    $(document).ready(function () {
        $(".homaly-wrapper").homaly({
            item_selector: "div.homaly_item",
            img_selector: "img.homaly_img",
            img_loaded_class: "homaly_loaded",
            img_height: 200,
            img_spacing: 5,
        }).init();
    });
</script>

Advanced Usage

HTML

  • <img> tag: Change attribute "src" to "data-src" and add class "lazyload" to use lazysizes
  • <a> tag: Add href link and attribute data-lightbox="lb1" to use lighbox2
<div class="homaly-wrapper">
    <a href="https://dummyimage.com/900x600/98EF36/fff.jpg&text=Homaly" data-lightbox="lb1" class="homaly_item">
        <img data-src="https://dummyimage.com/900x600/98EF36/fff.jpg&text=Homaly" class="homaly_img lazyload" />
    </a>
    <a href="https://dummyimage.com/1000x600/B4A761/fff.jpg&text=Homaly" data-lightbox="lb1" class="homaly_item">
        <img data-src="https://dummyimage.com/1000x600/B4A761/fff.jpg&text=Homaly" class="homaly_img lazyload" />
    </a>
</div>

CSS

<link rel="stylesheet" href="lightbox.min.css">
<link rel="stylesheet" href="animate.min.css">

Javascript

Add class "animate__animated animate__jackInTheBox" or any other "animate__*" class name from animate.css you like to img_loaded_class option

<script src="jquery.min.js"></script>
<script src="lazysizes.min.js"></script>
<script src="lightbox.min.js"></script>
<script src="homaly.min.js"></script>
<!-- Homaly Init -->
<script>
    $(document).ready(function () {
        $(".homaly-wrapper").homaly({
            item_selector: "a.homaly_item",
            img_selector: "img.homaly_img",
            img_loaded_class: "homaly_loaded animate__animated animate__jackInTheBox",
            img_height: 200,
            img_spacing: 5,
        }).init();
    });
</script>

homaly's People

Contributors

lshung avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.