mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Merge pull request #9974 from asvetliakov/react-motion-slider
Added definition for react-motion-slider
This commit is contained in:
commit
7ce2630b07
28
react-motion-slider/react-motion-slider-tests.tsx
Normal file
28
react-motion-slider/react-motion-slider-tests.tsx
Normal file
@ -0,0 +1,28 @@
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
/// <reference path="./react-motion-slider.d.ts" />
|
||||
|
||||
import * as React from "react";
|
||||
import Slider from "react-motion-slider";
|
||||
|
||||
class Test extends React.Component<{}, {}> {
|
||||
protected slider: Slider;
|
||||
|
||||
public render() {
|
||||
return (
|
||||
<div onMouseEnter={this.onMouseEnter.bind(this) }>
|
||||
<Slider currentIndex={1}
|
||||
autoHeight
|
||||
align="center"
|
||||
ref={ref => this.slider = ref}
|
||||
>
|
||||
<div key="slide1"/>
|
||||
<div key="slide2"/>
|
||||
</Slider>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
protected onMouseEnter(): void {
|
||||
this.slider.next();
|
||||
}
|
||||
}
|
||||
85
react-motion-slider/react-motion-slider.d.ts
vendored
Normal file
85
react-motion-slider/react-motion-slider.d.ts
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
// Type definitions for react-motion-slider 0.4.1
|
||||
// Project: https://github.com/souporserious/react-motion-slider
|
||||
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
/// <reference path="../react-motion/react-motion.d.ts" />
|
||||
|
||||
|
||||
declare module "react-motion-slider" {
|
||||
import * as React from "react";
|
||||
import { OpaqueConfig } from "react-motion";
|
||||
|
||||
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?: OpaqueConfig;
|
||||
/**
|
||||
* 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<SliderProps, {}> {
|
||||
/**
|
||||
* Moves to next slide
|
||||
*/
|
||||
public next(): void;
|
||||
|
||||
/**
|
||||
* Move to previous slide
|
||||
*/
|
||||
public prev(): void;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user