Giter Club home page Giter Club logo

angular-packery's Introduction

angular-packery

Angular module for the popular Packery library.

Continuous Integration Status Dependency Status devDependency Status

Requirements

Optional


Example Usage

Simple

By default, this module listens for an element or attribute call and instantiates with the options described in Packery's API. It looks to a self-created object, div.packery-sizer, to control the grid dimensions.

HTML
<packery ng-init="objects = [{id:'1'},{id:'2'},{id:'3'}]">

  <packery-object>
    <header>
      <h3>Sample object</h3>
    </header>
    <div ng-include="'/resources/partials/some-partial.html'"></div>
  </packery-object>

  <packery-object>
    <div>Mmmm pizza</div>
  </packery-object>

  <packery-object>asdasd</packery-object>

  <packery-object ng-repeat="obj in objects">
     <h3>Dynamic object #{{obj.id}}</h3>
  </packery-object>

  <packery-object>
    <h3>One more</h3>
    <p>...for the road</p>
  </packery-object>

</packery>

CSS

.packery-sizer, .packery-object {
  width: 360px;
  height: 500px;
}

Custom

This module supports almost all of the Packery options in their intended form. As such, custom options can be set via attributes on the main packery element. Please refer to Packery's website for available options.

HTML
<packery row-height=".card.single" column-width=".card.single" handle=".card-header" is-origin-top="false" gutter="20">

  <packery-object class="card single">
    <header class="card-header">
      <h3>Uno</h3>
    </header>
    <div>One</div>
  </packery-object>

  <packery-object class="card double">
    <header class="card-header">
      <h3>Dos</h3>
    </header>
    <div>Two</div>
  </packery-object>

  <packery-object class="card single">
    <header class="card-header">
      <h3>Tres</h3>
    </header>
    <div>Three</div>
  </packery-object>

  <packery-object class="card single">
    <header class="card-header">
      <h3>Fourso</h3>
    </header>
    <div>Four</div>
  </packery-object>

</packery>
CSS
.card.single {
  width: 300px;
  height: 400px;
}

.card.double {
  width: 620px;
  height: 400px;
}

.card-header {
  cursor: move;
}

CSS Classes / Animating

Two CSS classes are applied to the objects to show depth during dragging events, hovered and lifted. The classes are triggered by both mouse events and touch events.

Animation can be applied easily with CSS:

.card {
  -webkit-transition: box-shadow 0.2s;
  -moz-transition: box-shadow 0.2s;
  transition: box-shadow 0.2s;
}

.card.hovered {
  box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
}

.card.lifted {
  box-shadow: 0 13px 33px rgba(100,100,100,0.30), 0 8px 12px rgba(100,100,100,0.22);
  z-index: 5;
}

Events

packeryInstantiated - Emits Packery obj. Fired when a new Packery container is created.

packeryObjectPacked - Emits element. Fired when an object is packed.


A note on ng-include and draggability

Due to how Angular builds ng-include templates, this module does not support using ng-include on your packery-object or custom handle elements. Doing so will cause draggability issues.

To ensure that your dynamic content packs and drags properly, please ensure that the objects and handles are built outside of any ng-include'd content.

Good:

<packery-object>
  <div ng-include="'template.html'"></div>
</packery-object>

Bad:

<packery-object ng-include="'template.html'"></packery-object>

Good:

<packery handle=".card-header">
  <packery-object class="card">
    <header class="card-header"><h3>Drag handle</h3></header>
    <div ng-include="'template.html'"></div>
  </packery-object>
</packery>

Bad:

<packery-object handle=".handle-in-template">
  <div ng-include="'template.html'"></div>
</packery-object>

License

This repository is open source and distributed under the MIT License:

The MIT License

Copyright (c) 2014 Sungard http://www.sungard.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Packery is a product of Metafizzy LLC and is distributed under a separate license. Please refer to their website for information on Packery's license.

angular-packery's People

Contributors

idanb11 avatar joshuahiggins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-packery's Issues

Different heights

Hello,

First, thank you for your work!

I have some troubles with my use case, I have elements with images of different heights and packery doesn't seem to pack it right. It packs my elements with the same height.
Do you have any clue to make it work?

Thank you,
Martin

Maintaining?

I am looking for an angular port of packery but it looks like this is no longer being maintained. Is there any plans for this or has it been dropped?

Draggable attribute to disable/enable draggabilly

Hi, first of thanks for this module, it's really useful to me.
Anyway I was wondering if the attribute draggable is meant to be used ?
It isn't mentioned in the ReadMe however I looked at the source and found that a draggable attribute is provided for the directive. I tried to set it to false but nothing happened.

I would like to do something like this:
<packery draggable="{{isDrag}}"> with isDrag being a variable in my controller.
Basically I just want to enable and disable drag and drop with a click of a button.

Then I found this line: https://github.com/SunGard-Labs/angular-packery/blob/master/src/packery.js#L195
The problem is that scope.draggable will always be true either because of the config boolean or because any variable set in scope.draggable will be a string therefore true.

Anyway after doing a little type check:

if(typeof scope.draggable === "string")
  scope.draggable = (scope.draggable === "true");

I managed to disable drag at launch. But if I change isDrag later for example with a click of a button, of course the draggability won't update.

Is it possible to add this behaviour ? There is a method to enable/disable drag in the Draggabillly module.

Integrate David into Grunt process

David can be used to track dependencies to ensure the repo supports the latest. While badges are provided by David, integrating David into the Grunt process will allow more granular control and input.

Not-supporting the latest updates should cause a CI build failure and should be considered priority #1 on bug-fixes.

Packery-sizer should default to 1x1 pixel grid when no sizing found

Issue #27 brings to light the fact that there's no default sizing set for the Packery grid.

The problem is that this repository is purely JavaScript, but the grid that Packery is built over relies on a base grid size being set via the .packery-sizer CSS class or the row-height and column-width attributes. If no sizing is found, there is currently no default and the grid will get, well, wonky.

Ideally, a 1 pixel height and width would be ideal defaults if no sizing is found, however how can we determine properly if there is no sizing? Currently the default of the repository is to look toward .packery-sizer, and with no way of determining whether this element has sizing attributes set in an external CSS file, I'm at a loss of how to provide a default fallback.

Add support for unpacking packery object and emit packery instance with its hash.

Firstly, It's a great angular module which can fulfill the packery packing functions in angular fashion.
However, when using this module, I find some defects:

  1. Can not remove packery item when the relative data object deleted from collection. We often change our data model collection, say, add data items or remove data items, and angular will adjust the DOM nodes correspondingly. As you known, even if DOM nodes removed, the packery will keep them in the layout until we manually call packery.remove() function or packery.reloadItems() before packery.layout().
  2. $emit "packeryInstantiated" without hash to identify with which $scope this instance should be associated. I think the purpose you $emit "packeryInstantiated" event is giving outer $scope a chance to capture the packery instance for later using, say, invoking packery.layout() to re-layout as necessary. However if the app have multiple packery instances, the outer scope can not identify which $scope it should associated in the event handler. To resolve the issue, we can bind a predefined hash to the "packery" directive, and once the $rootScope capture the "packeryInstantiated" event, the outer $scope can measure whether this instance is the associated one.

Add support for programmatically reordering objects

This idea stems from 2 use cases:

  • Angular renders static markup faster than dynamic markup, such as markup generated via ng-repeat. When generating static and dynamic objects, Packery will append the dynamic after the static despite their original source order.
  • A need to maintain user preferred order and/or positions of Packery objects. For instance, in a dashboard view with multiple widgets, a user may re-order widgets and wish to maintain this preference through later sessions.

Adding support to manage object order and/or positions could potentially address both issues. However, as Packery supports any grid size (down to 1x1 pixel), managing order would also require managing positions.

I'm not sure if this is something that should be added on a project basis, to fit individual needs, or via this modules where I believe it could potentially introduce a larger amount of fringe case bugs.

I'm opening this issue to come back to at a later time and hopefully get some feedback from others.

Repository ownership / maintainers needs to be updated

This repo is owned by the SunGard-Labs GitHub group, which is associated with FIS (formerly SunGard). Until now, I have been 1 of 2 admins associated with the repo, although the second admin is unknown to me. Additionally, I have not been an employee of SunGard / FIS for a while.

As an admin (and not owner), I have restricted access to maintain the repo itself due to it's ownership by the SunGard-Labs user group. Only the official "owner", in the GitHub sense of the term, is able to associate user groups, approve 3rd party integrations (like Travis, Coveralls, or Slack), and many other common tasks.

As there has been activity in this repo as of late, and the ability to manage the repo is limited, there's a couple options to move forward:

  1. An active employee of FIS can petition the company to add new users to the SunGard-Labs group. At that point I can associate these users as admins and I can remove myself from the SunGard-Labs team. This will still result in limited ability to update the repo due to ownership existing outside of the maintainer's reach.
  2. The repo can be forked under the MIT license it's distributed with and given a much needed update, managed by the active maintainers.

File names should match repository name

There is some confusion with the naming of the distributed files, as it matches Packery itself. Files contained in /src and /dist should reflect the name of the repository, angular-packery.

As this is a breaking change, this should align to a minor release.

Expose Packery object

Hi,

I'm using angular-packery in a project, and we have an element that changes size (as we post some data there). This causes a problem as packery is not relocating other elements to allow for that.

I see there's a fit method in the Packery API but the only place I find in angular-packery to access the object directly is a broadcast on rootscope.

Is there a better way to bind this object and use fit? Or is this maybe something on the roadmap, such as the support for stamp?

Add common class to drag handle for styling

The issue: If a project calls for multiple angular-packery instances with different drag handles, adding a common class of cursor: move; would require you to style each drag handle individually.

When creating a handle, angular-packery should add a class of .packery-handle to the element to allow for general CSS styles that are unaware of each individual handle.

Add support for "stamp"

Packery provides a "stamp" method that allows an object to remain static while objects pack around it. This functionality is not present in angular-packery currently and should be added.

How to call shiftLayout on packery instance

I'm a bit confused as to how to call shiftLayout on the packery instance. I have a listener on the dragStart and dragEnd events of Draggabilly to shrink the height of all elements to make them easier to drag and then once it's done bring the heights back to full. But when this happens I need to have packery shift the layout like their animation example so that everything shifts up to one another. How am I supposed to call this on the instance?

I have the packery data set to a scope property like so

$scope.packeryInstance = angular.element('.packery-wrapper').data('Packery');
$($scope.packeryInstance.element).on('dragStart',dragStartListener);
$($scope.packeryInstance.element).on('dragEnd',dragEndListener);

But in my listeners I can't figure out what the proper way to call the shiftLayout method is.

Add testing...

This should be high up on the list after v1.1. This repo needs automated testing.

Boolean attributes unable to set to false

This was discovered via issue #7, but there are other boolean attributes that have the same issue, such as draggable. All current attributes should be checked to ensure that all allowed values perform as expected.

auto reload packery on collection change

Can you please add functionality to auto-reload packery (I believe that would be "reloadItems" method) when the ng-repeat collection changes (in the spirit of angular)?

<packery>
        <packery-object ng-repeat="tile in vm.tiles" >

        </packery-object>
    </packery>

Add CI to support future testing

Travis CI should be added to support #20. Until testing is available, it should at least check that pull requests and commits meet the jshint.

Packery objects do not wrap

When angular packery objects take up more space than the viewport has visible they objects trail off the end of the page instead of wrapping.

Add jQuery UI draggable support

Packery accepts both Draggabilly and jQuery UI support. Currently, angular-packery only allows for Draggabilly support.

One thought is that the draggable attribute should be reworked to accept the following values: boolean jquery draggabilly as opposed to the current boolean only method. We'd need to take this into consideration when addressing issue #13.

I also think that the draggable option should default to false and Draggabilly should be removed from the Bower dependencies.

Add support for Packery 1.3.x

It seems the recent update to Packery 1.3.x has caused some issues with this repo. As a temporary workaround, the bower should be updated to only pull 1.2.x versions as we add support.

JS errors

Quite possibly an issue with my code or with how I installed it but trying to use the example code gives the following errors:
ReferenceError: Packery is not defined
at Object.Packery

I had to install it by putting this in the bower file:
"angular-packery" : "1.0.3"
and running bower install

I've added 'angular-packery' to the module list, but do I need to include any other dependencies?

Thanks

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.