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

Add secondaryKey option for 2d navigation #291

Closed
wants to merge 1 commit into from

Conversation

marwahaha
Copy link

@marwahaha marwahaha commented Jul 16, 2023

fixes #290

For example, my use case is

node decktape.js  --key=ArrowDown automatic 'https://hackmd.io/@kmarw/SJxRLR3DO2?controls=false&fragments=false' ~/test.pdf

There is a bug however; the first slide seems to print twice. Why is this?
This happens:

  • on this branch, when I use a secondary key or not.
  • on the latest release, when the key does not advance the slides.

It does not happen

My guess is that it happens when the first key is pressed, and nothing has changed, but perhaps the page is still loading, so isNextSlideDetected is set to true. Just a hypothesis though. (For example, on my slide deck, the first slide advances with the secondaryKey, i.e. the key doesn't advance the slide.)

Copy link
Owner

@astefanutti astefanutti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I’m thinking this could be generalized by turning the key option into an array, instead of introducing an ad-hoc ˋsecondary-key` option.

In your use case, that would lead to using something like:

$ decktape generic —key=ArrowDown —key=ArrowRight

@@ -79,6 +85,11 @@ class Generic {
// TODO: detect cycle to avoid infinite navigation for frameworks
// that support loopable presentations like impress.js and flowtime.js
await pause(1000);

if (!this.isNextSlideDetected && (typeof this.secondaryKey !== 'undefined')) {
await this.page.keyboard.press(this.secondaryKey);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intuitively, I’d expect the « secondary » key, e.g., the down arrow key, to be used first, and if no changes are detected, then fall through using the « primary » key, i.e., the right arrow key.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, we can reverse the order.

@marwahaha
Copy link
Author

Thanks for the PR. I’m thinking this could be generalized by turning the key option into an array, instead of introducing an ad-hoc ˋsecondary-key` option.

I think this is not that easy; I tried to do this but nomnom's list: true option setting is only parsed when using generic command and not automatic.

@marwahaha
Copy link
Author

This seems sort of complicated, and still doesn't fix the bug. Maybe it makes sense to allow the Hackmd plugin on its own.

@astefanutti
Copy link
Owner

@marwahaha I've created #292, that allows to run:

$ decktape generic 'https://hackmd.io/@kmarw/SJxRLR3DO2?controls=false&fragments=false' test.pdf --key ArrowDown --key ArrowRight

Which produces the following PDF document: test.pdf

@marwahaha
Copy link
Author

I think this almost works, but has the same bug I mention (first slide is repeated twice).

@astefanutti
Copy link
Owner

I've fixed the duplicated first slides issue with 0b69015.

I get the following PDF document: test.pdf

Let me know if that works for you.

@marwahaha
Copy link
Author

marwahaha commented Aug 3, 2023

superseded by #292

@marwahaha marwahaha closed this Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a 2D navigation support to generic plugin
2 participants