Skip to content

Commit

Permalink
Fix: Interactive mode switching (#896)
Browse files Browse the repository at this point in the history
* Remove app.cancelPromise

* Use queue library for queuing.

* Remove custom promise queue and use queue package.

* Fix barrage cancellation.

* Do not recreate queue everytime.

* Revert commit.

* Move queue creation in sketch function.

* Refactor code to add more readability.

* Fix failing tests.

---------

Co-authored-by: sayedtaqui <sayedwp@gmail.com>
  • Loading branch information
amovar18 and mohdsayed authored Dec 16, 2024
1 parent 6fc2ada commit c94095c
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 223 deletions.
8 changes: 7 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/explorable-explanations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"homepage": "https://github.com/GoogleChromeLabs/ps-analysis-tool",
"dependencies": {
"just-throttle": "^4.2.0",
"p5": "^1.11.0"
"p5": "^1.11.0",
"queue": "^7.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const app = {
visitedIndexOrderTracker: -1,
isRevisitingNodeInInteractiveMode: false,
usedNextOrPrev: false,
promiseQueue: null,
canvasEventListerners: {
main: {
mouseOver: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,6 @@ const drawAnimatedTimeline = (x, y, branches) => {
return;
}

if (app.cancelPromise) {
resolve();
return;
}

if (progress >= i * spacing && !renderedBranchIds.includes(branch.id)) {
// Draw vertical line once the horizontal line reaches its position
p.push();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ const ProgressLine = ({

return new Promise((resolve) => {
const animate = () => {
if (noAnimation || app.isRevisitingNodeInInteractiveMode) {
drawInstantly();
resolve(returnCoordinates);
return;
}

if (app.cancelPromise) {
resolve();
return;
Expand All @@ -118,6 +112,12 @@ const ProgressLine = ({
return;
}

if (noAnimation || app.isRevisitingNodeInInteractiveMode) {
drawInstantly();
resolve(returnCoordinates);
return;
}

p.push();
p.stroke(0);
p.strokeWeight(1);
Expand Down
Loading

0 comments on commit c94095c

Please sign in to comment.