mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-03-17 06:20:24 +00:00
Update README
Move getKlass into seperate function (fabric.util.getKlass)
This commit is contained in:
parent
2698597c74
commit
cd49e7d90e
2 changed files with 14 additions and 7 deletions
|
|
@ -12,8 +12,8 @@ Using Fabric.js, you can create and populate objects on canvas; objects like sim
|
|||
|
||||
### Goals
|
||||
|
||||
- Unit tested (1570+ tests at the moment)
|
||||
- Modular (~40 small "classes", modules, mixins)
|
||||
- Unit tested (1660+ tests at the moment)
|
||||
- Modular (~60 small "classes", modules, mixins)
|
||||
- Cross-browser
|
||||
- [Fast](https://github.com/kangax/fabric.js/wiki/Focus-on-speed)
|
||||
- Encapsulated in one object
|
||||
|
|
|
|||
|
|
@ -162,6 +162,16 @@
|
|||
return _requestAnimFrame.apply(fabric.window, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns klass "Class" object of given fabric.Object type
|
||||
* @memberOf fabric.util
|
||||
* @param {String} type Type of object (eg. 'circle')
|
||||
* @return {Object} klass "Class"
|
||||
*/
|
||||
function getKlass(type) {
|
||||
return fabric[fabric.util.string.camelize(fabric.util.string.capitalize(type))];
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads image element from given url and passes it to a callback
|
||||
* @memberOf fabric.util
|
||||
|
|
@ -193,10 +203,6 @@
|
|||
*/
|
||||
function enlivenObjects(objects, callback) {
|
||||
|
||||
function getKlass(type) {
|
||||
return fabric[fabric.util.string.camelize(fabric.util.string.capitalize(type))];
|
||||
}
|
||||
|
||||
function onLoaded() {
|
||||
if (++numLoadedObjects === numTotalObjects) {
|
||||
if (callback) {
|
||||
|
|
@ -213,7 +219,7 @@
|
|||
if (!o.type) {
|
||||
return;
|
||||
}
|
||||
var klass = getKlass(o.type);
|
||||
var klass = fabric.util.getKlass(o.type);
|
||||
if (klass.async) {
|
||||
klass.fromObject(o, function (o, error) {
|
||||
if (!error) {
|
||||
|
|
@ -449,6 +455,7 @@
|
|||
fabric.util.falseFunction = falseFunction;
|
||||
fabric.util.animate = animate;
|
||||
fabric.util.requestAnimFrame = requestAnimFrame;
|
||||
fabric.util.getKlass = getKlass;
|
||||
fabric.util.loadImage = loadImage;
|
||||
fabric.util.enlivenObjects = enlivenObjects;
|
||||
fabric.util.groupSVGElements = groupSVGElements;
|
||||
|
|
|
|||
Loading…
Reference in a new issue