Rotate an object in X and Y axis with mouse drag or touch in Unity?

I have a script that rotates an object in the Y axis but how do I rotate the object in the X axis as well? For example, if mouse-drag/touch is moving Left/Right, it should rotate in Y direction and if its moving up/down, it should rotate in X direction.

public class Rotate : MonoBehaviour
{

private float _sensitivity;
private Vector3 _mouseReference;
private Vector3 _mouseOffset;
private Vector3 _rotation;
private bool _isRotating;

void Start()
{
    _sensitivity = 0.4f;
    _rotation = Vector3.zero;
}

void Update()
{
    if (_isRotating)
    {
        // offset
        _mouseOffset = (Input.mousePosition - _mouseReference);

        // apply rotation
        _rotation.y = -(_mouseOffset.x + _mouseOffset.y) * _sensitivity;

        // rotate
        transform.Rotate(_rotation);

        // store mouse
        _mouseReference = Input.mousePosition;
    }
}

void OnMouseDown()
{
    // rotating flag
    _isRotating = true;

    // store mouse
    _mouseReference = Input.mousePosition;
}

void OnMouseUp()
{
    // rotating flag
    _isRotating = false;
}

}

First you need setup a swipe delta threshold according to which you decide whether to carry on or not.
Second you need to calculate the rotation angle based on the change of the swipe delta in the current frame.
**Third ** Apply the rotation via quatrinion and set your Z component to zero to avoid unwanted rotation behavior BUT Remember only after the rotation is applied do this step.
i think something like this might help you.