You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
is there a better way to do this than to create copies of the methods but attach them to the p5.Element then rather than using addElement() to add it to the pInst we'll just use child() instead.
I would use call() but the addElement() method seems to only add elements to pInst
I wonder if this is just a little too confusing? Right now all the create methods attach something to the DOM, I think it might make sense to stick with this just to make our lives easier on the development side? Or is this creating one element from another pattern something that's really common in JS?
I'm not too keen on adding complexity so I agree this is probably something to leave out. The use case I am finding is that some of my examples do this alot:
var elt1 = createElement();
var elt2 = createElement();
elt2.parent(elt1);
So is this really any better or less confusing?
var elt1 = createElement();
var elt2 = elt1.createElement();
Now that I write these, I think the answer is likely no. Or certainly not so great that it's worth the code and reference expanding.
I think I'd agree when comparing pros and cons; but during testing being able to create an element immediately as a child of another element feels great.
Activity
futuremarc commentedon Jun 16, 2015
is there a better way to do this than to create copies of the methods but attach them to the p5.Element then rather than using
addElement()to add it to thepInstwe'll just usechild()instead.I would use
call()but theaddElement()method seems to only add elements topInstlmccart commentedon Jun 17, 2015
I wonder if this is just a little too confusing? Right now all the create methods attach something to the DOM, I think it might make sense to stick with this just to make our lives easier on the development side? Or is this creating one element from another pattern something that's really common in JS?
shiffman commentedon Jun 17, 2015
I'm not too keen on adding complexity so I agree this is probably something to leave out. The use case I am finding is that some of my examples do this alot:
So is this really any better or less confusing?
Now that I write these, I think the answer is likely no. Or certainly not so great that it's worth the code and reference expanding.
futuremarc commentedon Jun 17, 2015
I think I'd agree when comparing pros and cons; but during testing being able to create an element immediately as a child of another element feels great.
futuremarc commentedon Jun 20, 2015
Closing this one as it doesn't make too much sense