diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4c2fbc8e1..0a5475d6c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -83,6 +83,7 @@ All definitions files include a header with the author and editors, so at some p * [Firefox](https://developer.mozilla.org/en-US/docs/Web/API) (by [vvakame](https://github.com/vvakame)) * [FlexSlider](http://www.woothemes.com/flexslider/) (by [Diullei Gomes](https://github.com/Diullei)) * [Flight by Twitter](http://flightjs.github.com/flight/) (by [Jonathan Hedrén](https://github.com/jonathanhedren)) +* [flipsnap.js](http://pxgrid.github.io/js-flipsnap/) (by [kubosho_](https://github.com/kubosho), [gsino](https://github.com/gsino), [Mayuki Sawatari](https://github.com/mayuki)) * [Foundation](http://foundation.zurb.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [FPSMeter](http://darsa.in/fpsmeter/) (by [Aaron Lampros](https://github.com/alampros)) * [fs-extra](https://github.com/jprichardson/node-fs-extra) (by [midknight41](https://github.com/midknight41)) diff --git a/flipsnap/flipsnap-tests.ts b/flipsnap/flipsnap-tests.ts new file mode 100644 index 000000000..a6b2f4fe8 --- /dev/null +++ b/flipsnap/flipsnap-tests.ts @@ -0,0 +1,13 @@ +/** + * Created by kubosho_ on 6/16/2014. + */ +/// + +Flipsnap('', { + maxPoint: 3, + distance: 230, + transitionDuration: 500, + disableTouch: true, + disable3d: false +}); + diff --git a/flipsnap/flipsnap.d.ts b/flipsnap/flipsnap.d.ts new file mode 100644 index 000000000..55e601704 --- /dev/null +++ b/flipsnap/flipsnap.d.ts @@ -0,0 +1,93 @@ +// Type definitions for flipsnap.js +// Project: http://pxgrid.github.io/js-flipsnap/ +// Definitions by: kubosho_ , gsino , Mayuki Sawatari +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface IFlipsnap { + /** + * Return true or false. true is returned when there is previous element. + */ + hasPrev(): boolean; + + /** + * Return true or false. true is returned when there is next element. + */ + hasNext(): boolean; + + /** + * Move to previous item. + */ + toPrev(transitionDuration?: number): void; + + /** + * Move to next item. + */ + toNext(transitionDuration?: number): void; + + /** + * Move to item of number. + */ + moveToPoint(point: number, transitionDuration?: number): void; + + /** + * Recalculate values + */ + refresh(): void; + + element: HTMLElement; +} + +interface FlipsnapStatic { + /** + * @param element The element + */ + (element: HTMLElement, opts?: FlipsnapOptions): IFlipsnap; + + /** + * @param selector The parameter must be CSS Selector. When set string, to get first element of result. Not all element. + */ + (selector: string, opts?: FlipsnapOptions): IFlipsnap; +} + +interface FlipsnapOptions { + /** + * Stop point count. default is auto calculate from element item count. + */ + maxPoint?: number; + /** + * Move distance. default is auto calculate from element width and maxPont. + */ + distance?: number; + /** + * Transition duration (millisecond). default is 350. + */ + transitionDuration?: number; + /** + * When set true, touch event is disabled. Only handling button or etc interface. default is false. + */ + disableTouch?: boolean; + /** + * When support 3D transform browser and this option set true, it is not used 3D transform and use 2D transform. You should set true, when it is a device which has a bug in 3D transform(old Android or BlackBerry etc). default is false. + */ + disable3d?: boolean; +} + +interface HTMLElement { + addEventListener(type: "fstouchstart", listener: (ev: Event) => any, useCapture?: boolean): void; + addEventListener(type: "fstouchmove", listener: (ev: FlipsnapTouchMoveEvent) => any, useCapture?: boolean): void; + addEventListener(type: "fstouchend", listener: (ev: FlipsnapTouchEndEvent) => any, useCapture?: boolean): void; +} + +interface FlipsnapTouchMoveEvent extends Event { + delta: number; + direction: number; +} + +interface FlipsnapTouchEndEvent extends Event { + moved: boolean; + cancelled: boolean; + newPoint: number; + originalPoint: number; +} + +declare var Flipsnap: FlipsnapStatic;