Controlled slider

I have UI slider which i want to be controlled in two-sided manner:
By default, the slider bar is controlled by the script, but when player presses on the slider, i want it to reverse and allow user to set slider value into the script. My trouble is that when script controls slider, it overrides any input made by user. I need to somehow detect if player presses on the slider button,
Any tips?

i would need to see how it is coded, but you can just have a bool isPressed, that the whenever the player modifys its value set it to true and just compare if its false for before changing the slider value by code

   public Slider mainSlider;
   private bool isPressed;

    public void Start()
    {
        isPressed = false;
        mainSlider.onValueChanged.AddListener(delegate {ValueChangeCheck(); });
    }

    public void ValueChangeCheck()
    {
        isPressed = true;
    }