Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: merge next to master #2563

Merged
merged 48 commits into from
Nov 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
72b0f52
docs: update NG-ZORRO logo (#2425)
hsuanxyz Nov 10, 2018
a17ea49
fix(module:collapse): can't fold up active panel with accordion (#2440)
wheeljs Nov 13, 2018
d9db523
chore: update styles(ant-design 3.10.7) (#2432)
ng-zorro-bot Nov 18, 2018
2f5b4fc
chore: update styles(ant-design 3.10.8) (#2475)
ng-zorro-bot Nov 20, 2018
811a009
feat: Adds danish locale (#2486)
michaelkrog Nov 20, 2018
e6e2369
fix(module:menu): fix dropdown menu item selected className (#2434)
LiadIdan Nov 24, 2018
7ae325f
fix(module:list): fix invalid render empty style when unspecified dat…
cipchk Nov 24, 2018
1a93749
docs(module:modal): add missing nzClassName property (#2400)
wilsoncook Nov 24, 2018
7d78f57
docs: add faq in icons docs (#2459)
Nov 24, 2018
e41640a
fix(module:menu): fix fold menu (#2454)
ffey Nov 24, 2018
8992fc1
refactor(module:all): use cdk keycodes instead of magic number (#2499)
JLHwung Nov 24, 2018
5b8cdfc
release(1.8.1): release 1.8.1 (#2523)
Nov 25, 2018
c968d39
chore: update styles(ant-design 3.10.9) (#2525)
ng-zorro-bot Nov 30, 2018
12106f0
fix(readme): fix misspelling (#2472)
BlackGanglion Nov 30, 2018
caabc54
refactor(module:all): support Angular 7.0 (#2372)
vthinkxie Oct 29, 2018
1fb825f
refactor(module:checkbox): support checkbox onPush (#2478)
vthinkxie Nov 19, 2018
cec0927
refactor(module:collapse): support onPush in collapse (#2481)
vthinkxie Nov 19, 2018
37c4204
refactor(module:divider): refactor divider (#2482)
vthinkxie Nov 20, 2018
9f81b2f
refactor(module:form): refactor form (#2493)
vthinkxie Nov 21, 2018
856a2ee
refactor(module:grid): refactor grid module (#2498)
vthinkxie Nov 21, 2018
01a2f5b
refactor(module:layout): refactor layout (#2500)
vthinkxie Nov 21, 2018
adaa3c0
feat(module:progress): support custom strokeColor and strokeLinecap (…
hsuanxyz Nov 24, 2018
29358c4
feat(module:avatar): support custom size (#2416)
hsuanxyz Nov 24, 2018
a2e07e6
fix(module:timeline): fix loading icon (#2386)
hsuanxyz Nov 24, 2018
5d535a4
feat(module:drawer): add input property in NzDrawerRef (#2464)
hsuanxyz Nov 24, 2018
4055da8
refactor(module:radio): refactor radio to support OnPush (#2519)
vthinkxie Nov 25, 2018
6b6805c
refactor(module:spin): refactor spin (#2530)
vthinkxie Nov 25, 2018
e21109e
refactor(module:alert & card): refactor card & refactor template outl…
vthinkxie Nov 26, 2018
577e384
refactor(module:switch & checkbox): refactor switch & checkbox (#2533)
vthinkxie Nov 26, 2018
97ead6d
refactor(module:core): refactor input convert decorators (#2535)
hsuanxyz Nov 26, 2018
e9f9686
refactor(module:mention): refactor mention (#2510)
hsuanxyz Nov 30, 2018
d5ed86b
refactor(module:steps): refactor steps (#2512)
Nov 30, 2018
eb6ce13
feat(module:modal): support clicking ESC to close modal (#2483)
wenqi73 Nov 30, 2018
ee6dbb0
refactor(module:breadcrumb): refactor breadcrumb (#2513)
Nov 30, 2018
ba80040
refactor(module:skeleton): refactor skeleton (#2514)
Nov 30, 2018
594a4e8
refactor(module:icon): refactor icon (#2517)
Nov 30, 2018
a518243
refactor(module:tree-select): refactor tree-select (#2528)
hsuanxyz Nov 30, 2018
57d9544
build: bump webpack integration (#2524)
JLHwung Nov 30, 2018
d75420b
refactor(module:timeline): refactor timeline (#2515)
Nov 30, 2018
97d0458
refactor(module:autocomplete): refactor autocomplete (#2505)
hsuanxyz Nov 30, 2018
7dc6185
refactor(module:cascader): refactor cascader (#2516)
Nov 30, 2018
51d52f7
refactor(module:avatar): refactor avatar (#2536)
hsuanxyz Nov 30, 2018
80aeb4a
refactor(module:upload): refactor upload (#2555)
cipchk Nov 30, 2018
2e03594
refactor(module:list): refactor list (#2548)
cipchk Nov 30, 2018
dd62be3
refactor(module:transfer): refactor transfer (#2553)
cipchk Nov 30, 2018
9c800c5
refactor(module:back-top): refactor back-top (#2547)
cipchk Nov 30, 2018
6efce22
refactor(module:anchor): refactor anchor (#2546)
cipchk Nov 30, 2018
e2e2713
refactor(module:affix): refactor affix (#2544)
cipchk Nov 30, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
<a name="1.8.1"></a>
## [1.8.1](https://github.com/NG-ZORRO/ng-zorro-antd/compare/1.8.0...1.8.1) (2018-11-24)


### Bug Fixes

* **collapse:** can't fold up active panel with accordion ([#2440](https://github.com/NG-ZORRO/ng-zorro-antd/issues/2440)) ([a17ea49](https://github.com/NG-ZORRO/ng-zorro-antd/commit/a17ea49)), closes [#2437](https://github.com/NG-ZORRO/ng-zorro-antd/issues/2437)
* **list:** fix invalid render empty style when unspecified data source ([#2415](https://github.com/NG-ZORRO/ng-zorro-antd/issues/2415)) ([7ae325f](https://github.com/NG-ZORRO/ng-zorro-antd/commit/7ae325f)), closes [#2385](https://github.com/NG-ZORRO/ng-zorro-antd/issues/2385)
* **menu:** fix dropdown menu item selected className ([#2434](https://github.com/NG-ZORRO/ng-zorro-antd/issues/2434)) ([e6e2369](https://github.com/NG-ZORRO/ng-zorro-antd/commit/e6e2369)), closes [#2433](https://github.com/NG-ZORRO/ng-zorro-antd/issues/2433)
* **menu:** fix fold menu ([#2454](https://github.com/NG-ZORRO/ng-zorro-antd/issues/2454)) ([e41640a](https://github.com/NG-ZORRO/ng-zorro-antd/commit/e41640a)), closes [#2449](https://github.com/NG-ZORRO/ng-zorro-antd/issues/2449)


### Features

* Adds danish locale ([#2486](https://github.com/NG-ZORRO/ng-zorro-antd/issues/2486)) ([811a009](https://github.com/NG-ZORRO/ng-zorro-antd/commit/811a009)), closes [#2485](https://github.com/NG-ZORRO/ng-zorro-antd/issues/2485)



<a name="1.8.0"></a>
# [1.8.0](https://github.com/NG-ZORRO/ng-zorro-antd/compare/1.7.1...1.8.0) (2018-10-26)

Expand Down
4 changes: 2 additions & 2 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Ant Design 的 Angular 实现,开发和服务于企业级后台产品。

## 🖥 支持环境

- Angular `^6.0.0`
- Angular `^7.0.0`
- 现代浏览器,以及 Internet Explorer 11+ (使用 [polyfills](https://angular.io/guide/browser-support))
- [Electron](http://electron.atom.io/)

Expand Down Expand Up @@ -70,7 +70,7 @@ $ ng add ng-zorro-antd
在每一个需要使用组件的 module 中引入 `NgZorroAntdModule`。

```ts
import { NgZorroAntModule } from 'ng-zorro-antd';
import { NgZorroAntdModule } from 'ng-zorro-antd';

@NgModule({
imports: [ NgZorroAntdModule ]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ English | [简体中文](README-zh_CN.md)

## 🖥 Environment Support

* Angular `^6.0.0`
* Angular `^7.0.0`
* Modern browsers and Internet Explorer 11+ (with [polyfills](https://angular.io/guide/browser-support))
* [Electron](http://electron.atom.io/)

Expand Down Expand Up @@ -77,7 +77,7 @@ $ npm install ng-zorro-antd
Import the module into every module where you want to use the components.

```ts
import { NgZorroAntModule } from 'ng-zorro-antd';
import { NgZorroAntdModule } from 'ng-zorro-antd';

@NgModule({
imports: [ NgZorroAntdModule ]
Expand Down
36 changes: 23 additions & 13 deletions components/affix/affix.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ describe('affix', () => {
new Event('pageshow'),
new Event('load')
];
const height = 100;
const width = 100;

beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
Expand Down Expand Up @@ -109,13 +111,13 @@ describe('affix', () => {
describe('when element gets shifted horizontally', () => {
it('adjusts left position accordingly to maintain natural position', fakeAsync(() => {
setupInitialState();
componentObject.offsetTo(componentObject.elementRef(), { top: startOffset, left: 10, width: 100, height: 100 });
componentObject.offsetTo(componentObject.elementRef(), { top: startOffset, left: 10, width, height });
emitScroll(window, defaultOffsetTop + startOffset + 1);

expect(componentObject.wrap().offsetLeft).toBe(10);

emitScroll(window, defaultOffsetTop + startOffset - 1);
componentObject.offsetTo(componentObject.elementRef(), { top: startOffset, left: 100, width: 100, height: 100 });
componentObject.offsetTo(componentObject.elementRef(), { top: startOffset, left: 100, width, height });
emitScroll(window, defaultOffsetTop + startOffset + 1);

expect(componentObject.wrap().offsetLeft).toBe(100);
Expand Down Expand Up @@ -288,6 +290,15 @@ describe('affix', () => {
fixture.detectChanges();
expect(component.updatePosition).toHaveBeenCalled();
});

it('should be a string value', () => {
spyOn(component, 'updatePosition');
expect(component.updatePosition).not.toHaveBeenCalled();
fixture.detectChanges();
context.fakeTarget = '#target';
fixture.detectChanges();
expect(component.updatePosition).toHaveBeenCalled();
});
});

describe('(nzChange)', () => {
Expand Down Expand Up @@ -318,19 +329,20 @@ describe('affix', () => {
}));
});

it('should adjust the width when resize', fakeAsync(() => {
it('should adjust placeholder width when resize', fakeAsync(() => {
const offsetTop = 150;
context.newOffset = offsetTop;
setupInitialState({ offsetTop: offsetTop + 1 });
emitScroll(window, 2);
expect(componentObject.elementRef().style.width).toBe(`${width}px`);
componentObject.offsetYTo(componentObject.elementRef(), offsetTop + 2);
tick(20);
fixture.detectChanges();
componentObject.emitEvent(window, new Event('resize'));
tick(20);
fixture.detectChanges();

expect(componentObject.wrap().offsetTop).toBe(offsetTop);
expect(componentObject.elementRef().style.width).toBe(``);

discardPeriodicTasks();
}));
Expand All @@ -352,7 +364,7 @@ describe('affix', () => {
}

getOffset(el: Element): Offset {
return this.offsets[el.id] || { top: 10, left: 0, height: 100, width: 100 };
return this.offsets[el.id] || { top: 10, left: 0, height, width };
}

emitEvent(el: Element | Window, event: Event): void {
Expand All @@ -368,8 +380,8 @@ describe('affix', () => {
this.offsets[this.getKey(el)] = {
top: offset.top,
left: offset.left,
height: 100,
width: 100
height,
width
};
}

Expand All @@ -379,8 +391,8 @@ describe('affix', () => {
{
top: offsetTop,
left: 0,
height: 100,
width: 100
height,
width
}
);
}
Expand Down Expand Up @@ -486,14 +498,12 @@ describe('affix-extra', () => {
<button id="content">Affix Button</button>
</nz-affix>
<div id="target"></div>
`,
styleUrls: [ './style/index.less' ],
encapsulation: ViewEncapsulation.None
`
})
class TestAffixComponent {
@ViewChild(NzAffixComponent)
nzAffixComponent: NzAffixComponent;
fakeTarget: Element | Window = null;
fakeTarget: string | Element | Window = null;
newOffset: {};
newOffsetBottom: {};
}
2 changes: 1 addition & 1 deletion components/affix/doc/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Please note that Affix should not cover other content on the page, especially wh
| -------- | ----------- | ---- | ------- |
| `[nzOffsetBottom]` | Pixels to offset from bottom when calculating position of scroll | number | - |
| `[nzOffsetTop]` | Pixels to offset from top when calculating position of scroll | number | 0 |
| `[nzTarget]` | specifies the scrollable area dom node | `HTMLElement` | `window` |
| `[nzTarget]` | specifies the scrollable area dom node | `string, HTMLElement` | `window` |
| `(nzChange)` | Callback for when affix state is changed | `EventEmitter<boolean>` | - |

**Note:** Children of `nz-affix` can not be `position: absolute`, but you can set `nz-affix` as `position: absolute`:
Expand Down
2 changes: 1 addition & 1 deletion components/affix/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ title: Affix
| --- | --- | --- | --- |
| `[nzOffsetBottom]` | 距离窗口底部达到指定偏移量后触发 | number | |
| `[nzOffsetTop]` | 距离窗口顶部达到指定偏移量后触发 | number | |
| `[nzTarget]` | 设置 `nz-affix` 需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 | `HTMLElement` | `window` |
| `[nzTarget]` | 设置 `nz-affix` 需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 | `string, HTMLElement` | `window` |
| `(nzChange)` | 固定状态改变时触发的回调函数 | `EventEmitter<boolean>` | 无 |

**注意:**`nz-affix` 内的元素不要使用绝对定位,如需要绝对定位的效果,可以直接设置 `nz-affix` 为绝对定位:
Expand Down
112 changes: 59 additions & 53 deletions components/affix/nz-affix.component.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// tslint:disable:no-any
import { DOCUMENT } from '@angular/common';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ElementRef,
EventEmitter,
Inject,
Input,
OnDestroy,
OnInit,
Output,
ViewChild
ViewChild,
ViewEncapsulation
} from '@angular/core';

import { NzScrollService } from '../core/scroll/nz-scroll.service';
Expand All @@ -21,41 +23,23 @@ import { throttleByAnimationFrameDecorator } from '../core/util/throttleByAnimat
selector : 'nz-affix',
templateUrl : './nz-affix.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
styles : [
`:host {
styles : [ `
nz-affix {
display: block;
}`
]
}
` ],
encapsulation : ViewEncapsulation.None
})
export class NzAffixComponent implements OnInit, OnDestroy {

private timeout: any;
private events = [
'resize',
'scroll',
'touchstart',
'touchmove',
'touchend',
'pageshow',
'load'
];
private affixStyle: any;
private placeholderStyle: any;

@ViewChild('wrap') private wrap: ElementRef;

private _target: Element | Window = window;

@Input()
set nzTarget(value: Element | Window) {
set nzTarget(value: string | Element | Window) {
this.clearEventListeners();
this._target = value || window;
this._target = typeof value === 'string' ? this.doc.querySelector(value) : value || window;
this.setTargetEventListeners();
this.updatePosition({});
}

private _offsetTop: number;

@Input()
set nzOffsetTop(value: number) {
if (typeof value === 'undefined') {
Expand All @@ -68,8 +52,6 @@ export class NzAffixComponent implements OnInit, OnDestroy {
return this._offsetTop;
}

private _offsetBottom: number;

@Input()
set nzOffsetBottom(value: number) {
if (typeof value === 'undefined') {
Expand All @@ -78,43 +60,48 @@ export class NzAffixComponent implements OnInit, OnDestroy {
this._offsetBottom = toNumber(value, null);
}

@Output() nzChange: EventEmitter<boolean> = new EventEmitter();
@Output()
readonly nzChange: EventEmitter<boolean> = new EventEmitter();

constructor(private scrollSrv: NzScrollService, private _el: ElementRef, private cd: ChangeDetectorRef) {
// tslint:disable-next-line:no-any
constructor(private scrollSrv: NzScrollService, private _el: ElementRef, @Inject(DOCUMENT) private doc: any, private cd: ChangeDetectorRef) {
}

private timeout;
private events = [
'resize',
'scroll',
'touchstart',
'touchmove',
'touchend',
'pageshow',
'load'
];
private affixStyle;
private placeholderStyle;

@ViewChild('wrap') private wrap: ElementRef;

private _target: Element | Window = window;

private _offsetTop: number;

private _offsetBottom: number;

ngOnInit(): void {
this.timeout = setTimeout(() => {
this.setTargetEventListeners();
this.updatePosition({});
});
}

private setTargetEventListeners(): void {
this.clearEventListeners();
this.events.forEach((eventName: string) => {
this._target.addEventListener(eventName, this.updatePosition, false);
});
}

private clearEventListeners(): void {
this.events.forEach(eventName => {
this._target.removeEventListener(eventName, this.updatePosition, false);
});
}

ngOnDestroy(): void {
this.clearEventListeners();
clearTimeout(this.timeout);
// tslint:disable-next-line:no-any
(this.updatePosition as any).cancel();
}

private getTargetRect(target: Element | Window | null): ClientRect {
return target !== window ?
(target as HTMLElement).getBoundingClientRect() :
{ top: 0, left: 0, bottom: 0 } as ClientRect;
}

getOffset(element: Element, target: Element | Window | null): {
top: number;
left: number;
Expand All @@ -127,7 +114,7 @@ export class NzAffixComponent implements OnInit, OnDestroy {
const scrollTop = this.scrollSrv.getScroll(target, true);
const scrollLeft = this.scrollSrv.getScroll(target, false);

const docElem = window.document.body;
const docElem = this.doc.body;
const clientTop = docElem.clientTop || 0;
const clientLeft = docElem.clientLeft || 0;

Expand All @@ -139,6 +126,25 @@ export class NzAffixComponent implements OnInit, OnDestroy {
};
}

private setTargetEventListeners(): void {
this.clearEventListeners();
this.events.forEach((eventName: string) => {
this._target.addEventListener(eventName, this.updatePosition, false);
});
}

private clearEventListeners(): void {
this.events.forEach(eventName => {
this._target.removeEventListener(eventName, this.updatePosition, false);
});
}

private getTargetRect(target: Element | Window | null): ClientRect {
return target !== window ?
(target as HTMLElement).getBoundingClientRect() :
{ top: 0, left: 0, bottom: 0 } as ClientRect;
}

private genStyle(affixStyle: {}): string {
if (affixStyle == null) {
return '';
Expand All @@ -149,7 +155,7 @@ export class NzAffixComponent implements OnInit, OnDestroy {
}).join(';');
}

private setAffixStyle(e: any, affixStyle: {}): void {
private setAffixStyle(e: Event, affixStyle: {}): void {
const originalAffixStyle = this.affixStyle;
const isWindow = this._target === window;
if (e.type === 'scroll' && originalAffixStyle && affixStyle && isWindow) {
Expand Down Expand Up @@ -185,6 +191,7 @@ export class NzAffixComponent implements OnInit, OnDestroy {
}

@throttleByAnimationFrameDecorator()
// tslint:disable-next-line:no-any
updatePosition(e: any): void {
const targetNode = this._target;
// Backwards support
Expand Down Expand Up @@ -250,5 +257,4 @@ export class NzAffixComponent implements OnInit, OnDestroy {
this.setPlaceholderStyle(null);
}
}

}
Loading