Skip to content

Commit daed6b8

Browse files
committed
cleanup changesets and fix versioning
1 parent f4365e3 commit daed6b8

File tree

6 files changed

+60
-39
lines changed

6 files changed

+60
-39
lines changed

.changeset/clean-buckets-chew.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22
"@jspsych-contrib/plugin-html-vas-response": minor
33
---
44

5-
Fixes an issue where drag events caused the scale to become unresponsive and the `not-allowed` cursor to appear.
6-
7-
html-vas-response 2.0.0
5+
Fixes an issue where drag events caused the scale to become unresponsive and the `not-allowed` cursor to appear.

.changeset/proud-ghosts-move.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/plugin-html-vas-response/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This plugin collects responses to an arbitrary HTML string using a point-and-cli
77
## Loading
88

99
```js
10-
<script src="https://unpkg.com/@jspsych-contrib/plugin-html-vas-response@2.1.0"></script>
10+
<script src="https://unpkg.com/@jspsych-contrib/plugin-html-vas-response@2.0.0"></script>
1111
```
1212

1313
## Compatibility

packages/plugin-html-vas-response/index.js

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var jsPsychHtmlVasResponse = (function (jspsych) {
33

44
const info = {
55
name: "html-vas-response",
6-
version: "2.0.0",
6+
version: "2.1.0",
77
parameters: {
88
/** The string to be displayed. */
99
stimulus: {
@@ -187,7 +187,7 @@ var jsPsychHtmlVasResponse = (function (jspsych) {
187187
trial(display_element, trial) {
188188
// constrain hline_pct to < 100
189189
if (trial.hline_pct > 100) {
190-
console.log('hline_pct is greater than 100! This makes no sense. Setting to 100.');
190+
console.log("hline_pct is greater than 100! This makes no sense. Setting to 100.");
191191
trial.hline_pct = 100;
192192
}
193193
// half of the thumb width value from jspsych.css, used to adjust the label positions
@@ -213,17 +213,30 @@ var jsPsychHtmlVasResponse = (function (jspsych) {
213213
// Draw horizontal line in VAS container
214214
html +=
215215
'<div id="jspsych-html-vas-response-hline" style="position: relative; background: ' +
216-
trial.scale_colour + "; " +
217-
'width: ' + trial.hline_pct + '%; ' +
218-
'left: ' + (100 - trial.hline_pct)/2 + '%; ' + // Keep the horizontal line centred within clickable region
219-
'height: 2px; ' +
220-
'top: ' + (trial.scale_height / 2 - 1) + 'px">';
216+
trial.scale_colour +
217+
"; " +
218+
"width: " +
219+
trial.hline_pct +
220+
"%; " +
221+
"left: " +
222+
(100 - trial.hline_pct) / 2 +
223+
"%; " + // Keep the horizontal line centred within clickable region
224+
"height: 2px; " +
225+
"top: " +
226+
(trial.scale_height / 2 - 1) +
227+
'px">';
221228
// Draw vertical line, but hide it at first
222229
html +=
223-
'<div id="jspsych-html-vas-response-vline" style="visibility: hidden; position: absolute; left: 0px; ' +
224-
'background-color: ' + trial.marker_colour + '; ' +
225-
'height: ' + trial.scale_height + 'px; ' +
226-
'top: ' + (-trial.scale_height/2 + 1) + 'px; ' +
230+
'<div id="jspsych-html-vas-response-vline" style="visibility: hidden; position: absolute; left: 0px; ' +
231+
"background-color: " +
232+
trial.marker_colour +
233+
"; " +
234+
"height: " +
235+
trial.scale_height +
236+
"px; " +
237+
"top: " +
238+
(-trial.scale_height / 2 + 1) +
239+
"px; " +
227240
'width: 2px"></div>';
228241

229242
html += "<div>"; // special alignment div
@@ -234,7 +247,9 @@ var jsPsychHtmlVasResponse = (function (jspsych) {
234247
var offset = (percent_dist_from_center * half_thumb_width) / 100;
235248
html +=
236249
'<div style="border: 1px solid transparent; display: inline-block; position: absolute; ' +
237-
'top: ' + trial.scale_height/2 + 'px; ' +
250+
"top: " +
251+
trial.scale_height / 2 +
252+
"px; " +
238253
"left:calc(" +
239254
percent_of_range +
240255
"% - (" +
@@ -304,8 +319,7 @@ var jsPsychHtmlVasResponse = (function (jspsych) {
304319
ppn_tick = Math.max(Math.min(ppn_tick, 1), 0); // Constrain to 0 - 1
305320
// Round to nearest increment, if needed
306321
if (trial.n_scale_points) {
307-
ppn_tick =
308-
Math.round(ppn_tick * (trial.n_scale_points - 1)) / (trial.n_scale_points - 1);
322+
ppn_tick = Math.round(ppn_tick * (trial.n_scale_points - 1)) / (trial.n_scale_points - 1);
309323
}
310324
var vline = document.getElementById("jspsych-html-vas-response-vline");
311325
vline.style.left = ppn_tick * hline_rect.width - 1 + "px";
@@ -319,25 +333,33 @@ var jsPsychHtmlVasResponse = (function (jspsych) {
319333
if (trial.resp_fcn) {
320334
trial.resp_fcn(ppn_tick);
321335
}
322-
};
336+
}
323337
// Dragging makes an ugly "operation forbidden" cursor appear---easiest to just prevent any dragging
324-
document.addEventListener("dragstart", function(e) {e.preventDefault()});
338+
document.addEventListener("dragstart", function (e) {
339+
e.preventDefault();
340+
});
325341
// Make responsive to both clicks and touches
326342
vas.onclick = update_vas;
327343
// Logic is more complex for dragging
328344
if (trial.marker_draggable) {
329345
// Track mouse state---whether to respond to mouse position depends on mouse position
330346
var mouse_state = "up"; // or "down"
331-
document.addEventListener("mousedown", function() {mouse_state = 'down'});
347+
document.addEventListener("mousedown", function () {
348+
mouse_state = "down";
349+
});
332350
// document.addEventListener("dblclick", function() {mouse_state = 'down'});
333-
document.addEventListener("mouseup", function() {mouse_state = 'up'});
334-
document.addEventListener("dragend", function() {mouse_state = 'up'});
351+
document.addEventListener("mouseup", function () {
352+
mouse_state = "up";
353+
});
354+
document.addEventListener("dragend", function () {
355+
mouse_state = "up";
356+
});
335357
function drag_update(e, test_mouse_state) {
336358
var do_update = true;
337359
test_mouse_state = test_mouse_state ?? true; // test by default
338360
if (test_mouse_state) {
339-
if (mouse_state == 'up') {
340-
do_update = false
361+
if (mouse_state == "up") {
362+
do_update = false;
341363
}
342364
}
343365
if (do_update) {
@@ -346,9 +368,9 @@ var jsPsychHtmlVasResponse = (function (jspsych) {
346368
}
347369
vas.addEventListener("mousemove", drag_update);
348370
vas.addEventListener("drag", drag_update);
349-
vas.addEventListener("touchmove", function(e) {
371+
vas.addEventListener("touchmove", function (e) {
350372
e.preventDefault(); // So that whole screen doesn't move in MS Edge
351-
drag_update(e, false) // Don't test whether mouse is down
373+
drag_update(e, false); // Don't test whether mouse is down
352374
});
353375
}
354376

packages/plugin-html-vas-response/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jspsych-contrib/plugin-html-vas-response",
3-
"version": "2.1.0",
3+
"version": "2.0.0",
44
"description": "This plugin collects responses to an arbitrary HTML string using a point-and-click visual analogue scale.",
55
"unpkg": "dist/index.browser.min.js",
66
"files": [

packages/plugin-ios/index.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var jsPsychIos = (function (jspsych) {
33

44
const info = {
55
name: "ios",
6-
version: "2.0.0",
6+
version: "2.0.1",
77
parameters: {
88
/** The prompt to be displayed above the circles. */
99
prompt: {
@@ -426,22 +426,28 @@ var jsPsychIos = (function (jspsych) {
426426
}
427427
};
428428
// Handle touch events
429-
clickable_area.addEventListener('touchstart', function (e) {
429+
clickable_area.addEventListener("touchstart", function (e) {
430430
circles_movable = true;
431431
update_circles(e.changedTouches[e.changedTouches.length - 1].clientX);
432432
var continue_button = document.getElementById("jspsych-ios-next");
433433
continue_button.disabled = false;
434434
});
435-
clickable_area.addEventListener('touchend', function(e) {circles_movable = false;});
436-
clickable_area.addEventListener('touchleave', function(e) {circles_movable = false;});
437-
clickable_area.addEventListener('touchmove', function (e) {
435+
clickable_area.addEventListener("touchend", function (e) {
436+
circles_movable = false;
437+
});
438+
clickable_area.addEventListener("touchleave", function (e) {
439+
circles_movable = false;
440+
});
441+
clickable_area.addEventListener("touchmove", function (e) {
438442
e.preventDefault(); // So that whole screen doesn't move in MS Edge
439443
if (circles_movable) {
440444
update_circles(e.changedTouches[e.changedTouches.length - 1].clientX);
441445
}
442446
});
443447
// Handle drag events
444-
document.addEventListener("dragstart", function(e) {e.preventDefault()});
448+
document.addEventListener("dragstart", function (e) {
449+
e.preventDefault();
450+
});
445451

446452
// Data storage
447453
var response = {

0 commit comments

Comments
 (0)