mirror of
https://github.com/konvajs/konva.git
synced 2026-03-03 16:58:33 +08:00
moved UA to Global namespace, and fixed scope issue in _drawChildren that was preventing nested draws from working correctly
This commit is contained in:
@@ -235,10 +235,9 @@
|
|||||||
return arr;
|
return arr;
|
||||||
},
|
},
|
||||||
_setChildrenIndices: function() {
|
_setChildrenIndices: function() {
|
||||||
var children = this.children, len = children.length;
|
this.children.each(function(child, n) {
|
||||||
for(var n = 0; n < len; n++) {
|
child.index = n;
|
||||||
children[n].index = n;
|
});
|
||||||
}
|
|
||||||
},
|
},
|
||||||
drawScene: function(canvas) {
|
drawScene: function(canvas) {
|
||||||
var layer = this.getLayer(),
|
var layer = this.getLayer(),
|
||||||
@@ -261,12 +260,9 @@
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
_drawChildren: function(canvas) {
|
_drawChildren: function(canvas) {
|
||||||
var children = this.children;
|
this.children.each(function(child) {
|
||||||
len = children.length;
|
child.drawScene(canvas);
|
||||||
|
});
|
||||||
for(n = 0; n < len; n++) {
|
|
||||||
children[n].drawScene(canvas);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
drawHit: function() {
|
drawHit: function() {
|
||||||
var hasClip = this.getClipWidth() && this.getClipHeight() && this.nodeType !== 'Stage',
|
var hasClip = this.getClipWidth() && this.getClipHeight() && this.nodeType !== 'Stage',
|
||||||
|
|||||||
@@ -49,6 +49,23 @@ var Kinetic = {};
|
|||||||
dblClickWindow: 400,
|
dblClickWindow: 400,
|
||||||
pixelRatio: undefined,
|
pixelRatio: undefined,
|
||||||
|
|
||||||
|
// user agent
|
||||||
|
UA: (function() {
|
||||||
|
var ua = navigator.userAgent.toLowerCase(),
|
||||||
|
// jQuery UA regex
|
||||||
|
match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
|
||||||
|
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
|
||||||
|
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
|
||||||
|
/(msie) ([\w.]+)/.exec( ua ) ||
|
||||||
|
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
|
||||||
|
[];
|
||||||
|
|
||||||
|
return {
|
||||||
|
browser: match[ 1 ] || '',
|
||||||
|
version: match[ 2 ] || '0'
|
||||||
|
};
|
||||||
|
})(),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace Filters
|
* @namespace Filters
|
||||||
* @memberof Kinetic
|
* @memberof Kinetic
|
||||||
|
|||||||
22
src/Util.js
22
src/Util.js
@@ -253,24 +253,6 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* jQuery UA
|
|
||||||
*/
|
|
||||||
Kinetic.UA = (function() {
|
|
||||||
var ua = navigator.userAgent.toLowerCase(),
|
|
||||||
match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
|
|
||||||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
|
|
||||||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
|
|
||||||
/(msie) ([\w.]+)/.exec( ua ) ||
|
|
||||||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
|
|
||||||
[];
|
|
||||||
|
|
||||||
return {
|
|
||||||
browser: match[ 1 ] || '',
|
|
||||||
version: match[ 2 ] || '0'
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
// CONSTANTS
|
// CONSTANTS
|
||||||
var CANVAS = 'canvas',
|
var CANVAS = 'canvas',
|
||||||
CONTEXT_2D = '2d',
|
CONTEXT_2D = '2d',
|
||||||
@@ -589,8 +571,8 @@
|
|||||||
canvas = document.createElement(CANVAS);
|
canvas = document.createElement(CANVAS);
|
||||||
canvas.width = arg.width;
|
canvas.width = arg.width;
|
||||||
canvas.height = arg.height;
|
canvas.height = arg.height;
|
||||||
context = canvas.getContext(CONTEXT_2D);
|
_context = canvas.getContext(CONTEXT_2D);
|
||||||
context.putImageData(arg, 0, 0);
|
_context.putImageData(arg, 0, 0);
|
||||||
dataUrl = canvas.toDataURL();
|
dataUrl = canvas.toDataURL();
|
||||||
imageObj = new Image();
|
imageObj = new Image();
|
||||||
imageObj.onload = function() {
|
imageObj.onload = function() {
|
||||||
|
|||||||
@@ -51,6 +51,8 @@
|
|||||||
cropHeight = this.getCropHeight(),
|
cropHeight = this.getCropHeight(),
|
||||||
image;
|
image;
|
||||||
|
|
||||||
|
//TODO: this logic needs to hook int othe new caching system
|
||||||
|
|
||||||
// if a filter is set, and the filter needs to be updated, reapply
|
// if a filter is set, and the filter needs to be updated, reapply
|
||||||
if (this.getFilter() && this._applyFilter) {
|
if (this.getFilter() && this._applyFilter) {
|
||||||
this.applyFilter();
|
this.applyFilter();
|
||||||
|
|||||||
@@ -2138,8 +2138,6 @@ suite('Node', function() {
|
|||||||
layer.add(group);
|
layer.add(group);
|
||||||
stage.add(layer);
|
stage.add(layer);
|
||||||
|
|
||||||
var startDataUrl = layer.toDataURL();
|
|
||||||
|
|
||||||
assert.equal(triangle.getId(), 'myTriangle');
|
assert.equal(triangle.getId(), 'myTriangle');
|
||||||
|
|
||||||
var expectedJson = '{"attrs":{"width":578,"height":200},"className":"Stage","children":[{"attrs":{},"className":"Layer","children":[{"attrs":{},"className":"Group","children":[{"attrs":{"fill":"#00D2FF","stroke":"black","strokeWidth":4,"id":"myTriangle"},"className":"Shape"}]}]}]}';
|
var expectedJson = '{"attrs":{"width":578,"height":200},"className":"Stage","children":[{"attrs":{},"className":"Layer","children":[{"attrs":{},"className":"Group","children":[{"attrs":{"fill":"#00D2FF","stroke":"black","strokeWidth":4,"id":"myTriangle"},"className":"Shape"}]}]}]}';
|
||||||
|
|||||||
Reference in New Issue
Block a user