It’s better just to use a gallery script tht has responsiveness baked in. There are lots around these days. Examples include bxslider, slick, flickety, owl, responsive slides and many more.
I’m sure it can be done, but I’ve found it to be too much trouble in the past. Part of the problem is that JS is affecting the CSS, so it’s not just a matter of editing your styles to make it more responsive. You basically have to mess with the JS, which can end up taking longer than just getting a ready-made script.