Skip to content

Commit

Permalink
fix(multi-backend): typings for touch backend now include all the opt…
Browse files Browse the repository at this point in the history
…ions; use dnd-core types
  • Loading branch information
cormacrelf committed Jun 29, 2018
1 parent 25003eb commit 606d94f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/angular-skyhook-multi-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"lib": {
"entryFile": "src/index.ts",
"umdModuleIds": {
"dnd-core": "dndCore",
"rxjs": "rxjs",
"angular-skyhook": "angularSkyhook"
}
Expand All @@ -35,6 +36,7 @@
"peerDependencies": {
"@angular/core": ">= 5.0.0",
"angular-skyhook": "^1.0.0",
"dnd-core": "^4.0.0",
"rxjs": ">= 5.5.0"
},
"scripts": {
Expand Down
5 changes: 4 additions & 1 deletion packages/angular-skyhook-multi-backend/src/HTML5ToTouch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import {
default as MultiBackend,
MouseTransition,
TouchTransition,
Transition
Transition,
BackendTransition
} from "dnd-multi-backend";

import { Backend, BackendFactory } from 'dnd-core';

export const HTML5ToTouch = {
backends: [
{
Expand Down
27 changes: 22 additions & 5 deletions packages/angular-skyhook-multi-backend/src/ambient.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
declare module "dnd-multi-backend" {
import { Backend } from 'dnd-core';
import { BackendFactory } from 'dnd-core';
import { DragDropManager } from 'dnd-core';
export interface Transition {
event: string;
check: (event: Event) => boolean;
}
export type Backend = any;
export type BackendTransition = {
backend: any;
backend: BackendFactory;
transition: Transition;
preview?: boolean;
};
const MultiBackend: (
transition: { backends: BackendTransition[] }
) => Backend;
) => BackendFactory;
export default MultiBackend;
export const createTransition: (
event: string,
Expand All @@ -22,7 +25,21 @@ declare module "dnd-multi-backend" {
}

declare module "react-dnd-touch-backend" {
import { Backend } from "dnd-multi-backend";
const TouchBackend: ({ enableMouseEvents }: { enableMouseEvents: boolean }) => Backend;
import { Backend, BackendFactory } from "dnd-core";
export interface AngleRange {
start: number, // degrees, moving clockwise with 0/360 = pointing left
end: number, // degrees, moving clockwise with 0/360 = pointing left
}
export interface TouchBackendOptions {
enableMouseEvents?: boolean;
enableTouchEvents?: boolean,
enableKeyboardEvents?: boolean,
ignoreContextMenu?: boolean,
delayTouchStart?: number, // ms
delayMouseStart?: number, // ms
touchSlop?: number, // px
scrollAngleRanges?: AngleRange[] | undefined,
}
const TouchBackend: (options: TouchBackendOptions) => BackendFactory;
export default TouchBackend;
}

0 comments on commit 606d94f

Please sign in to comment.