-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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 #7389
Comments
Hi! Can I work on this enhancement request. I consider myself a newbie to open source and to p5.js for that matter. And I'd do good with a little bit of help. |
Sure, I'd like also to become a contributor to the library, I have a few blocks of code i'd like to see in the lib and as addons. Maybe we wait for a steward for a review, go free with this one I see you already forked the lib, may be a merge request on main with this implementation would go faster, idk |
Thank you! I think we might need approval from at least 1 steward before we start the work, as this is feature enhancement. Let's see. |
I think something like this makes sense, @limzykenneth how do you feel about the proposed API here? |
I'm thinking whether |
I forked the library to make tests with the 'style' function to go through the _validateParameters() process. That being said I'm having some troubles figuring the impletation of such built-in tools since I'm quite new with the architecture, but I'll get there ! p5.Element.prototype.show = function (value) {
// check if value is a valid value for display prop
p5._validateParameters('show', arguments);
//affect const diplayValue either passed-in value, previous value (different from none) or default;
const displayValue = value || this._prevDisplay || 'revert';
//apply value to object with p5 style function
this.style('display', displayValue);
return this;
};
p5.Element.prototype.hide = function () {
// Store the current display style if not already set
this._prevDisplay = this.style('display');
// use p5 style to hide p5 elt
this.style('display', 'none');
return this;
}; This way I think it's more clear that we want to consider that the element we want to |
|
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?
Feature enhancement details
The text was updated successfully, but these errors were encountered: