Skip to content

Commit

Permalink
chore(module:carousel): remove vertical api (#4376)
Browse files Browse the repository at this point in the history
* feat(module:carousel): remove vertical api

BREAKING CHANGE:

Carousel
 - `nzVertical` is removed. Please use 'nzDotPosition' instead.
  • Loading branch information
Wendell authored and hsuanxyz committed Jan 8, 2020
1 parent 2842dd8 commit 37aa921
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 42 deletions.
2 changes: 1 addition & 1 deletion components/carousel/nz-carousel.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="slick-initialized slick-slider" [class.slick-vertical]="nzVertical">
<div class="slick-initialized slick-slider" [class.slick-vertical]="nzDotPosition === 'left' || nzDotPosition === 'right'">
<div
#slickList
class="slick-list"
Expand Down
22 changes: 1 addition & 21 deletions components/carousel/nz-carousel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,7 @@ import {
import { Subject } from 'rxjs';
import { finalize, takeUntil } from 'rxjs/operators';

import {
InputBoolean,
InputNumber,
NzConfigService,
NzDomEventService,
NzDragService,
warnDeprecation,
WithConfig
} from 'ng-zorro-antd/core';
import { InputBoolean, InputNumber, NzConfigService, NzDomEventService, NzDragService, WithConfig } from 'ng-zorro-antd/core';

import { NzCarouselContentDirective } from './nz-carousel-content.directive';
import {
Expand Down Expand Up @@ -102,17 +94,6 @@ export class NzCarouselComponent implements AfterContentInit, AfterViewInit, OnD
@Input() @WithConfig(NZ_CONFIG_COMPONENT_NAME, 3000) @InputNumber() nzAutoPlaySpeed: number;
@Input() @InputNumber() nzTransitionSpeed = 500;

@Input()
@InputBoolean()
get nzVertical(): boolean {
return this.vertical;
}

set nzVertical(value: boolean) {
warnDeprecation(`'nzVertical' is deprecated and will be removed in 9.0.0. Please use 'nzDotPosition' instead.`);
this.vertical = value;
}

@Input()
@WithConfig(NZ_CONFIG_COMPONENT_NAME, 'bottom')
set nzDotPosition(value: NzCarouselDotPosition) {
Expand Down Expand Up @@ -314,7 +295,6 @@ export class NzCarouselComponent implements AfterContentInit, AfterViewInit, OnD

/**
* Drag carousel.
* @param event
*/
pointerDown = (event: TouchEvent | MouseEvent) => {
if (!this.isDragging && !this.isTransiting && this.nzEnableSwipe) {
Expand Down
23 changes: 3 additions & 20 deletions components/carousel/nz-carousel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { NzCarouselOpacityStrategy } from './strategies/opacity-strategy';
template: `
<nz-carousel
[nzEffect]="effect"
[nzVertical]="vertical"
[nzDots]="dots"
[nzDotPosition]="dotPosition"
[nzDotRender]="dotRender"
Expand All @@ -37,7 +36,6 @@ export class NzTestCarouselBasicComponent {
@ViewChild(NzCarouselComponent, { static: false }) nzCarouselComponent: NzCarouselComponent;
dots = true;
dotPosition = 'bottom';
vertical = false;
effect = 'scrollx';
array = [1, 2, 3, 4];
autoPlay = false;
Expand Down Expand Up @@ -134,21 +132,6 @@ describe('carousel', () => {
expect(carouselContents[0].nativeElement.classList).toContain('slick-active');
}));

// @deprecated 9.0.0
it('should vertical work', () => {
fixture.detectChanges();

expect(carouselWrapper.nativeElement.firstElementChild!.classList).toContain('slick-initialized');
expect(carouselWrapper.nativeElement.firstElementChild!.classList).toContain('slick-slider');
expect(carouselWrapper.nativeElement.firstElementChild!.classList).not.toContain('slick-vertical');
testComponent.vertical = true;
fixture.detectChanges();

expect(carouselWrapper.nativeElement.firstElementChild!.classList).toContain('slick-initialized');
expect(carouselWrapper.nativeElement.firstElementChild!.classList).toContain('slick-slider');
expect(carouselWrapper.nativeElement.firstElementChild!.classList).toContain('slick-vertical');
});

it('should nzDotPosition work', () => {
testComponent.dotPosition = 'left';
fixture.detectChanges();
Expand All @@ -165,7 +148,7 @@ describe('carousel', () => {
expect(carouselWrapper.nativeElement.querySelector('.slick-track').style.transform).not.toBe('');

testComponent.effect = 'fade';
testComponent.vertical = true;
testComponent.dotPosition = 'left';
fixture.detectChanges();
expect(carouselContents[0].nativeElement.classList).toContain('slick-active');
carouselWrapper.nativeElement.querySelector('.slick-dots').lastElementChild.click();
Expand Down Expand Up @@ -297,8 +280,8 @@ describe('carousel', () => {
expect(testComponent.nzCarouselComponent.slickTrackEl.style.transform).toBe(`translate3d(0px, 0px, 0px)`);
}));

it('vertical transform', fakeAsync(() => {
testComponent.vertical = true;
it('vertical', fakeAsync(() => {
testComponent.dotPosition = 'left';
fixture.detectChanges();

expect(testComponent.nzCarouselComponent.slickTrackEl.style.transform).toBe(`translate3d(0px, 0px, 0px)`);
Expand Down

0 comments on commit 37aa921

Please sign in to comment.