mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-14 16:53:10 +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
|
### Goals
|
||||||
|
|
||||||
- Unit tested (1570+ tests at the moment)
|
- Unit tested (1660+ tests at the moment)
|
||||||
- Modular (~40 small "classes", modules, mixins)
|
- Modular (~60 small "classes", modules, mixins)
|
||||||
- Cross-browser
|
- Cross-browser
|
||||||
- [Fast](https://github.com/kangax/fabric.js/wiki/Focus-on-speed)
|
- [Fast](https://github.com/kangax/fabric.js/wiki/Focus-on-speed)
|
||||||
- Encapsulated in one object
|
- Encapsulated in one object
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,16 @@
|
||||||
return _requestAnimFrame.apply(fabric.window, arguments);
|
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
|
* Loads image element from given url and passes it to a callback
|
||||||
* @memberOf fabric.util
|
* @memberOf fabric.util
|
||||||
|
|
@ -193,10 +203,6 @@
|
||||||
*/
|
*/
|
||||||
function enlivenObjects(objects, callback) {
|
function enlivenObjects(objects, callback) {
|
||||||
|
|
||||||
function getKlass(type) {
|
|
||||||
return fabric[fabric.util.string.camelize(fabric.util.string.capitalize(type))];
|
|
||||||
}
|
|
||||||
|
|
||||||
function onLoaded() {
|
function onLoaded() {
|
||||||
if (++numLoadedObjects === numTotalObjects) {
|
if (++numLoadedObjects === numTotalObjects) {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
|
|
@ -213,7 +219,7 @@
|
||||||
if (!o.type) {
|
if (!o.type) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var klass = getKlass(o.type);
|
var klass = fabric.util.getKlass(o.type);
|
||||||
if (klass.async) {
|
if (klass.async) {
|
||||||
klass.fromObject(o, function (o, error) {
|
klass.fromObject(o, function (o, error) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
|
|
@ -449,6 +455,7 @@
|
||||||
fabric.util.falseFunction = falseFunction;
|
fabric.util.falseFunction = falseFunction;
|
||||||
fabric.util.animate = animate;
|
fabric.util.animate = animate;
|
||||||
fabric.util.requestAnimFrame = requestAnimFrame;
|
fabric.util.requestAnimFrame = requestAnimFrame;
|
||||||
|
fabric.util.getKlass = getKlass;
|
||||||
fabric.util.loadImage = loadImage;
|
fabric.util.loadImage = loadImage;
|
||||||
fabric.util.enlivenObjects = enlivenObjects;
|
fabric.util.enlivenObjects = enlivenObjects;
|
||||||
fabric.util.groupSVGElements = groupSVGElements;
|
fabric.util.groupSVGElements = groupSVGElements;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue