| Page 1 of 1 | [ 6 posts ] |
|
If I want to create a new graphic with a set of parameters to be used every time, what's the best way to do that?
I'm trying this atm: Code: Y.extend(ConeIcon, Y.Shape, {}, { ATTRS: Y.mix({ type: 'circle', radius: 5, stroke: { weight: 2, color: '#fff' } }, Y.Shape.ATTRS) }); I just want to create a circle each time, and creating the above like this: Code: newThing = FC.pitch.addShape({ type: FC.ConeIcon, x: e.pageX, y: e.pageY }); I get several errors in the browser Code: Error: Invalid value for <svg:svg> attribute width="NaN" /drill/:1 Error: Invalid value for <svg:svg> attribute height="NaN" /drill/:1 Warning: Problem parsing viewBox="NaN NaN NaN NaN" Is this the best way to do it? I have several shapes & the same event will draw the right shape depending on other and just want to be able to create a new instance where the pointer is. |
|
Can anyone help?
|
|
You want to extend Circle so you can get all of its default behavior.
Code: Y.extend(ConeIcon, Y.Circle, { }, { ATTRS : Y.mix({ stroke: { valueFn: function() { return { weight: 2, dashstyle: "none", color: "#fff", opacity: 1.0 }; } }, radius: { value: 5 } }, Y.Circle.ATTRS, false, false, null, 0, true) }); Thanks, Tripp |
|
What's the difference between the way you've set radius & stroke Tripp? Why does one use valueFN() & the other just return an object?
|
Alberto SantiniYUI Contributor
|
Hello Stuart.
Maybe you may give a look at Attributes guide (Attribute Configuration Properties section - see valueFn): http://yuilibrary.com/yui/docs/attribute/ Recap for valueFn: A function, the return value of which is the value for the attribute. This property can be used instead of the value property for static configurations, if you need to set default values which require access to instance state ("this.something"). Hope that helps, IceBox |
|
Thanks for your help Alberto & Tripp.
|
| Page 1 of 1 | [ 6 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group