Skip to content

Commit 0d94838

Browse files
author
Yongnan Wu
committed
angular 12 and bug fixes
1 parent 44fc12c commit 0d94838

File tree

5 files changed

+93
-25
lines changed

5 files changed

+93
-25
lines changed

.gitignore

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (http://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# Typescript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
dist/*
61+

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change log
22

3+
## 12.0.0
4+
5+
- Angular 12 upgrade
6+
- fix space created by pre-loaded item
7+
- SSR check in `remove` function
8+
39
## 11.0.2
410

511
- fix item missing when it doesn't contain image and has ordered mode enabled

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-masonry",
3-
"version": "11.0.2",
3+
"version": "12.0.0",
44
"description": "Angular Module for displaying a feed of items in a masonry layout using https://github.com/desandro/masonry",
55
"keywords": [
66
"angular",
@@ -22,8 +22,8 @@
2222
"url": "https://github.com/wynfred/ngx-masonry/"
2323
},
2424
"peerDependencies": {
25-
"@angular/common": "^11.0.0",
26-
"@angular/core": "^11.0.0",
25+
"@angular/common": "^12.0.0",
26+
"@angular/core": "^12.0.0",
2727
"masonry-layout": "^4.2.0"
2828
},
2929
"dependencies": {

src/lib/ngx-masonry.component.ts

+21-20
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export class NgxMasonryComponent implements OnInit, OnChanges, OnDestroy {
6363
this.masonryInstance.on('removeComplete', (items: any) => {
6464
this.removeComplete.emit(items);
6565
});
66+
this.masonryInstance.items=[];
6667
}
6768
}
6869

@@ -121,28 +122,28 @@ export class NgxMasonryComponent implements OnInit, OnChanges, OnDestroy {
121122

122123
private itemLoaded(item: NgxMasonryDirective) {
123124
if(isPlatformBrowser(this.platformId)){
124-
// Tell Masonry that a child element has been added
125-
if (item.prepend) {
126-
this.masonryInstance.prepended(item.element.nativeElement);
127-
} else {
128-
this.masonryInstance.appended(item.element.nativeElement);
129-
}
130-
131-
// Check if first item
132-
if (this.masonryInstance.items.length === 1) {
133-
this.masonryInstance.layout();
134-
}
135-
item.playAnimation(true);
125+
// Tell Masonry that a child element has been added
126+
if (item.prepend) {
127+
this.masonryInstance.prepended(item.element.nativeElement);
128+
} else {
129+
this.masonryInstance.appended(item.element.nativeElement);
130+
}
131+
132+
// Check if first item
133+
if (this.masonryInstance.items.length === 1) {
134+
this.masonryInstance.layout();
135+
}
136+
item.playAnimation(true);
136137
}
137138
}
138139

139-
public remove(element: HTMLElement) {
140-
if (isPlatformBrowser(this.platformId)) {
141-
// Tell Masonry that a child element has been removed
142-
this.masonryInstance.remove(element);
140+
public remove(element: HTMLElement) {
141+
if (isPlatformBrowser(this.platformId)) {
142+
// Tell Masonry that a child element has been removed
143+
this.masonryInstance.remove(element);
143144

144-
// Layout items
145-
this.layout();
146-
}
147-
}
145+
// Layout items
146+
this.layout();
147+
}
148+
}
148149
}

src/test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
22

3-
import 'zone.js/dist/zone';
4-
import 'zone.js/dist/zone-testing';
3+
import 'zone.js';
4+
import 'zone.js/testing';
55
import { getTestBed } from '@angular/core/testing';
66
import {
77
BrowserDynamicTestingModule,

0 commit comments

Comments
 (0)