Don't know what you expected, but
void loop()
{
if (direction == 0) // this is the initial condition, so true
{
direction = 1; // this assignment makes the following condition true
}
if (direction == 1) // so this will be true as well
{
direction = 0; // this restores the initial condition
}
I would expect whatever action to be done and undone very often.