rename instructions page_change_callback to on_page_change

This commit is contained in:
Shaobin-Jiang 2023-12-09 07:41:22 +08:00
parent 438a46953f
commit 1c1849ca6c
No known key found for this signature in database
GPG Key ID: B679CC70E159691F
3 changed files with 5 additions and 5 deletions

View File

@ -20,7 +20,7 @@ In addition to the [parameters available in all plugins](../overview/plugins.md#
| button_label_next | string | 'Next' | The text that appears on the button to go forwards. |
| show_page_number | boolean | false | If true, and clickable navigation is enabled, then Page x/y will be shown between the nav buttons. |
| page_label | string | 'Page' | The text that appears before x/y pages displayed when show_page_number is true. |
| page_change_callback | function | ``function (current_page) {}`` | The function that is called every time the page changes. This function receives a single argument `current_page`, which is the index of the current page **after page change**, and starts at `0`. The function is also called when going forward from the last page, i.e., finishing the trial. |
| on_page_change | function | ``function (current_page) {}`` | The function that is called every time the page changes. This function receives a single argument `current_page`, which is the index of the current page **after page change**, and starts at `0`. The function is also called when going forward from the last page, i.e., finishing the trial. |
## Data Generated

View File

@ -70,7 +70,7 @@ describe("instructions plugin", () => {
{
type: instructions,
pages: ["page 1", "page 2", "page 3"],
page_change_callback: function (page_number: number) {
on_page_change: function (page_number: number) {
count[page_number]++;
},
},

View File

@ -65,7 +65,7 @@ const info = <const>{
default: "Next",
},
/** The callback function when page changes */
page_change_callback: {
on_page_change: {
type: ParameterType.FUNCTION,
pretty_name: "Page change callback",
default: function (current_page: number) {},
@ -175,7 +175,7 @@ class InstructionsPlugin implements JsPsychPlugin<Info> {
show_current_page();
}
trial.page_change_callback(current_page);
trial.on_page_change(current_page);
}
function back() {
@ -185,7 +185,7 @@ class InstructionsPlugin implements JsPsychPlugin<Info> {
show_current_page();
trial.page_change_callback(current_page);
trial.on_page_change(current_page);
}
function add_current_page_to_view_history() {