Skip to content

Commit

Permalink
Documenting more types
Browse files Browse the repository at this point in the history
  • Loading branch information
oatkiller committed Dec 19, 2019
1 parent ce110b5 commit c0054d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,32 @@ interface UserSetRasterSize {
readonly payload: Vector2;
}

// TODO, fix and rename this. or remove it
// this is used to directly set the transform of the camera,
// it should be named something like 'userSetPositionOfCamera'. It should work in conjunction with panning (it doesn't, or at least its not tested or tried.)
interface UserSetPanningOffset {
readonly type: 'userSetPanningOffset';
/**
* The world transform of the camera
*/
readonly payload: Vector2;
}

interface UserStartedPanning {
readonly type: 'userStartedPanning';
/**
* A vector in screen coordinates (each unit is a pixel and the Y axis increases towards the bottom of the screen.)
* Represents a starting position during panning for a pointing device.
*/
readonly payload: Vector2;
}

interface UserContinuedPanning {
readonly type: 'userContinuedPanning';
/**
* A vector in screen coordinates (each unit is a pixel and the Y axis increases towards the bottom of the screen.)
* Represents the current position during panning for a pointing device.
*/
readonly payload: Vector2;
}

Expand All @@ -56,7 +70,10 @@ interface UserCanceledPanning {
// This action is blacklisted in redux dev tools
interface UserFocusedOnWorldCoordinates {
readonly type: 'userFocusedOnWorldCoordinates';
// client X and Y of mouse event, adjusted for position of resolver on the page
/**
* World coordinates indicating a point that the user's pointing device is hoving over.
* When the camera's scale is changed, we make sure to adjust its tranform so that the these world coordinates are in the same place on the screen
*/
readonly payload: Vector2;
}

Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/endpoint/public/embeddables/resolver/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { ResolverAction } from './actions';

/**
* Redux state for the Resolver feature. Properties on this interface are populated via multiple reducers using redux's `combineReducers`.
*/
Expand All @@ -14,8 +16,6 @@ export interface ResolverState {
readonly camera: CameraState;
}

export { ResolverAction } from './actions';

interface PanningState {
/**
* Screen coordinate vector representing the starting point when panning.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import React, { useCallback, useState, useEffect, useRef, useMemo } from 'react';
import { Store } from 'redux';
import { Provider, useSelector, useDispatch } from 'react-redux';
import { Dispatch } from 'redux';
import styled from 'styled-components';
import { applyMatrix3 } from '../lib/vector2';
import { ResolverState, ResolverAction, Vector2 } from '../types';
Expand All @@ -21,11 +20,9 @@ export const AppRoot = React.memo(({ store }: { store: Store<ResolverState, Reso
);
});

const useResolverDispatch = () => useDispatch<Dispatch<ResolverAction>>();

const Diagnostic = styled(
React.memo(({ className }: { className?: string }) => {
const dispatch = useResolverDispatch();
const dispatch: (action: ResolverAction) => unknown = useDispatch();

const [ref, setRef] = useState<null | HTMLDivElement>(null);

Expand Down

0 comments on commit c0054d9

Please sign in to comment.