MCPcopy Create free account
hub / github.com/microsoft/SandDance / wrapper

Function wrapper

packages/vega-deck.gl/src/deck.gl-classes/deckgl.ts:68–123  ·  view source on GitHub ↗
(props: DeckProps)

Source from the content-addressed store, hash-verified

66 //This allows us to retrieve Deck from either UMD or ES6 consumers of this class.
67
68 function wrapper(props: DeckProps) {
69
70 /**
71 * @params container (Element) - DOM element to add deck.gl canvas to
72 * @params controller (Object) - Controller class. Leave empty for auto detection
73 */
74 class DeckGLInternal extends base.deck.Deck {
75 private _updateViewState;
76 private onViewStateChange;
77 public interactiveState: InteractiveStateVegaDeckGL;
78
79 constructor(props: DeckGLInternalProps) {
80 if (typeof document === 'undefined') {
81 // Not browser
82 throw Error('Deck can only be used in the browser');
83 }
84
85 const { deckCanvas } = createCanvas(props);
86
87 const viewState = props.initialViewState || props.viewState || {};
88
89 super(
90 Object.assign({}, props, {
91 width: '100%',
92 height: '100%',
93 canvas: deckCanvas,
94 controller: OrbitControllerClass,
95 initialViewState: viewState,
96 }),
97 );
98
99 // Callback for the controller
100 this._updateViewState = params => {
101 if (this.onViewStateChange) {
102 this.onViewStateChange(params);
103 }
104 };
105 }
106
107 setProps(props) {
108 // this._updateViewState must be bound to `this`
109 // but we don't have access to the current instance before calling super().
110 if ('onViewStateChange' in props && this._updateViewState) {
111 // This is called at least once at _onRendererInitialized
112 this.onViewStateChange = props.onViewStateChange;
113 props.onViewStateChange = this._updateViewState;
114 }
115
116 super.setProps(props);
117 }
118 }
119
120 const instance = new DeckGLInternal(props) as Deck;
121
122 return instance;
123 }
124
125 return {

Callers 1

create_cmdclassFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected