From 03be3be63a3151420f21a44b4e0461097934e974 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Wed, 6 Jul 2016 01:22:37 +0200 Subject: [PATCH 1/2] react-motion-slider type definition --- .../react-motion-slider-tests.tsx | 28 +++++++ react-motion-slider/react-motion-slider.d.ts | 82 +++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 react-motion-slider/react-motion-slider-tests.tsx create mode 100644 react-motion-slider/react-motion-slider.d.ts diff --git a/react-motion-slider/react-motion-slider-tests.tsx b/react-motion-slider/react-motion-slider-tests.tsx new file mode 100644 index 0000000000..b51f57fc3b --- /dev/null +++ b/react-motion-slider/react-motion-slider-tests.tsx @@ -0,0 +1,28 @@ +/// +/// + +import * as React from "react"; +import Slider from "react-motion-slider"; + +class Test extends React.Component<{}, {}> { + protected slider: Slider; + + public render() { + return ( +
+ this.slider = ref} + > +
+
+ +
+ ); + } + + protected onMouseEnter(): void { + this.slider.next(); + } +} diff --git a/react-motion-slider/react-motion-slider.d.ts b/react-motion-slider/react-motion-slider.d.ts new file mode 100644 index 0000000000..71ae1e9b26 --- /dev/null +++ b/react-motion-slider/react-motion-slider.d.ts @@ -0,0 +1,82 @@ +// Type definitions for react-motion-slider 0.4.1 +// Project: https://github.com/souporserious/react-motion-slider +// Definitions by: Alexey Svetliakov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "react-motion-slider" { + import * as React from "react"; + + export interface SliderProps { + /** + * Move to a slide by its key. + */ + currentKey?: string | number; + /** + * Move to a slide by its index. + */ + currentIndex?: number; + /** + * The amount of slides shown in view + * @default 1 + */ + slidesToShow?: number; + /** + * The amount of slides to move upon using prev and next methods. + * @default 1 + */ + slidesToMove?: number; + /** + * Animates the wrapper height to fit the current slide. + * @default false + */ + autoHeight?: boolean; + /** + * Offsets the slide to align either left, center, or right. + * @default "left" + */ + align?: "left" | "center" | "right"; + /** + * Enable touch and/or mouse dragging + * @default true + */ + swipe?: boolean | "touch" | "mouse"; + /** + * The amount the user must swipe to advance slides. (sliderWidth * swipeThreshold) + * @default 0.5 + */ + swipeThreshold?: number; + /** + * The amount of time in milliseconds that determines if a swipe was a flick or not. + */ + flickTimeout?: number; + /** + * Accepts a React Motion spring config. + */ + springConfig?: Object; + /** + * Prop callback fired before slide change. + * @param currentIndex + * @param nextIndex + */ + beforeSlide?: (currentIndex: number, nextIndex: number) => void; + /** + * Prop callback fired after slide change. + * @param currentIndex + */ + afterSlide?: (currentIndex: number) => void; + } + + export default class Slider extends React.Component { + /** + * Moves to next slide + */ + public next(): void; + + /** + * Move to previous slide + */ + public prev(): void; + } +} From e179e32a26efb3133adac5eab5a015a7532635af Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Thu, 7 Jul 2016 10:07:36 +0200 Subject: [PATCH 2/2] Use OpaqueConfig interface from react-motion --- react-motion-slider/react-motion-slider.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/react-motion-slider/react-motion-slider.d.ts b/react-motion-slider/react-motion-slider.d.ts index 71ae1e9b26..939500150d 100644 --- a/react-motion-slider/react-motion-slider.d.ts +++ b/react-motion-slider/react-motion-slider.d.ts @@ -4,9 +4,12 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// +/// + declare module "react-motion-slider" { import * as React from "react"; + import { OpaqueConfig } from "react-motion"; export interface SliderProps { /** @@ -54,7 +57,7 @@ declare module "react-motion-slider" { /** * Accepts a React Motion spring config. */ - springConfig?: Object; + springConfig?: OpaqueConfig; /** * Prop callback fired before slide change. * @param currentIndex