# Stimuli from previous trial remain on the screen for subsequent trials

**URL:** <https://discourse.psychopy.org/t/stimuli-from-previous-trial-remain-on-the-screen-for-subsequent-trials/18575>\
**Category:** Online experiments\
**Created:** [December 2, 2020, 9:21am UTC](https://discourse.psychopy.org/t/stimuli-from-previous-trial-remain-on-the-screen-for-subsequent-trials/18575 "2020-12-02T09:21:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lucy/32/10112_2.png) [@Lucy](https://discourse.psychopy.org/u/Lucy)\
**Post date:** [December 2, 2020, 9:21am UTC](https://discourse.psychopy.org/t/stimuli-from-previous-trial-remain-on-the-screen-for-subsequent-trials/18575/1 "2020-12-02T09:21:23Z")

</div>

URL of experiment: [Pavlovia](https://pavlovia.org/Lucy23/spatial_localisation_builderonly)

Description of the problem:  
My experiment requires participants to drag and drop a stimulus, and for this stimulus to reset to position = (0,0) for the next trial.  
I used a code components to do this (my experiment is named builderonly because I wanted to add my code components one at a time so I can debug where the issues are so it started life as builder only)

This works fine in Psychopy locally however in JS online the stimulus from the previous trial remains on screen in the position it was dragged to.

I tried setting the opacity = 0 in End routine so it would fade into the background but in Psychopy this did not take effect until the start of the next trial (no change in JS).  
I also tried resetting the position back to 0,0 at end routine and this also did not take effect until the start of the next trial in Psychopy (no change JS).  
I think the the challenge in coding this is making sure that the code can decipher the stimulus in the previous trial from the stimulus in the current trial and I’m not sure how to do this.

My other idea was to refresh the screen however I know that the crib sheet does not advise the use of win.flip().

Code components:

 ![Screenshot 2020-12-02 at 09.10.57](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/c/3/c3cc607b0052d6e6f116a5c09d4b7baed7a22df7.png)

 ![Screenshot 2020-12-02 at 09.23.09](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/1/e/1e6cff148d4b114ad21cd968489eb5d7551de457.png)

 ![Screenshot 2020-12-02 at 09.23.39](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/0/f/0fd573e393a695652ccd2488bc75fea5c0e65d09.png)

 ![Screenshot 2020-12-02 at 09.11.53](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/7/f/7fc2b8884fc2610310aaa59b80e096b9d63e8028.png)

---

<div class="post-metadata">

**Author:** ![sotiri](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@sotiri](https://discourse.psychopy.org/u/sotiri)\
**Post date:** [December 3, 2020, 12:34pm UTC](https://discourse.psychopy.org/t/stimuli-from-previous-trial-remain-on-the-screen-for-subsequent-trials/18575/2 "2020-12-03T12:34:39Z")

</div>

hi @Lucy, would it be possible to give me developer access to your project repository so that I can investigate some more? Or is [https://gitlab.pavlovia.org/Lucy23/spatial\_localisation](https://gitlab.pavlovia.org/Lucy23/spatial_localisation) pretty much the same? Thanks, s.

---

<div class="post-metadata">

**Author:** ![Lucy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lucy/32/10112_2.png) [@Lucy](https://discourse.psychopy.org/u/Lucy)\
**Post date:** [December 3, 2020, 2:02pm UTC](https://discourse.psychopy.org/t/stimuli-from-previous-trial-remain-on-the-screen-for-subsequent-trials/18575/3 "2020-12-03T14:02:59Z")

</div>

Hi @sotiri, I think I have invited you to have developer access and yes that is the link 🙂

---

<div class="post-metadata">

**Author:** ![sotiri](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@sotiri](https://discourse.psychopy.org/u/sotiri)\
**Post date:** [December 3, 2020, 2:09pm UTC](https://discourse.psychopy.org/t/stimuli-from-previous-trial-remain-on-the-screen-for-subsequent-trials/18575/4 "2020-12-03T14:09:10Z")

</div>

Hi @Lucy, OK great, on it, thanks 😊

---

<div class="post-metadata">

**Author:** ![Lucy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lucy/32/10112_2.png) [@Lucy](https://discourse.psychopy.org/u/Lucy)\
**Post date:** [December 7, 2020, 10:25am UTC](https://discourse.psychopy.org/t/stimuli-from-previous-trial-remain-on-the-screen-for-subsequent-trials/18575/5 "2020-12-07T10:25:32Z")

</div>

I’ve had help on this issue based on a question I asked in another thread.  
The reason the stimuli remained on screen into the next trial was because I misunderstood the drag and drop process.

At its most basic you do not need the createPiece function from the demo (because you don’t need any more pieces and that is what was being drawn onto the screen in my case and persisting into the next trial).

The lines of code needed for drag and drop can be found in the following thread:

> [@Drag and drop adaptation: moving the pieces all as one](https://discourse.psychopy.org/t/drag-and-drop-adaptation-moving-the-pieces-all-as-one/18515):
>
> OS (e.g. Win10): mac OS Catalina version 10.15.7 PsychoPy version (e.g. 1.84.x): 3.2 Standard Standalone? (y/n) Yes \*\*What are you trying to achieve?: I am looking to adapt the drag and drop demo so that the dragged stimulus moves all as one with no pieces left behind. However the attached version create several pieces which means that as you drag one piece away the next piece is available underneath. What did you try to make it work?: I have started adapting so that I am only using one st…

---

<div class="post-metadata">

**Author:** ![sotiri](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@sotiri](https://discourse.psychopy.org/u/sotiri)\
**Post date:** [December 7, 2020, 10:39am UTC](https://discourse.psychopy.org/t/stimuli-from-previous-trial-remain-on-the-screen-for-subsequent-trials/18575/6 "2020-12-07T10:39:10Z")

</div>

Ah cool, yes that makes sense, glad to hear you were able to find a solution and many thanks @Lucy for taking the time to follow up with the details 👍
