From 9b6f3684cbbd096f920614372635a435a611e6fe Mon Sep 17 00:00:00 2001 From: John Knox Date: Mon, 12 Aug 2019 03:02:16 -0700 Subject: [PATCH] Convert utils/snap to TS Reviewed By: danielbuechele Differential Revision: D16710422 fbshipit-source-id: 2f907904a7df24f6972952d0c7a63d7e6506e2ff --- src/ui/components/Interactive.js | 2 +- src/utils/{snap.js => snap.tsx} | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) rename src/utils/{snap.js => snap.tsx} (95%) diff --git a/src/ui/components/Interactive.js b/src/ui/components/Interactive.js index 663f6fd25..33260f433 100644 --- a/src/ui/components/Interactive.js +++ b/src/ui/components/Interactive.js @@ -12,7 +12,7 @@ import { maybeSnapLeft, maybeSnapTop, SNAP_SIZE, -} from '../../utils/snap.js'; +} from '../../utils/snap.tsx'; import styled from '../styled/index.js'; import invariant from 'invariant'; import React from 'react'; diff --git a/src/utils/snap.js b/src/utils/snap.tsx similarity index 95% rename from src/utils/snap.js rename to src/utils/snap.tsx index 723caabb1..377d005be 100644 --- a/src/utils/snap.js +++ b/src/utils/snap.tsx @@ -5,7 +5,7 @@ * @format */ -import type {Rect} from './geometry.js'; +import {Rect} from './geometry.js'; export const SNAP_SIZE = 16; @@ -19,10 +19,10 @@ export function getPossibleSnappedPosition( getGap, getNew, }: { - getNew: (win: Rect) => number, - getGap: (win: Rect) => number, + getNew: (win: Rect) => number; + getGap: (win: Rect) => number; }, -): ?number { +): number | undefined { for (const win of windows) { const gap = Math.abs(getGap(win)); if (gap >= 0 && gap < SNAP_SIZE) { @@ -87,7 +87,6 @@ export function maybeSnapLeft( // │A│B│ // └─┴─┘ const snapRight = getPossibleSnappedPosition(windows, { - debug: true, getGap: win => win.left - (props.width + left), getNew: win => win.left - props.width, });