/* * FancyScrollView (https://github.com/setchi/FancyScrollView) * Copyright (c) 2020 setchi * Licensed under MIT (https://github.com/setchi/FancyScrollView/blob/master/LICENSE) */ using UnityEngine; namespace FancyScrollView { /// /// Documentation text normalized. /// Documentation text normalized. /// Documentation text normalized. /// /// Documentation text normalized. /// Documentation text normalized. public abstract class FancyScrollRectCell : FancyCell where TContext : class, IFancyScrollRectContext, new() { /// public override void UpdatePosition(float position) { var (scrollSize, reuseMargin) = Context.CalculateScrollSize(); var normalizedPosition = (Mathf.Lerp(0f, scrollSize, position) - reuseMargin) / (scrollSize - reuseMargin * 2f); var start = 0.5f * scrollSize; var end = -start; UpdatePosition(normalizedPosition, Mathf.Lerp(start, end, position)); } /// /// Documentation text normalized. /// /// /// Documentation text normalized. /// Documentation text normalized. /// Documentation text normalized. /// /// Documentation text normalized. protected virtual void UpdatePosition(float normalizedPosition, float localPosition) { transform.localPosition = Context.ScrollDirection == ScrollDirection.Horizontal ? new Vector2(-localPosition, 0) : new Vector2(0, localPosition); } } /// /// Documentation text normalized. /// /// Documentation text normalized. /// public abstract class FancyScrollRectCell : FancyScrollRectCell { /// public sealed override void SetContext(FancyScrollRectContext context) => base.SetContext(context); } }