Due to absence of movement the pumping of blood from the leg towards heart is halted. because of which there is accumulation of extra cellular fluid and this is what swelling is your complaint. Continuous bending of knees leads to knee flexor spasm (Gastrocnemius muscle
in Calf is the knee flexor in standing position).. So elevation of leg above the heart level reduces the swelling.
Wish you a good health soon.