A water hammer occurs when you stop the flow fast, it doesn't occur while it is flowing. You could have some debris in the toilet fill valve that is causing the flow to vary. Cleaning the seal in the fill valve may help. There are probably other things as well. My unprofessional opinion.