/// <summary> /// Set the moving distance for this new movement /// </summary> /// If there has the distance left in the last movement, /// the moving distance will be accumulated.<para/> /// If the list reaches the end in the linear mode, the moving distance /// will be ignored and use `_bouncingDeltaPos` for the bouncing movement. /// <param name="distanceAdded">Set the additional moving distance</param> /// <param name="flag">No usage</param> public void SetMovement(float distanceAdded, bool flag) { // Ignore any movement when the list is aligning if (!_bouncingMovementCurve.IsMovementEnded()) { return; } var state = _getPositionState(); var movingDirection = Mathf.Sign(distanceAdded); if ((state == PositionState.Top && movingDirection < 0) || (state == PositionState.Bottom && movingDirection > 0)) { _bouncingMovementCurve.SetMovement(movingDirection * _bouncingDeltaPos); _unitMovementCurve.EndMovement(); } else { distanceAdded += _unitMovementCurve.distanceRemaining; _unitMovementCurve.SetMovement(distanceAdded); } }
/// <summary> /// Is the movement ended? /// </summary> public bool IsMovementEnded() { return(_bouncingMovementCurve.IsMovementEnded() && _unitMovementCurve.IsMovementEnded()); }
/// <summary> /// Is the movement ended? /// </summary> public bool IsMovementEnded() { return(!_isDragging && _aligningMovementCurve.IsMovementEnded() && _releasingMovementCurve.IsMovementEnded()); }