Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

Commit

Permalink
fix for animation timing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
RyotaSugawara committed Sep 1, 2017
1 parent 1af274f commit c165b78
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 7 deletions.
Empty file added docs/docs/index.d.ts
Empty file.
4 changes: 2 additions & 2 deletions docs/index.js

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions docs/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/// <reference types="react" />
import * as React from 'react';
export interface Touch {
startX: number;
startY: number;
endX: number;
endY: number;
swipeDirection: number;
}
export interface CarouselProps {
label?: string;
useDots?: boolean;
dotStyle?: any;
duration?: number;
autoSlideInterval?: number;
}
export interface CarouselState {
animate: boolean;
canUseDOM: boolean;
currentIndex: number;
slideCount: number;
slideWidth: any;
slideHeight: any;
swipePosition: number;
showIndex: number;
}
export default class Carousel extends React.Component<CarouselProps, CarouselState> {
container: Element;
swiping: boolean;
moving: boolean;
touch: Touch;
timer: any;
state: CarouselState;
static readonly defaultProps: CarouselProps;
constructor();
componentWillMount(): void;
componentDidMount(): void;
componentDidUpdate(prevProps: any): void;
componentWillUnmount(): void;
render(): JSX.Element;
renderInitialRect(): JSX.Element;
renderCarouselChild(): JSX.Element | JSX.Element[];
renderDots(): JSX.Element;
autoSlide(): void;
resetAutoSlide(): void;
addEvents(): void;
removeEvents(): void;
onResize(): void;
getFrameStyle(): any;
getSlideStyle(index: any): any;
canDisplaySlide(index: any): boolean;
getNextIndex(): number;
getPrevIndex(): number;
getIndexDirection(index: any): 0 | 1 | -1;
updateFrameRect(): void;
move(index: number): void;
next(): void;
prev(): void;
initialize(): void;
handleTouchStart(e: any): void;
handleTouchMove(e: any): boolean;
handleTouchEnd(): void;
judgeSwipeDirection(startX: number, startY: number, endX: number, endY: number): 0 | 1 | -1;
}
6 changes: 1 addition & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,6 @@ export default class Carousel extends React.Component<CarouselProps, CarouselSta
return true;
}

if (!this.state.animate) {
return false;
}

if (this.state.showIndex === index) {
return true;
}
Expand Down Expand Up @@ -349,7 +345,7 @@ export default class Carousel extends React.Component<CarouselProps, CarouselSta
});
}, this.props.duration);
});
});
}, 1000 / 60); // wait 1 frame (at 60fps) for animate
});
}

Expand Down

0 comments on commit c165b78

Please sign in to comment.