weapon sway rotation glitch

below is my weapon sway script
works not as i expected. the problem is it overshoots when passing the “zero” of an axis.
how do i prevent this hickup in the rotation?
script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class gunsway : MonoBehaviour
{
    public Transform root;
    Vector3 rotationLast;
    Vector3 rotationDelta;
    public float rotationAmount = 4f;
    public float speed = 3f;
    public float x;
    public float y;


    void Start ()
    {
        rotationLast = root.transform.eulerAngles;

    }


    void LateUpdate ()
    {
        rotationDelta = (root.transform.eulerAngles - rotationLast)  / Time.deltaTime /200f;



        rotationDelta.y = Mathf.Round(rotationDelta.y);
        rotationDelta.x = Mathf.Round (rotationDelta.x);

        rotationDelta.x = Mathf.Clamp (rotationDelta.x, -4f, 4f) ;
        rotationDelta.y = Mathf.Clamp (rotationDelta.y, -4f, 4f);  

        Vector3 wantedrotation = new Vector3 (rotationDelta.x , rotationDelta.y,0f);
        wantedrotation *= rotationAmount;
        x = rotationDelta.x;
        y = rotationDelta.y;
        transform.localRotation = Quaternion.Slerp(transform.localRotation,Quaternion.Euler(wantedrotation),Time.deltaTime * speed );

        if (rotationDelta.magnitude == 0) {
            rotationLast = -rotationLast;
        }
        rotationLast = root.transform.eulerAngles;

        //transform.localEulerAngles = rotationDelta;
    }
    public Vector3 angularvelocity
    {
        get
        {
            return rotationDelta;


        }
    }


}

First thing: don’t use Euler angles. They’re awful and lead to an endless variety of glitches.

I suspect that will solve your problem. If it doesn’t, then post the Euler-free code and we can work on that. But without a doubt get rid of Euler. It’s either already causing problems or it will later.

theres nothing wrong with eulers
the problem is the same with quaternions. when getting to zero of an axis the weapon glitches