Skip to content

Commit

Permalink
refactor(rstream-gestures): TS strictNullChecks
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jun 9, 2019
1 parent efca49c commit bac2904
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions packages/rstream-gestures/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,24 @@ export interface GestureStreamOpts extends IID<string> {
*/
export const gestureStream = (
el: HTMLElement,
opts?: Partial<GestureStreamOpts>
_opts?: Partial<GestureStreamOpts>
): StreamMerge<any, GestureEvent> => {
let isDown = false,
clickPos: number[];
let isDown = false;
let clickPos: number[] | null = null;

opts = Object.assign(
<GestureStreamOpts>{
id: "gestures",
zoom: 1,
absZoom: true,
minZoom: 0.25,
maxZoom: 4,
smooth: 1,
eventOpts: { capture: true },
preventDefault: true,
local: true,
scale: false
},
opts
);
const opts = <GestureStreamOpts>{
id: "gestures",
zoom: 1,
absZoom: true,
minZoom: 0.25,
maxZoom: 4,
smooth: 1,
eventOpts: { capture: true },
preventDefault: true,
local: true,
scale: false,
..._opts
};

let zoom = Math.min(Math.max(opts.zoom, opts.minZoom), opts.maxZoom);
const dpr = window.devicePixelRatio || 1;
Expand Down Expand Up @@ -187,8 +185,8 @@ export const gestureStream = (
clickPos = null;
break;
case GestureType.DRAG:
body.click = clickPos;
body.delta = [pos[0] - clickPos[0], pos[1] - clickPos[1]];
body.click = clickPos!;
body.delta = [pos[0] - clickPos![0], pos[1] - clickPos![1]];
break;
case GestureType.ZOOM:
const zdelta = (<WheelEvent>e).deltaY * opts.smooth;
Expand Down

0 comments on commit bac2904

Please sign in to comment.