Skip to content

Commit ae7e001

Browse files
committed
Fix type/docs for VivViewer and VivView (and upstream users)
1 parent b2e1371 commit ae7e001

File tree

6 files changed

+59
-20
lines changed

6 files changed

+59
-20
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
### Changed
88

9+
- Fix `VivViewer` and `VivView` types.
10+
911
## 0.9.4
1012

1113
### Added

src/viewers/PictureInPictureViewer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { GLOBAL_SLIDER_DIMENSION_FIELDS } from '../constants';
2222
* @param {Object} props.overview Allows you to pass settings into the OverviewView: { scale, margin, position, minimumWidth, maximumWidth,
2323
* boundingBoxColor, boundingBoxOutlineWidth, viewportOutlineColor, viewportOutlineWidth}. See http://viv.gehlenborglab.org/#overviewview for defaults.
2424
* @param {Boolean} props.overviewOn Whether or not to show the OverviewView.
25-
* @param {Object} [props.hoverHooks] Object including utility hooks - an object with key handleValue like { handleValue: (valueArray) => {}, handleCoordinate: (coordinate) => {} } where valueArray
25+
* @param {import('./VivViewer').HoverHooks} [props.hoverHooks] Object including utility hooks - an object with key handleValue like { handleValue: (valueArray) => {}, handleCoordinate: (coordinate) => {} } where valueArray
2626
* has the pixel values for the image under the hover location and coordinate is the coordinate in the image from which the values are picked.
2727
* @param {Array} [props.viewStates] Array of objects like [{ target: [x, y, 0], zoom: -zoom, id: DETAIL_VIEW_ID }] for setting where the viewer looks (optional - this is inferred from height/width/loader
2828
* internally by default using getDefaultInitialViewState).
@@ -41,7 +41,7 @@ import { GLOBAL_SLIDER_DIMENSION_FIELDS } from '../constants';
4141
* @param {import('./VivViewer').ViewStateChange} [props.onViewStateChange] Callback that returns the deck.gl view state (https://deck.gl/docs/api-reference/core/deck#onviewstatechange).
4242
* @param {import('./VivViewer').Hover} [props.onHover] Callback that returns the picking info and the event (https://deck.gl/docs/api-reference/core/layer#onhover
4343
* https://deck.gl/docs/developer-guide/interactivity#the-picking-info-object)
44-
* @param {Array} [props.transitionFields] A string array indicating which fields require a transition: Default: ['t', 'z'].
44+
* @param {Array} [props.transitionFields] A string array indicating which fields require a transition when making a new selection: Default: ['t', 'z'].
4545
*/
4646

4747
const PictureInPictureViewer = props => {
@@ -55,7 +55,7 @@ const PictureInPictureViewer = props => {
5555
overview,
5656
overviewOn,
5757
loaderSelection,
58-
hoverHooks = {},
58+
hoverHooks = { handleValue: () => {}, handleCoordinate: () => {} },
5959
height,
6060
width,
6161
isLensOn = false,

src/viewers/SideBySideViewer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { GLOBAL_SLIDER_DIMENSION_FIELDS } from '../constants';
2323
* @param {number} [props.lensSelection] Numeric index of the channel to be focused on by the lens (default 0).
2424
* @param {Array} [props.lensBorderColor] RGB color of the border of the lens (default [255, 255, 255]).
2525
* @param {number} [props.lensBorderRadius] Percentage of the radius of the lens for a border (default 0.02).
26+
* @param {number} [props.lensRadius] Pixel radius of the lens (default: 100).
2627
* @param {Array} [props.transparentColor] An RGB (0-255 range) color to be considered "transparent" if provided.
2728
* In other words, any fragment shader output equal transparentColor (before applying opacity) will have opacity 0.
2829
* This parameter only needs to be a truthy value when using colormaps because each colormap has its own transparent color that is calculated on the shader.

src/viewers/VivViewer.js

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,56 @@ const areViewStatesEqual = (viewState, otherViewState) => {
1515
/**
1616
* @callback ViewStateChange
1717
* @param {Object} event
18+
* @ignore
1819
*/
1920

2021
/**
2122
* @callback Hover
2223
* @param {Object} info
2324
* @param {Object} event
25+
* @ignore
2426
*/
2527

2628
/**
27-
* This component handles rendering the various views within the DeckGL contenxt.
28-
* @param {Object} props
29-
* @param {Array} props.layerProps Props for the layers in each view.
30-
* @param {Array} props.randomize Whether or not to randomize which view goes first (for dynamic rendering).
31-
* @param {VivView} props.views Various VivViews to render.
32-
* @param {Array} props.viewStates List of objects like [{ target: [x, y, 0], zoom: -zoom, id: 'left' }, { target: [x, y, 0], zoom: -zoom, id: 'right' }]
33-
* @param {ViewStateChange} [props.onViewStateChange] Callback that returns the deck.gl view state (https://deck.gl/docs/api-reference/core/deck#onviewstatechange).
34-
* @param {Hover} [props.onHover] Callback that returns the picking info and the event (https://deck.gl/docs/api-reference/core/layer#onhover
29+
* @callback HandleValue
30+
* @param {Array.<number>} valueArray pixel values for the image under the hover location
31+
* @ignore
32+
*/
33+
34+
/**
35+
* @callback HandleCoordinate
36+
* @param {Object} coordnate The coordinate in the image from which the values are picked.
37+
* @ignore
38+
*/
39+
40+
/**
41+
* @typedef HoverHooks
42+
* @type {object}
43+
* @property {HandleValue} handleValue
44+
* @property {HandleCoordinate} handleCoordinate
45+
* @ignore
46+
*/
47+
48+
/**
49+
* @typedef LayerProps
50+
* @type {object}
51+
* @property {Array} layerProps Props for the layers in each view.
52+
* @property {boolean} [randomize] Whether or not to randomize which view goes first (for dynamic rendering of multiple linked views).
53+
* @property {Array.<import('../views').VivView>} views Various `VivView`s to render.
54+
* @property {Array.<object>} viewStates List of objects like [{ target: [x, y, 0], zoom: -zoom, id: 'left' }, { target: [x, y, 0], zoom: -zoom, id: 'right' }]
55+
* @property {ViewStateChange} [onViewStateChange] Callback that returns the deck.gl view state (https://deck.gl/docs/api-reference/core/deck#onviewstatechange).
56+
* @property {Hover} [onHover] Callback that returns the picking info and the event (https://deck.gl/docs/api-reference/core/layer#onhover
3557
* https://deck.gl/docs/developer-guide/interactivity#the-picking-info-object)
58+
* @property {HoverHooks} [hoverHooks] Object including utility hooks - an object with key handleValue like { handleValue: (valueArray) => {}, handleCoordinate: (coordinate) => {} } where valueArray
59+
* has the pixel values for the image under the hover location and coordinate is the coordinate in the image from which the values are picked.
3660
*/
61+
3762
export default class VivViewer extends PureComponent {
63+
/**
64+
* This component handles rendering the various views within the DeckGL contenxt.
65+
* @param {LayerProps} props
66+
*/
67+
3868
constructor(props) {
3969
super(props);
4070
this.state = {
@@ -56,8 +86,9 @@ export default class VivViewer extends PureComponent {
5686
* This prevents only the `draw` call of a layer from firing,
5787
* but not other layer lifecycle methods. Nonetheless, it is
5888
* still useful.
59-
* @param {Layer} layer Layer being updated.
60-
* @param {Viewport} viewport Viewport being updated.
89+
* @param {object} args
90+
* @param {object} args.layer Layer being updated.
91+
* @param {object} args.viewport Viewport being updated.
6192
* @returns {boolean} Whether or not this layer should be drawn in this viewport.
6293
*/
6394
// eslint-disable-next-line class-methods-use-this

src/views/SideBySideView.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@ import { getImageLayers, getVivId, makeBoundingBox } from './utils';
99
* It is linked with its other views as controlled by `linkedIds`, `zoomLock`, and `panLock` parameters.
1010
* It takes the same arguments for its constructor as its base class VivView plus the following:
1111
* @param {Object} args
12-
* @param {Array} args.linkedIds Ids of the other views to which this could be locked via zoom/pan.
12+
* @param {Array<String>} args.linkedIds Ids of the other views to which this could be locked via zoom/pan.
1313
* @param {Boolean} args.panLock Whether or not we lock pan.
1414
* @param {Boolean} args.zoomLock Whether or not we lock zoom.
15-
* @param {Array} args.viewportOutlineColor Outline color of the border (default [255, 255, 255])
16-
* @param {number} args.viewportOutlineWidth Default outline width (default 10)
15+
* @param {Array=} args.viewportOutlineColor Outline color of the border (default [255, 255, 255])
16+
* @param {number=} args.viewportOutlineWidth Default outline width (default 10)
17+
* @param {number=} args.x X (top-left) location on the screen for the current view
18+
* @param {number=} args.y Y (top-left) location on the screen for the current view
19+
* @param {number} args.height Width of the view.
20+
* @param {number} args.width Height of the view.
21+
* @param {string} args.id id of the View
1722
* */
1823
export default class SideBySideView extends VivView {
1924
constructor({
2025
id,
21-
x,
22-
y,
26+
x = 0,
27+
y = 0,
2328
height,
2429
width,
2530
linkedIds = [],

src/views/VivView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { OrthographicView } from '@deck.gl/core';
77
* @param {Object} args.height Width of the view.
88
* @param {Object} args.width Height of the view.
99
* @param {string} args.id Id for the current view
10-
* @param {number} args.x X (top-left) location on the screen for the current view
11-
* @param {number} args.y Y (top-left) location on the screen for the current view
10+
* @param {number=} args.x X (top-left) location on the screen for the current view
11+
* @param {number=} args.y Y (top-left) location on the screen for the current view
1212
*/
1313
export default class VivView {
1414
constructor({ id, x = 0, y = 0, height, width }) {

0 commit comments

Comments
 (0)