@noriginmedia/react-spatial-navigation
Advanced tools
Comparing version 2.12.8 to 2.12.9
@@ -7,2 +7,6 @@ # Changelog | ||
## [2.12.9] | ||
### Changed | ||
- performance optimization: updateLayout is only called for components affected by navigation | ||
## [2.12.8] | ||
@@ -9,0 +13,0 @@ ### Added |
@@ -650,2 +650,4 @@ 'use strict'; | ||
value: function smartNavigate(direction, fromParentFocusKey, details) { | ||
var _this4 = this; | ||
this.log('smartNavigate', 'direction', direction); | ||
@@ -656,3 +658,5 @@ this.log('smartNavigate', 'fromParentFocusKey', fromParentFocusKey); | ||
if (!this.nativeMode && !fromParentFocusKey) { | ||
this.updateAllLayouts(); | ||
(0, _forOwn2.default)(this.focusableComponents, function (component) { | ||
component.layoutUpdated = false; | ||
}); | ||
} | ||
@@ -665,2 +669,3 @@ | ||
if (currentComponent) { | ||
this.updateLayout(currentComponent.focusKey); | ||
var parentFocusKey = currentComponent.parentFocusKey, | ||
@@ -681,2 +686,3 @@ focusKey = currentComponent.focusKey, | ||
if (component.parentFocusKey === parentFocusKey && component.focusable) { | ||
_this4.updateLayout(component.focusKey); | ||
var siblingCutoffCoordinate = SpatialNavigation.getCutoffCoordinate(isVerticalDirection, isIncrementalDirection, true, component.layout); | ||
@@ -756,2 +762,4 @@ | ||
value: function getNextFocusKey(targetFocusKey) { | ||
var _this5 = this; | ||
var targetComponent = this.focusableComponents[targetFocusKey]; | ||
@@ -799,2 +807,5 @@ | ||
*/ | ||
children.forEach(function (component) { | ||
return _this5.updateLayout(component.focusKey); | ||
}); | ||
@@ -867,3 +878,4 @@ var _getChildClosestToOri = getChildClosestToOrigin(children), | ||
node: node | ||
} | ||
}, | ||
layoutUpdated: false | ||
}; | ||
@@ -923,2 +935,4 @@ | ||
if (component) { | ||
this.updateLayout(component.focusKey); | ||
return component.layout; | ||
@@ -954,3 +968,3 @@ } | ||
value: function updateParentsHasFocusedChild(focusKey, details) { | ||
var _this4 = this; | ||
var _this6 = this; | ||
@@ -985,13 +999,13 @@ var parents = []; | ||
(0, _forEach2.default)(parentsToRemoveFlag, function (parentFocusKey) { | ||
var parentComponent = _this4.focusableComponents[parentFocusKey]; | ||
var parentComponent = _this6.focusableComponents[parentFocusKey]; | ||
parentComponent && parentComponent.trackChildren && parentComponent.onUpdateHasFocusedChild(false); | ||
_this4.onIntermediateNodeBecameBlurred(parentFocusKey, details); | ||
_this6.onIntermediateNodeBecameBlurred(parentFocusKey, details); | ||
}); | ||
(0, _forEach2.default)(parentsToAddFlag, function (parentFocusKey) { | ||
var parentComponent = _this4.focusableComponents[parentFocusKey]; | ||
var parentComponent = _this6.focusableComponents[parentFocusKey]; | ||
parentComponent && parentComponent.trackChildren && parentComponent.onUpdateHasFocusedChild(true); | ||
_this4.onIntermediateNodeBecameFocused(parentFocusKey, details); | ||
_this6.onIntermediateNodeBecameFocused(parentFocusKey, details); | ||
}); | ||
@@ -1094,3 +1108,3 @@ | ||
value: function updateAllLayouts() { | ||
var _this5 = this; | ||
var _this7 = this; | ||
@@ -1102,3 +1116,3 @@ if (this.nativeMode) { | ||
(0, _forOwn2.default)(this.focusableComponents, function (component, focusKey) { | ||
_this5.updateLayout(focusKey); | ||
_this7.updateLayout(focusKey); | ||
}); | ||
@@ -1111,3 +1125,3 @@ } | ||
if (!component || this.nativeMode) { | ||
if (!component || this.nativeMode || component.layoutUpdated) { | ||
return; | ||
@@ -1114,0 +1128,0 @@ } |
{ | ||
"name": "@noriginmedia/react-spatial-navigation", | ||
"version": "2.12.8", | ||
"version": "2.12.9", | ||
"description": "HOC-based Spatial Navigation (key navigation) solution for React", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
110981
1948
1