npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-masonry

v0.17.0

Published

[Homepage](https://passy.github.io/angular-masonry)

Downloads

14,172

Readme

AngularJS Masonry Directive Build StatusDependency Status Code Climate

Homepage

An AngularJS 1 directive to work with David Desandro's Masonry.

Usage

  1. Install via either bower or npm:

    1. bower install --save angular-masonry
    2. npm install --save angular-masonry
  2. Add wu.masonry to your application's module dependencies.

  3. Include dependencies in your HTML.

    <script src="bower_components/ev-emitter/ev-emitter.js"></script>
    <script src="bower_components/desandro-matches-selector/matches-selector.js"></script>
    <script src="bower_components/fizzy-ui-utils/utils.js"></script>
    <script src="bower_components/get-size/get-size.js"></script>
    <script src="bower_components/outlayer/item.js"></script>
    <script src="bower_components/outlayer/outlayer.js"></script>
    <script src="bower_components/masonry/masonry.js"></script>
    
    <!-- optional -->
    <script src="bower_components/imagesloaded/imagesloaded.js"></script>
    <!-- /optional -->
    
    <script src="bower_components/angular/angular.js"></script>
    <script src="bower_components/angular-masonry/angular-masonry.js"></script>
  4. Use the masonry directive.

Example

See the homepage for a live example.

<div masonry load-images="true">
    <div class="masonry-brick" ng-repeat="brick in bricks">
        <img ng-src="{{ brick.src }}" alt="A masonry brick">
    </div>
</div>

You have to include the masonry attribute on the element holding the bricks. The bricks are registered at the directive through the masonry-brick CSS classname.

The directive optionally uses imagesloaded to determine when all images within the masonry-brick have been loaded and adds the loaded CSS class to the element, so you can add custom styles and prevent ghosting effects.

Attributes

item-selector

(Default: .masonry-brick)

You can specify a different item selector through the item-selector attribute. You still need to use masonry-brick either as class name or element attribute on sub-elements in order to register it to the directive.

Example:

<masonry item-selector=".mybrick">
    <div masonry-brick class="mybrick">Unicorns</div>
    <div masonry-brick class="mybrick">Sparkles</div>
</masonry>

column-width

The column-width attribute allows you to override the the width of a column of a horizontal grid. If not set, Masonry will use the outer width of the first element.

Example:

<masonry column-width="200">
    <div class="masonry-brick">This will be 200px wide max.</div>
</masonry>

preserve-order

The preserve-order attributes disables the imagesLoaded logic and will instead display bricks by the order in the DOM instead of by the time they are loaded. Be aware that this can lead to visual glitches if the size of the elements isn't set at the time they are inserted.

Example:

<masonry preserve-order>
    <div class="masonry-brick"><img src="..." alt="Will always be shown 1st"></div>
    <div class="masonry-brick"><img src="..." alt="Will always be shown 2nd"></div>
</masonry>

load-images

Allows usage of imagesLoaded plugin. Defaults to false.

Example:

<masonry load-images="true">
    <div class="masonry-brick"><img src="/your/image_1.jpg" alt="image"/></div>
    <div class="masonry-brick"><img src="/your/image_2.jpg" alt="image"/></div>
</masonry>

reload-on-show

The reload-on-show attribute triggers a reload when the masonry element (or an ancestor element) is shown after being hidden, useful when using ng-show or ng-hide. Without this if the viewport is resized while the masonry element is hidden it may not render properly when shown again.

Example:

<masonry reload-on-show ng-show="showList">
    <div class="masonry-brick">...</div>
    <div class="masonry-brick">...</div>
</masonry>

When showList changes from falsey to truthy ctrl.reload will be called.

reload-on-resize

The reload-on-resize attribute triggers a reload when the masonry element changes its width, useful when only the parent element is resized (and not the window) and you want the elements to be rearranged. Without this if the parent is resized then some blank space may be left on the sides.

Example:

<masonry reload-on-resize>
    <div class="masonry-brick">...</div>
    <div class="masonry-brick">...</div>
</masonry>

masonry-options

You can provide additional options as expression either as masonry or masonry-options attribute.

Example:

<masonry masonry-options="{ transitionDuration: '0.4s' }">
</masonry>

Equivalent to:

<div masonry="{ transitionDuration: '0.4s' }">
</div>

prepend

Bricks are appended by default. This behavior can be specified for each brick by providing the prepend attribute.

Example:

<div masonry>
    <div class="masonry-brick" prepend="isPrepended()">...</div>
</div>

Credits

The directive is based on a StackOverflow question answered by James Sharp.

Contributing

Please refer to CONTRIBUTING.md before opening issues or pull requests.

License

MIT

Bitdeli Badge