5using System.Collections.Generic;
18 [RequireComponent(typeof(Scroller))]
19 public abstract class FancyScrollRect<TItemData, TContext> : FancyScrollView<TItemData, TContext>
20 where TContext : class, IFancyScrollRectContext, new()
44 [SerializeField]
protected float spacing = 0f;
57 protected virtual bool Scrollable => MaxScrollPosition > 0f;
67 protected Scroller Scroller => cachedScroller ?? (cachedScroller = GetComponent<Scroller>());
69 float ScrollLength => 1f / Mathf.Max(
cellInterval, 1e-2f) - 1f;
86 Context.CalculateScrollSize = () =>
91 return (scrollSize, reuseMargin);
102 void OnScrollerValueChanged(
float p)
123 void ShrinkScrollbar(
float offset)
167 base.UpdateContents(items);
187 protected virtual void JumpTo(
int itemIndex,
float alignment = 0.5f)
199 protected virtual void ScrollTo(
int index,
float duration,
float alignment = 0.5f, Action onComplete =
null)
212 protected virtual void ScrollTo(
int index,
float duration,
Ease easing,
float alignment = 0.5f, Action onComplete =
null)
234 return position / Mathf.Max(
ItemsSource.Count - 1, 1) * MaxScrollPosition - PaddingHeadLength;
244 return (position + PaddingHeadLength) / MaxScrollPosition * Mathf.Max(
ItemsSource.Count - 1, 1);
279 Debug.LogError(
"Loop is currently not supported in FancyScrollRect.");
285 Debug.LogError(
"Snap is currently not supported in FancyScrollRect.");
291 Debug.LogError(
"MovementType.Unrestricted is currently not supported in FancyScrollRect.");
Credit Erdener Gonenc - @PixelEnvision.