Skip to content

Commit

Permalink
Fix type/docs for VivViewer and VivView (and upstream users)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilan-gold committed Apr 1, 2021
1 parent b2e1371 commit 7703fcf
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 21 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

### Changed

- Fix `VivViewer` and `VivView` types.

## 0.9.4

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/viewers/PictureInPictureViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { GLOBAL_SLIDER_DIMENSION_FIELDS } from '../constants';
* @param {import('./VivViewer').ViewStateChange} [props.onViewStateChange] Callback that returns the deck.gl view state (https://deck.gl/docs/api-reference/core/deck#onviewstatechange).
* @param {import('./VivViewer').Hover} [props.onHover] Callback that returns the picking info and the event (https://deck.gl/docs/api-reference/core/layer#onhover
* https://deck.gl/docs/developer-guide/interactivity#the-picking-info-object)
* @param {Array} [props.transitionFields] A string array indicating which fields require a transition: Default: ['t', 'z'].
* @param {Array} [props.transitionFields] A string array indicating which fields require a transition when making a new selection: Default: ['t', 'z'].
*/

const PictureInPictureViewer = props => {
Expand Down
1 change: 1 addition & 0 deletions src/viewers/SideBySideViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { GLOBAL_SLIDER_DIMENSION_FIELDS } from '../constants';
* @param {number} [props.lensSelection] Numeric index of the channel to be focused on by the lens (default 0).
* @param {Array} [props.lensBorderColor] RGB color of the border of the lens (default [255, 255, 255]).
* @param {number} [props.lensBorderRadius] Percentage of the radius of the lens for a border (default 0.02).
* @param {number} [props.lensRadius] Pixel radius of the lens (default: 100).
* @param {Array} [props.transparentColor] An RGB (0-255 range) color to be considered "transparent" if provided.
* In other words, any fragment shader output equal transparentColor (before applying opacity) will have opacity 0.
* 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.
Expand Down
39 changes: 26 additions & 13 deletions src/viewers/VivViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,38 @@ const areViewStatesEqual = (viewState, otherViewState) => {
/**
* @callback ViewStateChange
* @param {Object} event
* @ignore
*/

/**
* @callback Hover
* @param {Object} info
* @param {Object} event
* @ignore
*/

/**
* This component handles rendering the various views within the DeckGL contenxt.
* @param {Object} props
* @param {Array} props.layerProps Props for the layers in each view.
* @param {Array} props.randomize Whether or not to randomize which view goes first (for dynamic rendering).
* @param {VivView} props.views Various VivViews to render.
* @param {Array} props.viewStates List of objects like [{ target: [x, y, 0], zoom: -zoom, id: 'left' }, { target: [x, y, 0], zoom: -zoom, id: 'right' }]
* @param {ViewStateChange} [props.onViewStateChange] Callback that returns the deck.gl view state (https://deck.gl/docs/api-reference/core/deck#onviewstatechange).
* @param {Hover} [props.onHover] Callback that returns the picking info and the event (https://deck.gl/docs/api-reference/core/layer#onhover
* https://deck.gl/docs/developer-guide/interactivity#the-picking-info-object)
*/
/**
* @typedef LayerProps
* @type {object}
* @property {Array} layerProps Props for the layers in each view.
* @property {boolean} [randomize] Whether or not to randomize which view goes first (for dynamic rendering of multiple linked views).
* @property {Array.<import('../views').VivView>} views Various `VivView`s to render.
* @property {Array.<object>} viewStates List of objects like [{ target: [x, y, 0], zoom: -zoom, id: 'left' }, { target: [x, y, 0], zoom: -zoom, id: 'right' }]
* @property {ViewStateChange} [onViewStateChange] Callback that returns the deck.gl view state (https://deck.gl/docs/api-reference/core/deck#onviewstatechange).
* @property {Hover} [onHover] Callback that returns the picking info and the event (https://deck.gl/docs/api-reference/core/layer#onhover
* https://deck.gl/docs/developer-guide/interactivity#the-picking-info-object)
* @property {Object} [hoverHooks] Object including utility hooks - an object with key handleValue like { handleValue: (valueArray) => {}, handleCoordinate: (coordinate) => {} } where valueArray
* 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.
*/


export default class VivViewer extends PureComponent {

/**
* This component handles rendering the various views within the DeckGL contenxt.
* @param {LayerProps} props
*/

constructor(props) {
super(props);
this.state = {
Expand All @@ -56,8 +68,9 @@ export default class VivViewer extends PureComponent {
* This prevents only the `draw` call of a layer from firing,
* but not other layer lifecycle methods. Nonetheless, it is
* still useful.
* @param {Layer} layer Layer being updated.
* @param {Viewport} viewport Viewport being updated.
* @param {object} args
* @param {object} args.layer Layer being updated.
* @param {object} args.viewport Viewport being updated.
* @returns {boolean} Whether or not this layer should be drawn in this viewport.
*/
// eslint-disable-next-line class-methods-use-this
Expand Down
15 changes: 10 additions & 5 deletions src/views/SideBySideView.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,22 @@ import { getImageLayers, getVivId, makeBoundingBox } from './utils';
* It is linked with its other views as controlled by `linkedIds`, `zoomLock`, and `panLock` parameters.
* It takes the same arguments for its constructor as its base class VivView plus the following:
* @param {Object} args
* @param {Array} args.linkedIds Ids of the other views to which this could be locked via zoom/pan.
* @param {Array<String>} args.linkedIds Ids of the other views to which this could be locked via zoom/pan.
* @param {Boolean} args.panLock Whether or not we lock pan.
* @param {Boolean} args.zoomLock Whether or not we lock zoom.
* @param {Array} args.viewportOutlineColor Outline color of the border (default [255, 255, 255])
* @param {number} args.viewportOutlineWidth Default outline width (default 10)
* @param {Array=} args.viewportOutlineColor Outline color of the border (default [255, 255, 255])
* @param {number=} args.viewportOutlineWidth Default outline width (default 10)
* @param {number=} args.x X (top-left) location on the screen for the current view
* @param {number=} args.y Y (top-left) location on the screen for the current view
* @param {number} args.height Width of the view.
* @param {number} args.width Height of the view.
* @param {string} args.id id of the View
* */
export default class SideBySideView extends VivView {
constructor({
id,
x,
y,
x = 0,
y = 0,
height,
width,
linkedIds = [],
Expand Down
4 changes: 2 additions & 2 deletions src/views/VivView.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { OrthographicView } from '@deck.gl/core';
* @param {Object} args.height Width of the view.
* @param {Object} args.width Height of the view.
* @param {string} args.id Id for the current view
* @param {number} args.x X (top-left) location on the screen for the current view
* @param {number} args.y Y (top-left) location on the screen for the current view
* @param {number=} args.x X (top-left) location on the screen for the current view
* @param {number=} args.y Y (top-left) location on the screen for the current view
*/
export default class VivView {
constructor({ id, x = 0, y = 0, height, width }) {
Expand Down

0 comments on commit 7703fcf

Please sign in to comment.