MCPcopy
hub / github.com/visgl/deck.gl / setProps

Function setProps

modules/core/src/controllers/controller.ts:295–354  ·  view source on GitHub ↗

* Extract interactivity options

(props: ControllerProps)

Source from the content-addressed store, hash-verified

293 * Extract interactivity options
294 */
295 setProps(props: ControllerProps) {
296 if (props.dragMode) {
297 this.dragMode = props.dragMode;
298 }
299 const oldProps = this.props;
300 this.props = props;
301
302 if (!('transitionInterpolator' in props)) {
303 // Add default transition interpolator
304 props.transitionInterpolator = this._getTransitionProps().transitionInterpolator;
305 }
306
307 this.transitionManager.processViewStateChange(props);
308
309 const {inertia} = props;
310 this.inertia = Number.isFinite(inertia) ? (inertia as number) : (inertia === true ? DEFAULT_INERTIA : 0);
311
312 // TODO - make sure these are not reset on every setProps
313 const {
314 scrollZoom = true,
315 dragPan = true,
316 dragRotate = true,
317 doubleClickZoom = true,
318 touchZoom = true,
319 touchRotate = false,
320 keyboard = true
321 } = props;
322
323 // Register/unregister events
324 const isInteractive = Boolean(this.onViewStateChange);
325 this.toggleEvents(EVENT_TYPES.WHEEL, isInteractive && scrollZoom);
326 // We always need the pan events to set the correct isDragging state, even if dragPan & dragRotate are both false
327 this.toggleEvents(EVENT_TYPES.PAN, isInteractive);
328 this.toggleEvents(EVENT_TYPES.PINCH, isInteractive && (touchZoom || touchRotate));
329 this.toggleEvents(EVENT_TYPES.MULTI_PAN, isInteractive && touchRotate);
330 this.toggleEvents(EVENT_TYPES.DOUBLE_CLICK, isInteractive && doubleClickZoom);
331 this.toggleEvents(EVENT_TYPES.KEYBOARD, isInteractive && keyboard);
332
333 // Interaction toggles
334 this.scrollZoom = scrollZoom;
335 this.dragPan = dragPan;
336 this.dragRotate = dragRotate;
337 this.doubleClickZoom = doubleClickZoom;
338 this.touchZoom = touchZoom;
339 this.touchRotate = touchRotate;
340 this.keyboard = keyboard;
341
342 // Normalize view state if maxBounds is defined
343 const dimensionChanged = !oldProps || oldProps.height !== props.height || oldProps.width !== props.width || oldProps.maxBounds !== props.maxBounds;
344 if (dimensionChanged && props.maxBounds) {
345 // Dimensions changed, try re-normalize the props
346 const controllerState = new this.ControllerState({...props, makeViewport: this.makeViewport});
347 const normalizedProps = controllerState.getViewportProps();
348 const changed = Object.keys(normalizedProps).some(key => !deepEqual(normalizedProps[key], props[key], 1));
349 if (changed) {
350 // some props are updated after normalization
351 this.updateViewport(controllerState);
352 }

Callers

nothing calls this directly

Calls 4

deepEqualFunction · 0.90
getViewportPropsMethod · 0.80
updateViewportMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…