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

Ignore empty lines for line events #43031

Merged
merged 2 commits into from Oct 26, 2021

Conversation

katleiahramos
Copy link
Contributor

Ignores blank lines for line events

Skip.empty.lines.mov

Links

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@katleiahramos katleiahramos requested a review from a team October 15, 2021 22:32
@@ -299,11 +299,12 @@ export default class PoetryLibrary extends CoreLibrary {
applyGlobalLineAnimation(renderInfo, frameCount) {
// Add 2 so there's time before the first line and after the last line
const framesPerLine = POEM_DURATION / (renderInfo.lines.length + 2);
const nonEmptyLines = renderInfo.lines.filter(line => line.text !== ''); // Ignore empty lines for line events
Copy link
Contributor

Choose a reason for hiding this comment

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

could line.text ever be null/undefined or empty but with whitespace " "? we might want to consider those cases anyways because "empty" could end up meaning any of those things in the future

@ajpal
Copy link
Contributor

ajpal commented Oct 26, 2021

I think instead of filtering out the blank lines in applyGlobalLineEffect, it would be better to filter them out in executeDrawLoopAndCallbacks where we fire the line event callbacks. Basically, I think the blank lines should still be allowed to take up time in the poem animation (like a stanza pause), but they just shouldn't count for the line event block

@katleiahramos
Copy link
Contributor Author

I think instead of filtering out the blank lines in applyGlobalLineEffect, it would be better to filter them out in executeDrawLoopAndCallbacks where we fire the line event callbacks. Basically, I think the blank lines should still be allowed to take up time in the poem animation (like a stanza pause), but they just shouldn't count for the line event block

@ajpal So I see we're already filtering lines using the property isPoemBodyLine. Does it make sense to mark that as false if the line is "blank" and then just let it get filtered out here?

 const poemLines = renderInfo.lines.filter(
        line => line.isPoemBodyLine
      );

@ajpal
Copy link
Contributor

ajpal commented Oct 26, 2021

I think instead of filtering out the blank lines in applyGlobalLineEffect, it would be better to filter them out in executeDrawLoopAndCallbacks where we fire the line event callbacks. Basically, I think the blank lines should still be allowed to take up time in the poem animation (like a stanza pause), but they just shouldn't count for the line event block

@ajpal So I see we're already filtering lines using the property isPoemBodyLine. Does it make sense to mark that as false if the line is "blank" and then just let it get filtered out here?

 const poemLines = renderInfo.lines.filter(
        line => line.isPoemBodyLine
      );

Oh, yeah that would totally work! (i think)

@katleiahramos katleiahramos force-pushed the katleiah/handle-blank-lines-poetry branch from 1b3a723 to 8b457b0 Compare October 26, 2021 19:49
Comment on lines 36 to 40
export function containsAtLeastOneAlphaNumberic(string) {
return /^.*[a-zA-Z0-9èàùìòÈÀÒÙÌéáúíóÉÁÚÍÓëäüïöËÄÜÏÖêâûîôÊÂÛÎÔç'-]+.*$/.test(
string
);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This feels like it should go into a global stringUtils type of file. I didn't see one, and so I put it here for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated: 6184ff1

@@ -441,7 +441,7 @@ export default class PoetryLibrary extends CoreLibrary {
x: PLAYSPACE_SIZE / 2,
y: yCursor,
size: lineSize,
isPoemBodyLine: true
isPoemBodyLine: utils.containsAtLeastOneAlphaNumberic(line) // Used to skip blank lines in animations
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I almost wonder if we should rename isPoemBodyLine to canHaveEvent or something? I feel like that might be a more accurate representation of what it is/ what it's used for and then we might not need as much info in the comments. But doesn't have to be part of these changes.

@katleiahramos katleiahramos merged commit dd56c9b into staging Oct 26, 2021
@katleiahramos katleiahramos deleted the katleiah/handle-blank-lines-poetry branch October 26, 2021 23:19
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.

None yet

3 participants