bm-core-ui 2.10.4 → 2.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4922,7 +4922,7 @@ BMCollectionView.prototype = BMExtend(BM_COLLECTION_VIEW_USE_BMVIEW_SUBCLASS ? O
4922
4922
  targetOffset.x += self._offscreenBufferSize;
4923
4923
  targetOffset.y += self._offscreenBufferSize;
4924
4924
 
4925
- let controller = BMAnimationContextGetCurrent().controllerForObject(self, {node: self._contentWrapper[0]});
4925
+ let controller = BMAnimationContextGetCurrent().controllerForObject(self._contentWrapper[0], {node: self._contentWrapper[0]});
4926
4926
  if (self.iScroll) {
4927
4927
  //controller.registerCustomProperty('scrollOffset', {withHandler: fraction => {
4928
4928
  //var offsetX = currentOffset.x + fraction * (targetOffset.x - currentOffset.x);
@@ -5625,7 +5625,7 @@ BMCollectionView.prototype = BMExtend(BM_COLLECTION_VIEW_USE_BMVIEW_SUBCLASS ? O
5625
5625
  targetOffset.x += self._offscreenBufferSize;
5626
5626
  targetOffset.y += self._offscreenBufferSize;
5627
5627
 
5628
- let controller = BMAnimationContextGetCurrent().controllerForObject(self, {node: self._container[0]});
5628
+ let controller = BMAnimationContextGetCurrent().controllerForObject(self._container[0], {node: self._container[0]});
5629
5629
  if (self.iScroll) {
5630
5630
  controller.registerCustomProperty('scrollOffset', {withHandler: fraction => {
5631
5631
  var offsetX = currentOffset.x + fraction * (targetOffset.x - currentOffset.x);
@@ -1708,6 +1708,15 @@ BMCollectionViewFlowLayout.prototype = BMExtend(Object.create(BMCollectionViewLa
1708
1708
 
1709
1709
  let iterator = this._prepareLayoutWithScrollbarOffsetGenerator(useOffset);
1710
1710
 
1711
+ // Determine if the result is a complete layout and disable iterators
1712
+ // A complete layout has cached attributes for all sections and rows
1713
+ const sectionCount = this.collectionView.numberOfSections();
1714
+ const rowCount = sectionCount ? this.collectionView.numberOfObjectsInSectionAtIndex(sectionCount - 1) : 0;
1715
+ let isCompleteLayout = !this._expectedCellSize || !sectionCount || (
1716
+ this.cachedLayout?.sections?.length == sectionCount &&
1717
+ this.cachedLayout?.sections[sectionCount - 1].rows?.length == rowCount
1718
+ );
1719
+
1711
1720
  // When not using automatic cell sizes, the generator function will run to finish from the first
1712
1721
  // invocation of `next`.
1713
1722
  // When using automatic cell sizes, the first iteration will only build a rough outline of the expected layout
@@ -1717,6 +1726,28 @@ BMCollectionViewFlowLayout.prototype = BMExtend(Object.create(BMCollectionViewLa
1717
1726
  this._layoutIterator = iterator;
1718
1727
  this.cachedLayout.iterator = iterator;
1719
1728
  }
1729
+ else if (!this.cachedLayout.iterator) {
1730
+ // If the iterator is finished this means that either:
1731
+ // - the layout is actually complete which can be verified by checking the cached attribute counts
1732
+ // - the layout process had to be restarted with scrollbar offsets, in which case the cached layout
1733
+ // will have been processed to have an iterator attached to it by the time the first iterator
1734
+ // step returns, in this case this branch should not execute
1735
+
1736
+ if (isCompleteLayout) {
1737
+ // Of the result is done, update the resolved index path and size accordingly
1738
+ this.cachedLayout.resolvedIndexPath = BMIndexPathMakeWithRow(rowCount - 1, {inSectionAtIndex: sectionCount - 1});
1739
+
1740
+ const contentSize = this.contentSize();
1741
+ this.cachedLayout.resolvedWidth = contentSize.width;
1742
+ this.cachedLayout.resolvedHeight = contentSize.height;
1743
+ }
1744
+
1745
+ // TODO: The rest of the code must be updated to handle complete layout caches where there is no need to
1746
+ if (!this._layoutIterator) {
1747
+ this._layoutIterator = { next() {} };
1748
+ }
1749
+ this.cachedLayout.iterator = { next() {} };
1750
+ }
1720
1751
  },
1721
1752
 
1722
1753
  /**