Kinetics of one-dimensional swelling and shrinking of polymer gels under mechanical constraint