Commit Graph

4 Commits

Author SHA1 Message Date
Andrey Kyrdyumov
0dd15bce72 Make SnapSVG accessible from WebPack
I have to add export = Snap to make project accessible from projects which using webpack, mina object was not accessibly now, but in runtime it was still perfectly fine to have it in the code. Thus I extract mina package as separate global dependency. For code which use SnapSVG as global dependency this will work as earlier, but for those who want to use SnapSVG with WebPack it will reflect how mina available after importing SnapSVG
2017-06-30 12:43:51 +06:00
uglycoyote
c0c9cd3d41 Changing Paper.g and Paper.group to return Snap.Paper rather than just Paper (failed Travis test) 2017-03-31 10:18:23 -07:00
uglycoyote
80a1bc1c9f Change return type of Paper.group() and Paper.g() to "Paper"
Prior to this change, the return type of Paper.group() was specified as "any" which was not very helpful.  In my code I was declaring the variable i was storing the group in as "Element" which seemed to make sense at first, but then I later realized that operations like myGroup.line (to add a line in the group) were resulting in type errors.  The "group" type has a line method but the "Element" type does not.

Looking in to the source code a bit more I found that groups are instantiated as Elements but then use the following code (in the Element construcor) to copy methods from the Paper prototype, which I believe makes the group type essentially equal to a "Paper":

```
    if (this.type in {g: 1, mask: 1, pattern: 1, symbol: 1}) {
        for (var method in Paper.prototype) if (Paper.prototype[has](method)) {
            this[method] = Paper.prototype[method];
        }
    }
```

I'm not exactly familiar with this syntax though; it's not clear to me what ```Paper.prototype[has](method)``` exactly means or whether this means that a group object only inherits a subset of the methods from Paper, and therefore there should be some other type in the Type Definition file which corresponds to groups, masks, patterns and symbols.

Perhaps the Paper.mask and Paper.ptrn should be changed to return Paper as well?  I'm not familiar with those so I didn't touch them in the type def file.
2017-03-30 22:40:29 -07:00
Andy Hanson
354cec620d Move all packages to a types directory 2017-03-24 14:27:52 -07:00