Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add callback for page changes in instructions plugin #3190

Open
wants to merge 6 commits into
base: v8
Choose a base branch
from

Conversation

Shaobin-Jiang
Copy link
Contributor

A new parameter page_change_callback is added to plugin instructions. This function is called every time a page change occurs and receives one single argument which is the index of the current page, starting from 0.

I am really in favor of this parameter because we often are in the need of acquiring the current page number and make corresponding changes. For example, we might want to hide button previous on the first page and change the label of button forward to "start experiment" on the last page. We can do this without the page_change_callback parameter naturally, but not as convenient as with the parameter.

Normally, with a plugin that does not have "page change", we can achieve this with the on_finish parameter. But given that the instructions plugin is a special one with page change, I think a resembling parameter ought to be added, hence the page_change_callback.

Copy link

changeset-bot bot commented Nov 23, 2023

🦋 Changeset detected

Latest commit: 1c1849c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@jspsych/plugin-instructions Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jodeleeuw
Copy link
Member

Hey @Shaobin-Jiang this is great, thanks. What do you think about calling it on_page_change to make it consistent with other callback function parameters in the library?

@jodeleeuw jodeleeuw changed the title Enhance instructions Add callback for page changes in instructions plugin Dec 8, 2023
@Shaobin-Jiang
Copy link
Contributor Author

Great idea @jodeleeuw . Changed that bit in the latest commit.

@jodeleeuw jodeleeuw added this to the 8.0 milestone Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants