MCPcopy Create free account
hub / github.com/visgl/react-map-gl / _updateViewState

Method _updateViewState

modules/react-mapbox/src/mapbox/mapbox.ts:446–463  ·  view source on GitHub ↗
(nextProps: MapboxProps, triggerEvents: boolean)

Source from the content-addressed store, hash-verified

444 @returns {bool} true if anything is changed
445 */
446 _updateViewState(nextProps: MapboxProps, triggerEvents: boolean): boolean {
447 const viewState: Partial<ViewState> = nextProps.viewState || nextProps;
448 const tr = this._proxyTransform;
449 const {zoom, pitch, bearing} = tr;
450 const changed = compareViewStateWithTransform(this._proxyTransform, viewState);
451 tr.$reactViewState = viewState;
452
453 if (changed && triggerEvents) {
454 const deferredEvents = this._deferredEvents;
455 // Delay DOM control updates to the next render cycle
456 deferredEvents.move = true;
457 deferredEvents.zoom ||= zoom !== tr.zoom;
458 deferredEvents.rotate ||= bearing !== tr.bearing;
459 deferredEvents.pitch ||= pitch !== tr.pitch;
460 }
461
462 return changed;
463 }
464
465 /* Update camera constraints and projection settings to match props
466 @param {object} nextProps

Callers 2

setPropsMethod · 0.95
reuseMethod · 0.45

Calls 1

Tested by

no test coverage detected