Prevent errors in FF when rendering non-ready patterns

This commit is contained in:
kangax 2013-10-29 19:44:19 +01:00
parent 9ff21bf531
commit f53559773f
5 changed files with 21 additions and 6 deletions

5
dist/all.js vendored
View file

@ -6437,6 +6437,11 @@ fabric.Pattern = fabric.util.createClass(/** @lends fabric.Pattern.prototype */
*/
toLive: function(ctx) {
var source = typeof this.source === 'function' ? this.source() : this.source;
// if an image
if (typeof source.src !== 'undefined') {
if (!source.complete) return '';
if (source.naturalWidth === 0 || source.naturalHeight === 0) return '';
}
return ctx.createPattern(source, this.repeat);
}
});

12
dist/all.min.js vendored

File diff suppressed because one or more lines are too long

BIN
dist/all.min.js.gz vendored

Binary file not shown.

5
dist/all.require.js vendored
View file

@ -6437,6 +6437,11 @@ fabric.Pattern = fabric.util.createClass(/** @lends fabric.Pattern.prototype */
*/
toLive: function(ctx) {
var source = typeof this.source === 'function' ? this.source() : this.source;
// if an image
if (typeof source.src !== 'undefined') {
if (!source.complete) return '';
if (source.naturalWidth === 0 || source.naturalHeight === 0) return '';
}
return ctx.createPattern(source, this.repeat);
}
});

View file

@ -134,6 +134,11 @@ fabric.Pattern = fabric.util.createClass(/** @lends fabric.Pattern.prototype */
*/
toLive: function(ctx) {
var source = typeof this.source === 'function' ? this.source() : this.source;
// if an image
if (typeof source.src !== 'undefined') {
if (!source.complete) return '';
if (source.naturalWidth === 0 || source.naturalHeight === 0) return '';
}
return ctx.createPattern(source, this.repeat);
}
});