@solidtv/solid 1.6.5 → 1.7.0

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.
Files changed (60) hide show
  1. package/dist/src/core/dom-renderer/domRenderer.d.ts +7 -7
  2. package/dist/src/core/dom-renderer/domRenderer.js +1 -9
  3. package/dist/src/core/dom-renderer/domRenderer.js.map +1 -1
  4. package/dist/src/core/dom-renderer/domRendererTypes.d.ts +4 -4
  5. package/dist/src/core/elementNode.d.ts +23 -5
  6. package/dist/src/core/elementNode.js +194 -45
  7. package/dist/src/core/elementNode.js.map +1 -1
  8. package/dist/src/core/flex.js +2 -1
  9. package/dist/src/core/flex.js.map +1 -1
  10. package/dist/src/core/focusManager.js +144 -99
  11. package/dist/src/core/focusManager.js.map +1 -1
  12. package/dist/src/core/index.d.ts +3 -0
  13. package/dist/src/core/index.js +2 -0
  14. package/dist/src/core/index.js.map +1 -1
  15. package/dist/src/core/intrinsicTypes.d.ts +5 -2
  16. package/dist/src/core/lightningInit.d.ts +2 -2
  17. package/dist/src/core/lightningInit.js +71 -32
  18. package/dist/src/core/lightningInit.js.map +1 -1
  19. package/dist/src/core/nodeTypes.d.ts +1 -1
  20. package/dist/src/core/nodeTypes.js +2 -3
  21. package/dist/src/core/nodeTypes.js.map +1 -1
  22. package/dist/src/core/shaders.d.ts +1 -1
  23. package/dist/src/core/states.js +20 -4
  24. package/dist/src/core/states.js.map +1 -1
  25. package/dist/src/primitives/FPSCounter.jsx +3 -3
  26. package/dist/src/primitives/FPSCounter.jsx.map +1 -1
  27. package/dist/src/primitives/Image.jsx +2 -10
  28. package/dist/src/primitives/Image.jsx.map +1 -1
  29. package/dist/src/primitives/Lazy.jsx +7 -1
  30. package/dist/src/primitives/Lazy.jsx.map +1 -1
  31. package/dist/src/primitives/Virtual.d.ts +4 -0
  32. package/dist/src/primitives/Virtual.jsx +192 -106
  33. package/dist/src/primitives/Virtual.jsx.map +1 -1
  34. package/dist/src/primitives/VirtualGrid.jsx +87 -18
  35. package/dist/src/primitives/VirtualGrid.jsx.map +1 -1
  36. package/dist/src/primitives/utils/handleNavigation.js +12 -5
  37. package/dist/src/primitives/utils/handleNavigation.js.map +1 -1
  38. package/dist/src/primitives/utils/withScrolling.js +63 -57
  39. package/dist/src/primitives/utils/withScrolling.js.map +1 -1
  40. package/dist/src/render.d.ts +1 -1
  41. package/dist/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +12 -5
  43. package/src/core/dom-renderer/domRenderer.ts +4 -12
  44. package/src/core/dom-renderer/domRendererTypes.ts +4 -4
  45. package/src/core/elementNode.ts +219 -50
  46. package/src/core/flex.ts +2 -1
  47. package/src/core/focusManager.ts +173 -135
  48. package/src/core/index.ts +4 -0
  49. package/src/core/intrinsicTypes.ts +10 -2
  50. package/src/core/lightningInit.ts +85 -35
  51. package/src/core/nodeTypes.ts +6 -3
  52. package/src/core/shaders.ts +1 -1
  53. package/src/core/states.ts +19 -4
  54. package/src/primitives/FPSCounter.tsx +4 -4
  55. package/src/primitives/Image.tsx +2 -9
  56. package/src/primitives/Lazy.tsx +8 -1
  57. package/src/primitives/Virtual.tsx +211 -117
  58. package/src/primitives/VirtualGrid.tsx +98 -21
  59. package/src/primitives/utils/handleNavigation.ts +12 -5
  60. package/src/primitives/utils/withScrolling.ts +63 -62
@@ -52,15 +52,25 @@ export function VirtualGrid<T>(props: VirtualGridProps<T>): s.JSX.Element {
52
52
  return Math.min(items().length, rawEnd);
53
53
  });
54
54
 
55
- const [slice, setSlice] = s.createSignal(items().slice(start(), end()));
55
+ const [slice, setSliceSignal] = s.createSignal(items().slice(start(), end()));
56
+ // Set when the window's items change, cleared by the grid's next flex pass
57
+ // (onLayout): a window shift lays the grid out only if nothing else has.
58
+ let layoutPending = false;
59
+ function setSlice(window: T[]) {
60
+ layoutPending = true;
61
+ setSliceSignal(window);
62
+ }
56
63
 
57
64
  let viewRef!: lngp.NavigableElement;
58
65
 
59
66
  function onVerticalNav(dir: -1 | 1): lngp.KeyHandler {
60
67
  return function () {
61
68
  const perRow = itemsPerRow();
69
+ const count = items().length;
62
70
  const currentRowIndex = Math.floor(cursor() / perRow);
63
- const maxRows = Math.floor(items().length / perRow);
71
+ // B15: the last row's index. floor(length / perRow) was one row late
72
+ // when the length is a multiple of perRow.
73
+ const maxRows = Math.floor((count - 1) / perRow);
64
74
 
65
75
  if (
66
76
  currentRowIndex === 0 && dir === -1
@@ -69,19 +79,21 @@ export function VirtualGrid<T>(props: VirtualGridProps<T>): s.JSX.Element {
69
79
 
70
80
  const selected = this.selected || 0;
71
81
  const offset = dir * perRow;
72
- const newIndex = utils.clamp(selected + offset, 0, items().length - 1);
73
- const lastIdx = selected;
74
- this.selected = newIndex;
75
- const active = this.children[this.selected];
82
+ const newIndex = utils.clamp(selected + offset, 0, count - 1);
83
+ const active = this.children[newIndex];
76
84
 
85
+ // B15: `selected` changes only when there is a child to move to. It was
86
+ // written first, so a Down with nothing below left it past the mounted
87
+ // children and the next Up was lost.
77
88
  if (active instanceof lng.ElementNode) {
89
+ this.selected = newIndex;
78
90
  active.setFocus();
79
91
  chainedOnSelectedChanged.call(
80
92
  this as lngp.NavigableElement,
81
- this.selected,
93
+ newIndex,
82
94
  this as lngp.NavigableElement,
83
95
  active,
84
- lastIdx
96
+ selected
85
97
  );
86
98
  return true;
87
99
  }
@@ -91,9 +103,16 @@ export function VirtualGrid<T>(props: VirtualGridProps<T>): s.JSX.Element {
91
103
  const onUp = onVerticalNav(-1);
92
104
  const onDown = onVerticalNav(1);
93
105
 
106
+ // B15: set by applySelected for the call that applies an initial
107
+ // `selected`. The app gets lastIdx === idx there (as Row and Column report
108
+ // a mount selection); internally there is no previous selection, so the
109
+ // scroll to that row runs.
110
+ let forceRowScroll = false;
111
+
94
112
  const onSelectedChanged: lngp.OnSelectedChanged = function (_idx, elm, active, _lastIdx,) {
95
113
  let idx = _idx;
96
- let lastIdx = _lastIdx;
114
+ let lastIdx = forceRowScroll ? undefined : _lastIdx;
115
+ forceRowScroll = false;
97
116
  const perRow = itemsPerRow();
98
117
  const newRowIndex = Math.floor(idx / perRow);
99
118
  const prevRowIndex = Math.floor((lastIdx || 0) / perRow);
@@ -115,16 +134,51 @@ export function VirtualGrid<T>(props: VirtualGridProps<T>): s.JSX.Element {
115
134
  props.onEndReached?.();
116
135
  }
117
136
 
118
- queueMicrotask(() => {
119
- const prevRowY = this.y + active.y;
120
- this.updateLayout();
121
- this.lng.y = prevRowY - active.y;
122
- columnScroll(idx, elm, active, lastIdx);
123
- });
137
+ // `elm` is the grid (`this`): navigation calls it on itself.
138
+ shiftView = elm;
139
+ shiftActive = active;
140
+ shiftIdx = idx;
141
+ shiftLastIdx = lastIdx;
142
+ queueMicrotask(applyShift);
124
143
  };
125
144
 
145
+ // The scroll after a row change, run in a microtask once the new window is
146
+ // mounted. One function for every press (no closure per press): the press
147
+ // stores what it needs here.
148
+ let shiftView!: lngp.NavigableElement;
149
+ let shiftActive!: lng.ElementNode;
150
+ let shiftIdx = 0;
151
+ let shiftLastIdx: number | undefined;
152
+ function applyShift() {
153
+ const view = shiftView;
154
+ const active = shiftActive;
155
+ const prevRowY = view.y + active.y;
156
+ // One flex pass per window shift: lay out here only if the post-mutation
157
+ // layout has not already run since the window changed.
158
+ if (layoutPending) view.updateLayout();
159
+ view.lng.y = prevRowY - active.y;
160
+ columnScroll(shiftIdx, view, active, shiftLastIdx);
161
+ }
162
+
126
163
  const chainedOnSelectedChanged = lngp.chainFunctions(props.onSelectedChanged, onSelectedChanged)!;
127
164
 
165
+ // B15: an initial `selected` has not been applied (scrolled to) yet. It
166
+ // stays pending through runs that find no child (items still loading, or
167
+ // waiting for onEndReached) and is cleared by the run that applies it.
168
+ let initialSelectedPending = s.untrack(() => props.selected != null);
169
+
170
+ function applySelected(active: lng.ElementNode, lastSelected: number) {
171
+ const idx = viewRef.selected;
172
+ if (initialSelectedPending) {
173
+ initialSelectedPending = false;
174
+ forceRowScroll = true;
175
+ lastSelected = idx;
176
+ }
177
+ chainedOnSelectedChanged.call(viewRef, idx, viewRef, active, lastSelected);
178
+ // Not consumed when the app's handler returned true and stopped the chain.
179
+ forceRowScroll = false;
180
+ }
181
+
128
182
  let cachedSelected: number | undefined;
129
183
  const updateSelected = ([selected, _items]: [number?, any?]) => {
130
184
  if (!viewRef || selected == null) return;
@@ -150,20 +204,20 @@ export function VirtualGrid<T>(props: VirtualGridProps<T>): s.JSX.Element {
150
204
  // force focus as scrollToIndex is manually called
151
205
  active.setFocus();
152
206
  }
153
- chainedOnSelectedChanged.call(viewRef, viewRef.selected, viewRef, active, lastSelected);
207
+ applySelected(active, lastSelected);
154
208
  } else {
155
209
  setCursor(selected);
156
210
  setSlice(items().slice(start(), end()));
157
211
 
158
212
  queueMicrotask(() => {
159
- viewRef.updateLayout();
213
+ if (layoutPending) viewRef.updateLayout();
160
214
  active = viewRef.children.find(x => x.item === item);
161
215
  if (active instanceof lng.ElementNode) {
162
216
  viewRef.selected = viewRef.children.indexOf(active);
163
217
  if (lng.hasFocus(viewRef)) {
164
218
  active.setFocus();
165
219
  }
166
- chainedOnSelectedChanged.call(viewRef, viewRef.selected, viewRef, active, lastSelected);
220
+ applySelected(active, lastSelected);
167
221
  }
168
222
  });
169
223
  }
@@ -202,13 +256,28 @@ export function VirtualGrid<T>(props: VirtualGridProps<T>): s.JSX.Element {
202
256
  );
203
257
 
204
258
 
205
- return (
259
+ // Clears layoutPending: the grid's flex pass has run since the window
260
+ // changed. The app's onLayout still runs, read when called.
261
+ function onLayout(this: lng.ElementNode, target: lng.ElementNode) {
262
+ layoutPending = false;
263
+ return props.onLayout?.call(this, target);
264
+ }
265
+
266
+ // B15: `selected` on the node is a child index into the window, set once
267
+ // here and then by navigation and the selected effect. Passing the data
268
+ // index (`props.selected`) made the first forwardFocus pick the wrong child,
269
+ // and its reactive rewrite hid the previous child index from updateSelected.
270
+ const initialSelected = s.untrack(() =>
271
+ Math.max(0, (props.selected || 0) - start()),
272
+ );
273
+
274
+ const view = (
206
275
  <view
207
276
  {...props}
208
277
  scroll={props.scroll || 'always'}
209
278
  ref={lngp.chainRefs(el => { viewRef = el as lngp.NavigableElement; }, props.ref)}
210
- selected={props.selected || 0}
211
- cursor={cursor()}
279
+ selected={/* @once */ initialSelected}
280
+ onLayout={/* @once */ onLayout}
212
281
  onLeft={/* @once */ lngp.chainFunctions(props.onLeft, lngp.navigableHandleNavigation)}
213
282
  onRight={/* @once */ lngp.chainFunctions(props.onRight, lngp.navigableHandleNavigation)}
214
283
  onUp={/* @once */ lngp.chainFunctions(props.onUp, onUp)}
@@ -222,4 +291,12 @@ export function VirtualGrid<T>(props: VirtualGridProps<T>): s.JSX.Element {
222
291
  <List each={slice()}>{props.children}</List>
223
292
  </view>
224
293
  );
294
+
295
+ // `cursor` has an effect of its own: in the spread above, a cursor change
296
+ // (every press) re-ran every prop of the spread.
297
+ s.createRenderEffect(() => {
298
+ viewRef.cursor = cursor();
299
+ });
300
+
301
+ return view;
225
302
  }
@@ -39,13 +39,20 @@ function findFirstFocusableChildIdx(
39
39
  from = 0,
40
40
  delta = 1,
41
41
  ): number {
42
- for (let i = from; ; i += delta) {
43
- if (!idxInArray(i, el.children)) {
44
- if (el.wrap) {
45
- i = (i + el.children.length) % el.children.length;
42
+ const children = el.children;
43
+ const length = children.length;
44
+ const wrap = el.wrap;
45
+ // Visits each child at most once, so with wrap and every child skipFocus
46
+ // the search ends (B1). With no children there is nothing to find: -1.
47
+ let i = from;
48
+ for (let n = 0; n < length; n++, i += delta) {
49
+ if (!(i >= 0 && i < length)) {
50
+ if (wrap) {
51
+ i = ((i % length) + length) % length;
46
52
  } else break;
47
53
  }
48
- if (!el.children[i]?.skipFocus) {
54
+ const child = children[i];
55
+ if (child !== undefined && !child.skipFocus) {
49
56
  return i;
50
57
  }
51
58
  }
@@ -66,92 +66,97 @@ export function withScrolling(isRow: boolean): Scroller {
66
66
  componentRef = selected as ScrollableElement;
67
67
  selected = componentRef.selected || 0;
68
68
  }
69
- if (
70
- !componentRef ||
71
- componentRef.scroll === 'none' ||
72
- selected === lastSelected ||
73
- !componentRef.children.length
74
- )
69
+ if (!componentRef) return;
70
+ // Each input is read once into a local: on renderer v2 every node prop
71
+ // read goes through an accessor.
72
+ const scrollProp = componentRef.scroll;
73
+ const children = componentRef.children;
74
+ const childCount = children.length;
75
+ if (scrollProp === 'none' || selected === lastSelected || !childCount)
75
76
  return;
76
77
 
77
- if (componentRef._initialPosition === undefined) {
78
- componentRef._initialPosition = componentRef[axis];
78
+ const position = componentRef[axis];
79
+ let initialPosition = componentRef._initialPosition;
80
+ if (initialPosition === undefined) {
81
+ initialPosition = position;
82
+ componentRef._initialPosition = position;
79
83
  }
80
84
 
81
85
  const lng = componentRef.lng as unknown as INode;
82
- const screenSize = isRow ? lng.stage.root.w : lng.stage.root.h;
86
+ const root = lng.stage.root;
87
+ const screenSize = isRow ? root.w : root.h;
83
88
  // Determine if movement is incremental or decremental
84
89
  const isIncrementing =
85
90
  lastSelected === undefined || lastSelected - 1 !== selected;
86
91
 
87
- if (componentRef._screenOffset === undefined) {
88
- if (componentRef.parent!.clipping) {
89
- const p = componentRef.parent!;
90
- componentRef.endOffset =
91
- componentRef.endOffset ??
92
+ let offset = componentRef.offset;
93
+ let endOffset = componentRef.endOffset;
94
+ let screenOffset = componentRef._screenOffset;
95
+ if (screenOffset === undefined) {
96
+ const p = componentRef.parent!;
97
+ if (p.clipping) {
98
+ endOffset =
99
+ endOffset ??
92
100
  screenSize - ((isRow ? p.absX : p.absY) || 0) - p[dimension];
101
+ componentRef.endOffset = endOffset;
93
102
  }
94
103
 
95
- componentRef._screenOffset =
96
- componentRef.offset ??
97
- (isRow ? lng.absX : lng.absY) - componentRef[axis];
104
+ screenOffset = offset ?? (isRow ? lng.absX : lng.absY) - position;
105
+ componentRef._screenOffset = screenOffset;
98
106
  }
99
107
 
100
- const screenOffset = componentRef._screenOffset;
101
108
  const gap = componentRef.gap || 0;
109
+ const scrollIndex = componentRef.scrollIndex;
102
110
  // when creating we set scroll to always so we setup the right location for selected and scrollIndex
103
111
  const scroll =
104
- componentRef.scroll ||
112
+ scrollProp ||
105
113
  (lastSelected === undefined
106
- ? componentRef.scrollIndex
114
+ ? scrollIndex
107
115
  ? 'center'
108
116
  : 'always'
109
117
  : 'auto');
110
118
 
111
119
  // Allows manual position control
112
- const targetPosition = componentRef._targetPosition ?? componentRef[axis];
120
+ const targetPosition = componentRef._targetPosition ?? position;
113
121
  const rootPosition = isIncrementing
114
- ? Math.min(targetPosition, componentRef[axis])
115
- : Math.max(targetPosition, componentRef[axis]);
116
- componentRef.offset = componentRef.offset ?? rootPosition;
117
- const offset = componentRef.offset;
118
- selectedElement = selectedElement || componentRef.children[selected];
122
+ ? Math.min(targetPosition, position)
123
+ : Math.max(targetPosition, position);
124
+ offset = offset ?? rootPosition;
125
+ componentRef.offset = offset;
126
+ const selectedEl = selectedElement || children[selected];
119
127
 
120
- if (!selectedElement) {
128
+ if (!selectedEl) {
121
129
  return;
122
130
  }
123
- const selectedPosition = selectedElement[axis] ?? 0;
124
- const selectedSize = selectedElement[dimension] ?? 0;
131
+ const selectedPosition = selectedEl[axis] ?? 0;
132
+ const selectedSize = selectedEl[dimension] ?? 0;
133
+ // `$focus`, not `style.focus`: the focus state's styles live on the node
134
+ // under the state key, and the `style` getter allocates when unset.
125
135
  const selectedScale =
126
- selectedElement.scale ??
127
- (selectedElement.style?.focus as Styles)?.scale ??
128
- 1;
136
+ selectedEl.scale ?? (selectedEl.$focus as Styles | undefined)?.scale ?? 1;
129
137
  const selectedSizeScaled = selectedSize * selectedScale;
130
138
  const containerSize = componentRef[dimension] ?? 0;
131
139
  const maxOffset = Math.min(
132
- screenSize -
133
- containerSize -
134
- screenOffset -
135
- (componentRef.endOffset ?? 2 * gap),
140
+ screenSize - containerSize - screenOffset - (endOffset ?? 2 * gap),
136
141
  offset,
137
142
  );
138
143
 
139
144
  // Determine the next element based on whether incrementing or decrementing
140
145
  const nextIndex = isIncrementing ? selected + 1 : selected - 1;
141
- const nextElement = componentRef.children[nextIndex] || null;
146
+ const nextElement = children[nextIndex] || null;
147
+ const scrollStopLast = componentRef.scrollStopLast;
142
148
 
143
149
  // Default nextPosition to align with the selected position and offset
144
150
  let nextPosition = rootPosition;
145
151
 
146
152
  // Update nextPosition based on scroll type and specific conditions
147
- if (selectedElement.centerScroll) {
153
+ if (selectedEl.centerScroll) {
148
154
  nextPosition = -selectedPosition + (screenSize - selectedSizeScaled) / 2;
149
155
  } else if (scroll === 'always') {
150
156
  nextPosition = -selectedPosition + offset;
151
157
  } else if (scroll === 'bounded') {
152
- const totalItems = componentRef.children.length;
153
158
  const upCount = componentRef.upCount || 6;
154
- const nonScrollableZoneStart = Math.max(0, totalItems - upCount);
159
+ const nonScrollableZoneStart = Math.max(0, childCount - upCount);
155
160
  const isInNonScrollableZone = selected >= nonScrollableZoneStart;
156
161
  const isFirstOfNonScrollableZone = selected === nonScrollableZoneStart;
157
162
  const isEnteringZone =
@@ -163,11 +168,9 @@ export function withScrolling(isRow: boolean): Scroller {
163
168
  nextPosition = -selectedPosition + offset;
164
169
  } else if (isIncrementing) {
165
170
  if (isEnteringZone) {
166
- const firstOfZoneElement =
167
- componentRef.children[nonScrollableZoneStart];
168
- const firstOfZonePosition = firstOfZoneElement?.[axis] ?? 0;
171
+ const firstOfZoneElement = children[nonScrollableZoneStart];
169
172
  nextPosition = firstOfZoneElement
170
- ? -firstOfZonePosition + offset
173
+ ? -(firstOfZoneElement[axis] ?? 0) + offset
171
174
  : rootPosition;
172
175
  } else {
173
176
  nextPosition = rootPosition;
@@ -186,23 +189,20 @@ export function withScrolling(isRow: boolean): Scroller {
186
189
  nextPosition = Math.min(Math.max(centerPosition, maxOffset), offset);
187
190
  } else if (!nextElement) {
188
191
  // If at the last element, align to end
189
- if (componentRef.scrollStopLast && isIncrementing) {
192
+ if (scrollStopLast && isIncrementing) {
190
193
  nextPosition = rootPosition - selectedSize - gap;
191
194
  } else {
192
195
  nextPosition = isIncrementing ? maxOffset : offset;
193
196
  }
194
197
  } else if (scroll === 'auto') {
195
- if (componentRef.scrollIndex && componentRef.scrollIndex > 0) {
198
+ if (scrollIndex && scrollIndex > 0) {
196
199
  // Prevent scrolling if the selected item is within the last scrollIndex items
197
- const totalItems = componentRef.children.length;
198
- const nearEndIndex = totalItems - componentRef.scrollIndex;
200
+ const nearEndIndex = childCount - scrollIndex;
201
+ const currentSelected = componentRef.selected;
199
202
 
200
- if (
201
- isIncrementing &&
202
- componentRef.selected >= componentRef.scrollIndex
203
- ) {
203
+ if (isIncrementing && currentSelected >= scrollIndex) {
204
204
  nextPosition = rootPosition - selectedSize - gap;
205
- } else if (!isIncrementing && componentRef.selected < nearEndIndex) {
205
+ } else if (!isIncrementing && currentSelected < nearEndIndex) {
206
206
  nextPosition = rootPosition + selectedSize + gap;
207
207
  }
208
208
  } else if (isIncrementing) {
@@ -211,15 +211,15 @@ export function withScrolling(isRow: boolean): Scroller {
211
211
  nextPosition = rootPosition + selectedSize + gap;
212
212
  }
213
213
  } // Handle Edge scrolling
214
- else if (isIncrementing && isNotShown(nextElement)) {
215
- nextPosition = rootPosition - selectedSize - gap;
216
- } else if (isNotShown(nextElement)) {
217
- nextPosition = -selectedPosition + offset;
214
+ else if (isNotShown(nextElement)) {
215
+ nextPosition = isIncrementing
216
+ ? rootPosition - selectedSize - gap
217
+ : -selectedPosition + offset;
218
218
  }
219
219
 
220
220
  // Prevent container from moving beyond bounds
221
221
  const isScrollStopLastCase =
222
- componentRef.scrollStopLast && !nextElement && isIncrementing;
222
+ scrollStopLast && !nextElement && isIncrementing;
223
223
  nextPosition =
224
224
  isIncrementing &&
225
225
  scroll !== 'always' &&
@@ -229,10 +229,11 @@ export function withScrolling(isRow: boolean): Scroller {
229
229
  : Math.min(nextPosition, offset);
230
230
 
231
231
  // Update position if it has changed
232
- if (componentRef[axis] !== nextPosition) {
233
- if (componentRef.onScrolled) {
234
- const isInitial = nextPosition === componentRef._initialPosition;
235
- componentRef.onScrolled(componentRef, nextPosition, isInitial);
232
+ if (position !== nextPosition) {
233
+ const onScrolled = componentRef.onScrolled;
234
+ if (onScrolled) {
235
+ const isInitial = nextPosition === initialPosition;
236
+ onScrolled.call(componentRef, componentRef, nextPosition, isInitial);
236
237
  }
237
238
 
238
239
  componentRef[axis] = nextPosition;