How to write code for dragging, so when i drag mouse up, speed of animation speed-up, and vice-versa with down dragging?

I have tried with some delta positions, to adjust speed but unlucky. Have anyone some snipet of code for calculating speed?

EDIT (more info):
I have 4 animations

FIRST - idle

SECOND - is anim for gap for transition from FIRST TO THIRD animation, when we pull the object

THIRD - let’s say i have something to pull, and when it is pulled it is in idle, until it is pulled back, so call this animation IDLE PULL

FOURTH - is same as SECOND, just backwards because we pull back

So i need respetively change speed of animation in ration of speed of pulling . How to acheive this?

Here is my controller, i have bool isPulled, when it is true it goes to SECOND(PLAY ONCE) then to THIRD(LOOP) until it is uncheked, and when it is unchecked it goes to FOURTH(PLAY ONCE) and then again to idle

If picture doesn’t show, it is in attachment

I am going to asume that what you want is simpli drag mouse along the screen Y-axis and not drag an image or object.

The following class is a controller, create an empty GameObject, call it whatever you like and add this component to it. The object will register the difference between the starting position of the drag and the end position of the drag to calculate the magnitude of the modifier.

using UnityEngine;

public class UIAnimationSpeedByDrag : MonoBehaviour
{
    public static UIAnimationSpeedByDrag Instance { get; set; }

    public float animationDampingValue;
    float temp;

    Vector2 pointerDownPosition;
    Vector2 pointerUpPosition;

    bool bIsModifyingSpeed = false;

    void Awake ()
    {
        if (Instance == null)
            Instance = this;
        else
            Destroy(gameObject);
    }

    void Update ()
    {
        if (Input.GetMouseButtonDown(0))
        {
            pointerDownPosition = Input.mousePosition;
            bIsModifyingSpeed = true;
        }
        else if (Input.GetMouseButton(0) && bIsModifyingSpeed)
        {
            pointerUpPosition = Input.mousePosition;
            temp = -1 * (pointerDownPosition.y - pointerUpPosition.y);
        }
        else if(Input.GetMouseButtonUp(0) && bIsModifyingSpeed)
        {
            GetMouseMovementDelta();
            bIsModifyingSpeed = false;
        }
    }

    void GetMouseMovementDelta ()
    {
        animationDampingValue += temp;
    }

    void OnGUI ()
    {
        GUILayout.BeginVertical();

        GUILayout.Label("Animation Speed Damping Value : " + animationDampingValue);

        if (bIsModifyingSpeed)
            GUILayout.Label("Modifier (temp): " + temp);

        GUILayout.EndVertical();
    }
}

After the calculations have been made the canvas child element will have to move / animate using the calculated modifier value. Multiply the value with the animation / movement speed that you have used for the animation / movement.

This is a sample of how it would be used :

using UnityEngine;
using UnityEngine.UI;

public class AnimatedUIElement : MonoBehaviour
{
    public Canvas containingCanvas;
    public float animationSpeed = 1f;

    RectTransform rectTransform;

    [SerializeField]
    bool bAnimate = true;

    void Start ()
    {
        rectTransform = GetComponent<RectTransform>();
    }

    void Update ()
    {
        if(bAnimate)
            Animate();
    }

    void Animate ()
    {
        float animationDelta = Time.deltaTime * UIAnimationSpeedByDrag.Instance.animationDampingValue;
        rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x + animationSpeed * animationDelta, rectTransform.anchoredPosition.y);

        if(rectTransform.anchoredPosition.x > containingCanvas.pixelRect.width / 2)
        {
            rectTransform.anchoredPosition = new Vector2(-containingCanvas.pixelRect.width / 2, rectTransform.anchoredPosition.y);
        }
    }
}

There are many ways of optimizing this process. This will get you started if the context that i understood from your question is correct.

Hope i helped you out. Good luck.