Fix element replacement in applyFilters (when no filters are present).

This commit is contained in:
kangax 2011-11-02 17:25:20 -04:00
parent 4216a8ca00
commit d16e166e54
5 changed files with 19 additions and 9 deletions

View file

@ -1,6 +1,6 @@
/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
var fabric = fabric || { version: "0.6.7" };
var fabric = fabric || { version: "0.6.8" };
if (typeof exports != 'undefined') {
exports.fabric = fabric;

16
dist/all.js vendored
View file

@ -1,6 +1,6 @@
/*! Fabric.js Copyright 2008-2011, Bitsonnet (Juriy Zaytsev, Maxim Chernyak) */
var fabric = fabric || { version: "0.6.7" };
var fabric = fabric || { version: "0.6.8" };
if (typeof exports != 'undefined') {
exports.fabric = fabric;
@ -1846,17 +1846,14 @@ fabric.Observable = {
abort = options.abort || function() { return false; },
easing = options.easing || function(pos) { return (-Math.cos(pos * Math.PI) / 2) + 0.5; },
startValue = 'startValue' in options ? options.startValue : 0,
endValue = 'endValue' in options ? options.endValue : 100,
isReversed = startValue > endValue;
endValue = 'endValue' in options ? options.endValue : 100;
options.onStart && options.onStart();
var interval = setInterval(function() {
time = +new Date();
pos = time > finish ? 1 : (time - start) / duration;
onChange(isReversed
? (startValue - (startValue - endValue) * easing(pos))
: (startValue + (endValue - startValue) * easing(pos)));
onChange(startValue + (endValue - startValue) * easing(pos));
if (time > finish || abort()) {
clearInterval(interval);
options.onComplete && options.onComplete();
@ -1874,6 +1871,7 @@ fabric.Observable = {
fabric.util.animate = animate;
})();
(function() {
var slice = Array.prototype.slice;
@ -10659,6 +10657,12 @@ fabric.util.object.extend(fabric.Canvas.prototype, {
* @param {Function} callback Callback is invoked when all filters have been applied and new image is generated
*/
applyFilters: function(callback) {
if (this.filters.length === 0) {
this.setElement(this._originalImage);
callback && callback();
return;
}
var isLikelyNode = typeof Buffer !== 'undefined' && typeof window === 'undefined',
imgEl = this._originalImage,

View file

@ -1,7 +1,7 @@
{
"name": "fabric",
"description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.",
"version": "0.6.7",
"version": "0.6.8",
"author": "Juriy Zaytsev <kangax@gmail.com>",
"keywords": ["canvas", "graphic", "graphics", "SVG", "node-canvas", "parser", "HTML5", "object model"],
"repository": "git://github.com/kangax/fabric.js",

2
site

@ -1 +1 @@
Subproject commit 642a7a2bc0d939724c06c1b77a0ee12eee7bb63f
Subproject commit 62125d164e36c0effee33afca6fd9e83bbb7d5c8

View file

@ -240,6 +240,12 @@
* @param {Function} callback Callback is invoked when all filters have been applied and new image is generated
*/
applyFilters: function(callback) {
if (this.filters.length === 0) {
this.setElement(this._originalImage);
callback && callback();
return;
}
var isLikelyNode = typeof Buffer !== 'undefined' && typeof window === 'undefined',
imgEl = this._originalImage,