1
0
mirror of https://github.com/psychopy/psychojs.git synced 2025-05-10 10:40:54 +00:00

adding capacity for marker to snap to cursor started;

This commit is contained in:
lgtst 2022-06-16 16:18:13 +03:00
parent 88e7d127b3
commit 7794420cff

View File

@ -928,6 +928,39 @@ export class Slider extends util.mix(VisualStim).with(ColorMixin, WindowMixin)
this._body.endFill();
}
}
this._body.pointerdown = (e) =>
{
if (e.data.button === 0)
{
this._markerDragging = true;
if (!this._frozenMarker)
{
const mouseLocalPos_px = e.data.getLocalPosition(this._pixi);
const rating = this._posToRating([mouseLocalPos_px.x, mouseLocalPos_px.y]);
this.setMarkerPos(rating);
}
}
e.stopPropagation();
};
this._body.pointerupoutside = (e) => {
console.log("pointerupoutside body");
if (this._markerDragging)
{
this._markerDragging = false;
if (!this._frozenMarker)
{
const mouseLocalPos_px = e.data.getLocalPosition(this._pixi);
const rating = this._posToRating([mouseLocalPos_px.x, mouseLocalPos_px.y]);
this.recordRating(rating);
}
e.stopPropagation();
}
}
}
/**
@ -1079,6 +1112,7 @@ export class Slider extends util.mix(VisualStim).with(ColorMixin, WindowMixin)
// pointer was released outside of the marker: cancel the dragging
this._marker.pointerupoutside = this._marker.mouseupoutside = this._marker.touchendoutside = (event) =>
{
console.log('pointerupoutside')
if (self._markerDragging)
{
self._markerDragging = false;