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

fix: cease autoplay when maidr is deactivated (outside the plot) #526

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/js/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class Audio {
panning = 0;
}
} else if (constants.chartType == 'heat') {
if (!plot.data || !plot.data[position.y]) return;
rawFreq = plot.data[position.y][position.x];
rawPanning = position.x;
frequency = this.SlideBetween(
Expand Down
13 changes: 13 additions & 0 deletions src/js/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,10 @@ class Control {

constants.autoplayId = setInterval(function () {
position.x += step;
if (!plot || !plot.plotData) {
constants.KillAutoplay();
return;
}
if (position.x < 0 || plot.plotData.length - 1 < position.x) {
constants.KillAutoplay();
lockPosition();
Expand Down Expand Up @@ -1724,6 +1728,7 @@ class Control {
}

constants.autoplayId = setInterval(function () {
if (!plot) return;
if (
dir == 'left' ||
dir == 'right' ||
Expand Down Expand Up @@ -2499,6 +2504,10 @@ class Control {

constants.autoplayId = setInterval(function () {
position.x += step;
if (!plot || !plot.plotData) {
constants.KillAutoplay();
return;
}
if (position.x < 0 || plot.plotData.length - 1 < position.x) {
constants.KillAutoplay();
lockPosition();
Expand Down Expand Up @@ -2872,6 +2881,10 @@ class Control {
dir == 'reverse-right'
) {
position.x += step;
if (!plot || !plot.plotData) {
constants.KillAutoplay();
return;
}
if (position.x < 0 || plot.plotData.length - 1 < position.x) {
constants.KillAutoplay();
lockPosition();
Expand Down
2 changes: 1 addition & 1 deletion src/js/heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ class HeatMapRect {
var rect = document.createElementNS(svgns, 'rect');
rect.setAttribute('id', 'highlight_rect');
rect.setAttribute('x', this.x);
rect.setAttribute('y', this.y);
rect.setAttribute('y', this.y === undefined ? 0 : this.y);
rect.setAttribute('width', this.width);
rect.setAttribute('height', this.height);
rect.setAttribute('stroke', constants.colorSelected);
Expand Down
14 changes: 12 additions & 2 deletions src/js/scatterplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,10 @@ class ScatterPlot {
constants.sepPlayId = setInterval(
function () {
// play this tone
if (!audio || !audio.playTone) {
clearInterval(constants.sepPlayId);
return;
}
audio.playTone();

// and then set up for the next one
Expand All @@ -477,6 +481,10 @@ class ScatterPlot {
); // play all tones at the same time
} else if (constants.chartType == 'smooth') {
// best fit smooth layer
if (!audio || !audio.playTone) {
clearInterval(constants.sepPlayId);
return;
}
audio.playTone();
}
}
Expand Down Expand Up @@ -520,7 +528,7 @@ class ScatterPlot {
if (elIndex > -1) {
data = singleMaidr.data[elIndex];
} else {
data = singleMaidr.data
data = singleMaidr.data;
}
if (xyFormat == 'object') {
for (let i = 0; i < data.length; i++) {
Expand Down Expand Up @@ -714,7 +722,9 @@ class Layer0Point {
plot.plotPoints[this.circleIndex[i]] instanceof SVGUseElement ||
plot.plotPoints[this.circleIndex[i]] instanceof SVGCircleElement
) {
y = plot.plotPoints[this.circleIndex[i]].getAttribute(plot.prefix + 'y');
y = plot.plotPoints[this.circleIndex[i]].getAttribute(
plot.prefix + 'y'
);
}

point.setAttribute('cy', y);
Expand Down
Loading