Canvas Components, Controls and more!
ZIM 5.5.0 has launched at http://zimjs.com and no longer requires the zim namespace. For example:
var circle = new zim.Circle(); // has the zim namespace var circle = new Circle(); // does not have the namespace
A namespace prevents code conflict. If another library also has a global Circle class then whichever code is loaded last would obscure the other. But ZIM is often used without other libraries and so now the default is the namespace is not required. This saves typing and code size.
If you are using ZIM with other code and foresee naming conflicts then you can easily turn the namespace requirement back on by settingvar zns = true; // turn on zim namespace
before you load the zim code. See the top of the new templates for more details.
You can alternatively require the namespace and then in your code use zimplify() to turn the requirements off. An advantage here is that you can pass an exclude parameter with a string or an array of references you do NOT want to make global. For instance, zimplify(“Circle”); would mean no namespaces are required except for Circle – if that is the name that conflicts with other code.
The docs give a little note above the examples that tell you the zim namespace is not required unless zns is true but the examples and all the code tutorials in the Learn section, etc. still use the namespace. We will let it sink in a little and then consider updating the docs further. For now, it is good to be introduced to zim with the namespace to help recognize zim functions.
All the zim functions, display classes, control classes and Frame can have their namespace removed. The Methods run as functions, like: zim.drag(circle); still need the namespace as you are encouraged to use the method: circle.drag(); Exceptions are loop(), animate(), stopZimAnimate() and pauseZimAnimate(); as these are run as functions for various reasons.
The code to remove the zim namespace is very short – only a few lines. You can see it by expanding the zimplify() entry at the bottom of the docs and then press the view button.
All the best!