Created
October 19, 2016 21:54
-
-
Save mattpodwysocki/ac8f05969f905327747b47285f911e6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Insert a child at the given index. | |
/// </summary> | |
/// <param name="child">The child.</param> | |
/// <param name="index">The index.</param> | |
public void AddChildAt(CSSNode child, int index) | |
{ | |
Insert(index, child); | |
MarkUpdated(); | |
var node = (ReactShadowNode)child; | |
if (!IsLeafNode) | |
{ | |
var increase = node.IsLayoutOnly ? node._totalNativeChildren : 1; | |
_totalNativeChildren += increase; | |
UpdateNativeChildrenCountInParent(increase); | |
} | |
} | |
/// <summary> | |
/// Removes the child at the given index. | |
/// </summary> | |
/// <param name="index">The index.</param> | |
public ReactShadowNode RemoveChildAt(int index) | |
{ | |
var removed = RemoveAndReturnChildAt(index); | |
MarkUpdated(); | |
if (!IsLeafNode) | |
{ | |
var decrease = removed.IsLayoutOnly ? removed._totalNativeChildren : 1; | |
_totalNativeChildren -= decrease; | |
UpdateNativeChildrenCountInParent(decrease * -1); | |
} | |
return removed; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment