Package detail

angular2gridster

swiety856.3kMIT13.0.0

npm version

gridster, grid, gridLayout, angular

readme

angular2gridster

npm version

Angular implementation of well known Gridster (no jQuery, no external libraries, only Angular and Rx.js). Demo.

  1. Getting started
  2. What is Angular2gridster and why to use it?
  3. API Documentation
  4. Roadmap

More comprehensive documentation is available in Wiki.

Development progress can be tracked in Milestones and in Project board.

Versions:

  • Version 13.x works with Angular 13.x.
  • Version 12.x works with Angular 12.x.
  • Version 11.x works with Angular 11.x.
  • Version 10.x works with Angular 10.x.
  • Version 9.x works with Angular 9.x.
  • Version 8.x works with Angular 8.x.
  • Version 7.x works with Angular 7.x.
  • Version 6.x works with Angular 6.x.
  • Version 5.x works with Angular 5.x.
  • Version 4.x works with Angular 4.x.

Versions 1.x and 0.x works only with Angular 4.x, but the newest states you can find in v4.x.

Installation

npm install angular2gridster

Once installed you need to import our module:

...
import { GridsterModule } from 'angular2gridster';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    ...
    GridsterModule.forRoot() // .forRoot() is required since version v4+
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

The example it imports in AppModule, but it could also be imported in any other module - depends where you want to use it.

Additional steps for System.js

To make Angular2gridster works with System.js you need to provide dedicated configuration in systemjs.config.js. It requires change in map object and 'packages' as follows:

System.config({
    map: {
        // ...
        rxjs: 'node_modules/rxjs',
        angular2gridster: 'node_modules/angular2gridster',
    },
    packages: {
        // ...
        rxjs: {defaultExtension: 'js'},
        angular2gridster: {main: 'dist/index.js', defaultExtension: 'js'},
    },
});

Example usage

<ngx-gridster [options]="gridsterOptions" [draggableOptions]="{ handlerClass: 'panel-heading' }">
    <ngx-gridster-item
        *ngFor="let widget of widgets"
        [(x)]="widget.x"
        [(y)]="widget.y"
        [(w)]="widget.w"
        [(h)]="widget.h"
    >
        <!-- some content -->
    </ngx-gridster-item>
</ngx-gridster>

For version before 6.0.0:

<gridster [options]="gridsterOptions" [draggableOptions]="{ handlerClass: 'panel-heading' }">
    <gridster-item
        *ngFor="let widget of widgets"
        [(x)]="widget.x"
        [(y)]="widget.y"
        [(w)]="widget.w"
        [(h)]="widget.h"
    >
        <!-- some content -->
    </gridster-item>
</gridster>
widgets: Array<any> = [...];
gridsterOptions = {
  lanes: 2, // how many lines (grid cells) dashboard has
  direction: 'vertical', // items floating direction: vertical/horizontal/none
  floating: false, // default=true - prevents items to float according to the direction (gravity)
  dragAndDrop: false, // possible to change items position by drag n drop
  resizable: false, // possible to resize items by drag n drop by item edge/corner
  useCSSTransforms: true, // Uses CSS3 translate() instead of position top/left - significant performance boost.
  responsiveSizes: true, // allow to set different item sizes for different breakpoints
  // ResponsiveOptions can overwrite default configuration with any option available for specific breakpoint.
  responsiveOptions: [
        {
            breakpoint: 'sm',
            lanes: 3
        },
        {
            breakpoint: 'md',
            minWidth: 768,
            lanes: 4,
            dragAndDrop: true,
            resizable: true
        },
        {
            breakpoint: 'lg',
            lanes: 6,
            dragAndDrop: true,
            resizable: true
        },
        {
            breakpoint: 'xl',
            minWidth: 1800,
            lanes: 8,
            dragAndDrop: true,
            resizable: true
        }
    ]
};

Warning

If you use responsiveOptions, then item coords will be assigned to different breakpoint attributes:

  • till sm (480px), it uses x and y attributes
  • sm (480px - 768px), it uses xSm and ySm attributes
  • md (768px - 1250px), it uses xMd and yMd attributes
  • lg (1250px - 1800px), it uses xLg and yLg attributes
  • from xl (1800px), it uses xXl and yXl attributes

(widths in px are only example and works for `responsiveOptions in example above).

If you set responsiveSizes: true, item size can be different for different breakpoints. In this case size will be binded to following attributes:

  • till sm (480px), it uses w and h attributes
  • sm (480px - 768px), it uses wSm and hSm attributes
  • md (768px - 1250px), it uses wMd and hMd attributes
  • lg (1250px - 1800px), it uses wLg and hLg attributes
  • from xl (1800px), it uses wXl and hXl attributes

Demo

Clone or download this repository and just run:

npm i
npm run build
npm start

Go to: http://localhost:4200/

Compilation problems

If somebody will have compilation problems please add an issue (if not yet created). I will try to fix it as soon as possible. Angular compiler has still some issues opened and it is changing frequently.

As a temporary solution copy files from /projects/angular2gridster/src/lib folder to dedicated folder in your project.

Issues

If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via CodeSandbox:

Edit Angular

The project is in development so don't hesitate to writte any questions or suggestion on issue list. I look forward to get a response from you.

Origin

This project was created on idea of GridList. Great alternative for Gridster.

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

13.0.0 (2022-01-11)

12.0.0 (2021-06-26)

Features

  • upgrade: Upgrade to Angular 12 (57e28c4)

11.0.0 (2021-03-21)

Bug Fixes

  • Fix security issues (6f02e08)
  • import style according to angular style guide (a4004a5)

10.0.0 (2021-03-21)

Bug Fixes

  • Fix security issues (6f02e08)
  • import style according to angular style guide (a4004a5)

9.0.0 (2020-02-28)

Features

Bug Fixes

  • Fix security issues (6f02e08)
  • import style according to angular style guide (a4004a5)

8.1.2 (2019-10-23)

Bug Fixes

  • Use rounding again for cell size (9962aa0), closes #347

8.1.1 (2019-10-10)

Bug Fixes

  • Fix lodash Vulnerable version (7e25199)
  • drag: Remove rounding in clalculating cell sizes and item positions (536cd41), closes #346 #334

8.1.0 (2019-08-20)

Bug Fixes

  • demo: Fix resize widget by buttons in demo (3aab09c)

Features

  • config: add Gridster responsiveToParent option (35ca28c), closes #201 #333

8.0.1 (2019-06-10)

Features

7.0.2 (2019-01-26)

Bug Fixes

  • demo: demo not scrollable content (1fb0cd4)
  • drag: fix drag mouse position in scrollabe container (d044b54)

7.0.1 (2018-11-06)

Bug Fixes

  • build: fix peerDependencies (d9f6f02)

7.0.0 (2018-11-04)

Features

6.0.4 (2018-10-09)

Bug Fixes

  • fix element.style is undefined error (7baa71c), closes #298

6.0.3 (2018-10-08)

Bug Fixes

  • Expose private exports in bundle (e50b070), closes #299
  • Prevent error while dragging widget outside browser window
  • Fix getHProperty function. Fixes #283

6.0.2 (2018-07-29)

Bug Fixes

  • fix: set default draggableOptions to empty object
  • fix: change event - oldValues empty when value = 0

6.0.1 (2018-06-18)

Bug Fixes

  • fix: position and size binding on outside change Optimize amount of render calls

6.0.0-rc.1 (2018-05-29)

Bug Fixes

  • fix build bundle

6.0.0-rc.0 (2018-05-29)

Features

  • build: compatibility with Angular 6 (ceb74e3)

BREAKING CHANGES

  • build: New bundles works only with Angular 6. New selector names with ngx prefix

5.0.0 (2018-05-26)

Features

4.0.0 (2018-05-26)

Features

  • allow drag item prototypes to different gridster components in different modules BREAKING CHANGES: requeires .forRoot() in module import

1.6.0 (2018-05-21)

Features

1.5.3 (2018-05-18)

Bug Fixes

  • Make click event to be triggered on touch in drag handler (e8a6578)

1.5.2 (2018-05-06)

Bug Fixes

  • Remove error when adding new widgets with no responsiveOptions (275b1ca), closes #246

1.5.1 (2018-04-16)

Bug Fixes

  • Allow wrapping gridster-item component with other components (e6a5b3f)

1.5.0 (2018-04-15)

Bug Fixes

  • drag: Fix error on prototype drag start (90ade55)
  • Enabling scrolling in demo dashboard (80326f8)
  • prevent changing bindings in gridster items on gridster destroy (982cc53)
  • drag: Remove restriction about dragging items down/right (3e596c5), closes #228

Features

  • api: extend "change" event object to have isNew and oldValues (4e5d541), closes #191
  • config: Add option lines.always to always show grid lines (07c1512), closes #227

1.4.0 (2018-04-13)

Features

  • css: use ViewEncapsultation.None in all components (06cfa7b)
  • drag: Allow gridster inside gridster (1fc10d6)

1.3.4 (2018-03-26)

Bug Fixes

  • drag: Prevent gravity of dragged element on drop (f32144e), closes #214

1.3.3 (2018-03-24)

Bug Fixes

  • drag: Fix problem with resolving collision with gridster gravity on false (8d8f6a4), closes #209

1.3.2 (2018-03-10)

Bug Fixes

  • drag: Fix overlapping in different breakpoints after item resize with floating on false (a411afe)

1.3.1 (2018-03-10)

Bug Fixes

  • remove forgoten console.log (4d4a61a)

1.3.0 (2018-03-10)

Bug Fixes

  • deeps: Add missing RxJs dependencies (f675e66)
  • Hide grid lines on item drag out (49294c2), closes #173
  • drag: Fix overlapping in different breakpoints after item resize with floating on false (09b7e94), closes #194
  • drag: Fix overlapping in different breakpoints after item resize with floating on false (0258d5d)
  • drag: Prevent moving item to negative position (0265244), closes #174
  • drag: Solve problem with dropping items in single lane (624a9fe), closes #183

Features

  • demo: Add reset widgets button (0338921)
  • Add new option gristerOptions.lines.backgroundColor

1.2.1 (2018-02-02)

Bug Fixes

  • Define _items initially (400c4b9), closes #187
  • Update readme.md with info about coords with responsiveOptions set (b8f2227)

1.2.0 (2018-01-01)

Bug Fixes

  • config: correct applying dragAndDrop and resizable options on init (acfbd58), closes #163
  • gridster: add missing unsubscribe (6083508)
  • error when lazy loading widgets (611e56f), closes #165
  • Fix lint errors and extend lint script (f61d42a)

Features

  • display grid lines on drag and resize (d9440bb)

1.1.0 (2017-12-13)

Bug Fixes

  • demo: fix wrong item position on prototype drop (dde685c)
  • drag: Fix exceptions when dropping item prototype with touch devices (8053e01)
  • resize: Fix initial bindings, when new item without data is added. (7e0d0db), closes #158

Features

  • demo: Add "Remove all widgets" button to demo page (aad2c09)

1.0.1 (2017-11-28)

Bug Fixes

  • build: fix build folder

1.0.0 (2017-11-28)

Bug Fixes

  • responsive: Use responsive position properties for items added after gridster init (20ddfe3), closes #116
  • scroll: Use draggable options to enable/disable scroll on resize (7345024)
  • demo: Remove directory demo/src/app/gridster/, add symlink (06cc048)

Features

  • resize: configurable resize handlers (f7f83b5), closes #135
  • scroll: restrict scroll direction to gridster direction (dabcf1a), closes #143

1.0.0-alfa>) (2017-11-19)

Bug Fixes

  • drag: Fix problem with focused el when dragging in IE. Issue #128

Features

  • drag: Provide tolerance for gridster config. Issue #71
  • drag: Scroll container while dragging. Issue #27
  • drag: Output bindings in gridster item on drag/resize start and end
  • resize: Auto height for item. Issue #78

0.6.9>) (2017-11-04)

Bug Fixes

  • api: No binding update on item remove. Issue #120
  • performance Remove unnecessary import of entirety of Rxjs

Features

  • api Add events when reflowing grid items. Issue #115

0.6.8>) (2017-10-16)

Bug Fixes

  • drag: Fix problem with scrolling on touch devices. Issue #111
  • drag Fix drag position bug in scrolled container. Issue #114

Features

  • drag Options: direction: "none" and floating: false. Issue #109
  • performance Disable initial animation. Issue #104
  • config Provide option to set fixed cellWidth/cellHeight. Issue #91

0.6.7>) (2017-09-25)

Bug Fixes

  • drag: Fix problem with IE touch drag by touch-action css. Issue #72
  • performance Prevent performance issues while dragging item with selected text inside
  • resize Fix problem with assigning width/height to gridster element. Issue #85

Features

  • performance useCSSTransforms option for more effective moving rendering while dragging item
  • performance Get rid of getBoundingRect in drag event

0.6.6>) (2017-08-27)

Bug Fixes

  • drag: Make dragging works when gridster is in scrollable element. Issue #21

0.6.5>) (2017-07-28)

Bug Fixes

  • drag: Update gridster element item on drag start
  • config: Fix snap issue with new items and no responsive configuration
  • resize: Fix problem with item resize when no maxWidth and maxHeight option

0.6.4>) (2017-07-28)

Bug Fixes

  • deps: Reorganise project deps - try to fix bug with angular-cli #57

0.6.3>) (2017-07-14)

Bug Fixes

  • drag-drop: fix problem with not working drag n drop events in angular 4.2.6

0.6.2>) (2017-07-13)

Bug Fixes

  • drag-drop: fix dragging new item (gridster-item-prototype) when it's placed in the area of gridster #64

0.6.1>) (2017-07-10)

Bug Fixes

  • config: fix default gridster options
  • responsiveness: fix responsive behaviour on iPhones and iPads

0.6.0>) (2017-07-06)

Bug Fixes

  • drag-drop: solved problems with inputs in gridster-item container
  • drag-drop: bug fix with fast dragging item from outside

Features

  • config: Gridster responsive behaviour
  • config: different Gridster configuration for different breakpoints
  • drag-drop: disabling/enabling moving item in gridster
  • resize: disabling/enabling resizing item in gridster
  • api: new change event on GridsterItem
  • config: new GridsterItem options
  • deps: update angular env to newest version
  • demo: extend demo page
  • config: shrink Gridster height to fit items

0.5.3>) (2017-05-16)

Bug Fixes

  • drag-drop: DnD ngOnInit gridster-item bug fix
  • api: AOT fix for mismatching signature call

Features

  • config: Dynamic widthHeightRatio option change

0.5.2>) (2017-04-30)

Bug Fixes

  • drag-drop: item dragging position fix

Features

  • doc add System.js installation steps
  • demo add polyfills to support older IE

0.5.1>) (2017-04-18)

Bug Fixes

  • api: fix two way binding and change event for "x", "y", "w", "h"

Features

  • performance Prevent detectChanges to be invoked while dragging
  • performance Prevent detectChanges to be invoked while scrolling

0.5.0>) (2017-04-12)

Bug Fixes

  • api: fix two way binding and change event for "x" and "y"

Features

  • resize provide way to resize widgets by drag by every edge or corner
  • api generate most suitable widget positions (x, y) if not given
  • api provide two way binding and change event for "w" and "h"
  • config: enable/disable drag n drop
  • config: enable/disable resize
  • demo: update demo to show resize
  • demo: update demo to disable/enable dragging and resizing
  • demo: update demo to push new widget without defined position

0.4.1>) (2017-04-01)

Bug Fixes

  • api: add missing dependecies

Features

  • deps: Add support for Angular 4

0.4.0>) (2017-03-20)

Bug Fixes

  • css: fix problem with drag and scroll on touch devieces
  • build: recreate build env from scratch

Features

  • drag-drop provide directive that allows to add new widget to dashboard by dragging from outside
  • demo: create Angular CLI demo
  • demo: extend demo to show drag widgets from outside
  • drag-drop: reimplement drag n drop engine
  • api: refactor API of gridster.service
  • api: refactor API of gridster.component
  • api: refactor API of gridser.item.component

0.3.1>) (2017-01-24)

Bug Fixes

  • api move IGridsterOptions and IGridsterDraggableOptions to separate files, closes #9

0.3.0>) (2017-01-24)

Bug Fixes

  • css: move css of position-highlight outside of gridster component
  • css: move inner item styles outside of gridster components
  • css: fix position-highlight styles
  • demo: fix demo styles
  • drag-drop: fix problem of wrong mouse position when dragging and scrolling at once
  • api: replace IGridListItem with GridsterItemComponent
  • api: add isDragging property to GridsterItemComponent with class binding in template, instead of manipulating DOM
  • api: remove GridList cloneItems method

Features

  • config: add possibility to set gridster draggable options from outside
  • config: gridsterPositionChange Event Emmiter
  • config: gridster item x,y two way databind
  • config: add/remove gridster item
  • css: set dynamic gridster container width and height set by service

0.2.3>) (2016-12-21)

Bug Fixes

0.2.2 (2016-12-11)

Bug Fixes

  • build: remove old Angular CLI dependencies in package.json
  • build: fixes for build process

Features

  • config: add possibility to dynamically change gridster item size
  • config: add possibility to dynamically change gridster configuration
  • demo: add option to change size of gridster items
  • demo: add option to change gridster direction (floating): vertical/horizontal
  • demo: add option to change amount of gridster lines

0.2.0 (2016-12-03)

Features

  • build: Angular CLI build was replaced with custom webpack build
  • demo: create demo app component