Skip to content

Commit

Permalink
Merge pull request #4 from Haruma-K/feature/make_props_public
Browse files Browse the repository at this point in the history
Feature/make props public
  • Loading branch information
Haruma-K authored Aug 28, 2022
2 parents 67938d1 + f9c1afc commit 2566c52
Showing 1 changed file with 67 additions and 5 deletions.
72 changes: 67 additions & 5 deletions Assets/FancyCarouselView/Runtime/Scripts/CarouselView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,82 @@ public abstract class CarouselView<TData, TCell> : FancyScrollView<TData, Carous
private bool _draggableCache;
private Coroutine _scrollCoroutine;

protected override GameObject CellPrefab => _cellPrefab.gameObject;

public Scroller Scroller
{
get => _scroller;
set => _scroller = value;
}

public TCell CellPrefabInternal
{
get => _cellPrefab;
set => _cellPrefab = value;
}

public Vector2 CellSize
{
get => _cellSize;
set => _cellSize = value;
}

public float CellSpacing
{
get => _cellSpacing;
set => _cellSpacing = value;
}

public float SnapAnimationDuration
{
get => _snapAnimationDuration;
set => _snapAnimationDuration = value;
}

public Ease SnapAnimationType
{
get => _snapAnimationType;
set => _snapAnimationType = value;
}

public bool AutoScrollingEnabled
{
get => _autoScrollingEnabled;
set => _autoScrollingEnabled = value;
}

public float AutoScrollingIntervalSec
{
get => _autoScrollingIntervalSec;
set => _autoScrollingIntervalSec = value;
}

public bool InverseAutoScrollingDirection
{
get => _inverseAutoScrollingDirection;
set => _inverseAutoScrollingDirection = value;
}

public CarouselProgressView ProgressView
{
get => _progressView;
set => _progressView = value;
}

public bool ProgressViewInteraction
{
get => _progressViewInteraction;
set => _progressViewInteraction = value;
}

protected override GameObject CellPrefab => _cellPrefab.gameObject;

private int ActiveCellPosition => Mathf.RoundToInt(_scroller.Position);

private void Awake()
private void OnEnable()
{
if (_progressView != null) ActiveCellChanged += _progressView.SetActiveIndex;
}

private void OnDestroy()
private void OnDisable()
{
if (_progressView != null) ActiveCellChanged -= _progressView.SetActiveIndex;
}
Expand Down Expand Up @@ -241,7 +301,9 @@ protected override void Initialize()
if (cellContainer == null) cellContainer = transform;

var rectTrans = (RectTransform)cellContainer.transform;
var carouselSize = rectTrans.rect.width;
var carouselSize = _scroller.ScrollDirection == ScrollDirection.Horizontal
? rectTrans.rect.width
: rectTrans.rect.height;
var intervalPerPx = 0.5f / carouselSize;
var cellSize = _scroller.ScrollDirection == ScrollDirection.Horizontal ? _cellSize.x : _cellSize.y;
var zeroSpacingInterval = 0.5f - (carouselSize - cellSize) * intervalPerPx;
Expand Down

0 comments on commit 2566c52

Please sign in to comment.