Skip to content

Commit

Permalink
Fix post rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
amovar18 committed Dec 2, 2024
1 parent 129e0fb commit 50d2107
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 108 deletions.
4 changes: 4 additions & 0 deletions packages/explorable-explanations/src/components/branches.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ const drawAnimatedTimeline = (x, y, branches) => {
const branchX = x + i * spacing;
const branch = branches[i];
let endpoint;
if (app.cancelPromise) {
resolve();
return;
}

if (app.cancelPromise) {
resolve();
Expand Down
48 changes: 0 additions & 48 deletions packages/explorable-explanations/src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,52 +320,4 @@ utils.markVisitedValue = (index, value) => {
});
};

utils.setButtonsDisabilityState = () => {
const prevButton = document.getElementById('prevButton') ?? app.prevButton;
const nextButton = document.getElementById('nextButton') ?? app.nextButton;
// Exit early if buttons are not found
if (!prevButton || !nextButton) {
return;
}

if (!app.isInteractiveMode) {
document.getElementById('prevButton').disabled =
app.timeline.currentIndex > 0 ? false : true;

// Helper function to set button state
const setButtonState = (button, isDisabled) => {
button.disabled = isDisabled;
button.classList.toggle('disabled:pointer-events-none', isDisabled);
};

if (!isInteractiveMode) {
setButtonState(prevButton, currentIndex <= 0);
setButtonState(nextButton, currentIndex >= circles.length - 1);
}

// Additional state when the currentIndex exceeds the total circles
if (currentIndex >= circles.length) {
setButtonState(prevButton, true);
setButtonState(nextButton, true);
}
}
// eslint-disable-next-line no-undef
if (process.env.IS_RUNNING_STANDALONE) {
utils.disableButtons();
}
};
// This is only called in the standalone canvas.
utils.disableButtons = () => {
app.prevButton.style.cursor =
app.timeline.currentIndex > 0 ? 'pointer' : 'default';
app.prevButton.disabled = app.timeline.currentIndex > 0 ? false : true;
app.nextButton.disabled =
app.timeline.currentIndex === config.timeline.circles.length - 1
? true
: false;
app.nextButton.style.cursor =
app.timeline.currentIndex >= config.timeline.circles.length - 1
? 'default'
: 'pointer';
};
export default utils;
19 changes: 5 additions & 14 deletions packages/explorable-explanations/src/modules/auctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,6 @@ auction.setUp = (index) => {
{
title: 'DSP 2',
},
{
title: 'DSP 1',
},
{
title: 'DSP 2',
},
{
title: 'Key/Value Trusted',
description: 'SSP Server',
Expand Down Expand Up @@ -470,16 +464,13 @@ auction.draw = (index) => {
if (props?.showBarrageAnimation) {
await bubbles.barrageAnimation(index); // eslint-disable-line no-await-in-loop

const returnValue = await component(props); // eslint-disable-line no-await-in-loop
if (app.cancelPromise) {
return;
}

const delay = component === Box ? 1000 : 0;
await utils.delay(500); // eslint-disable-line no-await-in-loop

if (props?.showBarrageAnimation) {
if (
app.isInteractiveMode &&
config.timeline.circles[index].visited === true
) {
return;
utils.wipeAndRecreateInterestCanvas(); // eslint-disable-line no-await-in-loop
}

if (props?.showRippleEffect) {
Expand Down
4 changes: 0 additions & 4 deletions packages/explorable-explanations/src/modules/bubbles.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,6 @@ bubbles.bubbleChart = (
.attr('stroke-opacity', strokeOpacity)
.attr('class', 'svg overflowing-text circle-svg')
.attr('style', `${!app.bubbles.isExpanded ? 'pointer-events: none;' : ''}`)
.attr(
'style',
`${!config.bubbles.isExpanded ? 'pointer-events: none;' : ''}`
)
.attr(
'fill',
groups
Expand Down
19 changes: 18 additions & 1 deletion packages/explorable-explanations/src/modules/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,27 @@ timeline.init = () => {
}
});

expandIconPositions.forEach((positions) => {
if (
utils.isInsideCircle(
app.mouseX,
app.mouseY,
positions.x + config.timeline.circleProps.diameter / 2,
positions.y,
20
)
) {
app.isRevisitingNodeInInteractiveMode = true;
clickedIndex = positions.index;
}
});

if (
clickedIndex !== undefined &&
!config.timeline.circles[clickedIndex].visited
!app.isRevisitingNodeInInteractiveMode
) {
PromiseQueue.clear();
flow.clearBelowTimelineCircles();
app.shouldRespondToClick = false;
app.timeline.currentIndex = clickedIndex;
utils.wipeAndRecreateUserCanvas();
Expand Down
42 changes: 1 addition & 41 deletions packages/explorable-explanations/src/protectedAudience.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,6 @@ import bubbles from './modules/bubbles.js';
import app from './app.js';
import PromiseQueue from './lib/PromiseQueue.js';

const app = {
timeline: {
isPaused: false,
circlePositions: [],
smallCirclePositions: [],
circlePublisherIndices: [],
currentIndex: 0,
},
auction: {
auctions: [],
nextTipCoordinates: { x: 0, y: 0 },
},
joinInterestGroup: {
joinings: [],
nextTipCoordinates: { x: 0, y: 0 },
},
flow: {
intervals: {},
},
bubbles: {
positions: [],
minifiedSVG: null,
expandedSVG: null,
},
utils: {},
p: null,
igp: null,
up: null,
isMultiSeller: false,
};

app.setUpTimeLine = () => {
app.auction.auctions = [];
app.joinInterestGroup.joinings = [];
Expand Down Expand Up @@ -328,10 +297,6 @@ app.handleNonInteravtiveNext = () => {
return;
}

if (app.timeline.currentIndex > config.timeline.circles.length - 1) {
return;
}

app.timeline.isPaused = true;
app.cancelPromise = true;
app.timeline.currentIndex += 1;
Expand Down Expand Up @@ -458,7 +423,7 @@ app.handleControls = () => {
};

app.toggleInteractiveMode = async () => {
PromiseQueue.stop();
PromiseQueue.clear();
app.cancelPromise = true;
app.timeline.isPaused = true;

Expand All @@ -471,11 +436,6 @@ app.toggleInteractiveMode = async () => {
app.shouldRespondToClick = true;
app.startTrackingMouse = true;

if (!config.isInteractiveMode) {
config.shouldRespondToClick = true;
config.startTrackingMouse = true;
}

utils.markVisitedValue(config.timeline.circles.length, false);
timeline.eraseAndRedraw();
await utils.delay(100);
Expand Down

0 comments on commit 50d2107

Please sign in to comment.