If you want to have particle bounced at y=y0; (You can add a slider for user to change y0,too. )
you should change the code to

if(vy>0)return 1;
return y-y0;

How it works in ejs:
If the return value is less than zero, EJS will know it is an event need to be processed.
And EJS will reduce time step to find the most precise point so that return value is almost equal to zero.
process the event, and move forward the time to it should be.

In your previous case,
if(y<0.5)return y;

you did not notice the error. Because the relative error is too small for your eye to notice it.
However, the error will accumulate.
If you change the range to y(maximum)=1 you will notice the error easily.