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 custom value for show() function for p5.Elements #7388

Closed
1 of 17 tasks
rbottura opened this issue Nov 22, 2024 · 1 comment
Closed
1 of 17 tasks

add custom value for show() function for p5.Elements #7388

rbottura opened this issue Nov 22, 2024 · 1 comment

Comments

@rbottura
Copy link

Increasing access

we could deal with flex-type elements, and be able to toggle there visibility with a simple show('flex'). Or with a combined use with hide(), store the initial display value in p5.Element memory and re-use it when calling show() on same element.

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

Feature request details

p5.Element.prototype.show = function (value = 'block') {
  // List of valid CSS display values
  const validDisplayValues = [
    'block', 'inline', 'inline-block', 'flex', 'inline-flex', 'grid',
    'inline-grid', 'table', 'table-row', 'table-cell', 'contents', 'list-item', 
    'none', 'initial', 'inherit', 'unset', 'run-in', 'ruby', 'ruby-base', 
    'ruby-text', 'ruby-base-container', 'ruby-text-container'
  ];

  if (validDisplayValues.includes(value)) {
    this.elt.style.display = value;
  } else {
    console.error(`Invalid value for displaying element: "${value}"`);
  }

  return this;
};
Copy link

welcome bot commented Nov 22, 2024

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, please make sure to fill out the inputs in the issue forms. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant