End Trial after meeting a condition

Description of the problem:
Is there a way to end a particular trial (not a routine) if a condition is met? continueRoutine/break works when added to “Each Frame” section of the builder in Psychopy but not when added in PsychoJS to run it online.

From what I read in other posts, PsychoJS breaks cause the program to break out of all the loops as opposed to just the inner loop (which is presumably the loop within a trial). Using “continueRoutine = false;” leads to breaking out of the entire trial loop even if added in the Each Frame section. Using “trials.finished = true;” works similar.

I haven’t had problems with continueRoutine=False (which auto translates to continueRoutine=false;)

It doesn’t seem to work for me. Specifically, I have the following in the “EachFrame” section of my JS code component.
if (euclidean_dist(fixation_baseline.pos, [0, 0]) > 0.42){
fixation_baseline.opacity = 1;
continueRoutine = false;
}

If I were to remove continueRoutine = false;, the opacity of my stimulus (fixation_baseline) does change to 1 as expected meaning my condition does work as expected. Continue routine, instead of taking me out of that current trial, takes me out of the entire experiment.

The Psychopy version (continueRoutine = False) works perfectly well.

Help really appreciated!
Tejas

I suspect that your issue is that this inequality is still true at the beginning of the next iteration of the loop. What is the fixation pos based on? If it’s the mouse or an eye tracker then you probably need another intervening routine which only advances when the distance is small

You’re right!
It is based on mouse control. Adding an intervening routine worked.
Thank you so much!