Comparing version 3.0.0-beta4 to 3.0.0-beta5
@@ -214,3 +214,3 @@ /** | ||
var child = children[i]; | ||
cb.call(context, child); | ||
cb.call(context, child, i); | ||
} | ||
@@ -217,0 +217,0 @@ return this; |
@@ -67,2 +67,8 @@ /** | ||
return function (m) { | ||
// In case usage like this | ||
// el.getBoundingRect().applyTransform(el.transform) | ||
// And element has no transform | ||
if (!m) { | ||
return; | ||
} | ||
min[0] = this.x; | ||
@@ -69,0 +75,0 @@ min[1] = this.y; |
@@ -13,2 +13,7 @@ /** | ||
var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener; | ||
function getBoundingClientRect(el) { | ||
// BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect | ||
return el.getBoundingClientRect ? el.getBoundingClientRect() : { left: 0, top: 0}; | ||
} | ||
/** | ||
@@ -42,14 +47,7 @@ * 如果存在第三方嵌入的一些dom触发的事件,或touch事件,需要转换一下事件坐标 | ||
var elLeft = 0; | ||
var elTop = 0; | ||
while (el.offsetParent) { | ||
elLeft += el.offsetLeft; | ||
elTop += el.offsetTop; | ||
el = el.offsetParent; | ||
} | ||
e.zrX = mouseX - elLeft; | ||
e.zrY = mouseY - elTop; | ||
var box = getBoundingClientRect(el); | ||
var top = box.top + (window.pageYOffset || el.scrollTop) - (el.clientTop || 0); | ||
var left = box.left + (window.pageXOffset || el.scrollLeft) - (el.clientLeft || 0); | ||
e.zrX = mouseX - left; | ||
e.zrY = mouseY - top; | ||
e.zrDelta = (e.wheelDelta) ? e.wheelDelta / 120 : -(e.detail || 0) / 3; | ||
@@ -62,3 +60,3 @@ } | ||
if (touch) { | ||
var rBounding = el.getBoundingClientRect(); | ||
var rBounding = getBoundingClientRect(el); | ||
// touch事件坐标是全屏的~ | ||
@@ -65,0 +63,0 @@ e.zrX = touch.clientX - rBounding.left; |
@@ -25,6 +25,5 @@ /** | ||
* @param {*} source | ||
* @param {boolean} [deep=false] | ||
* @return {*} 拷贝后的新对象 | ||
*/ | ||
function clone(source, deep) { | ||
function clone(source) { | ||
if (typeof source == 'object' && source !== null) { | ||
@@ -35,3 +34,3 @@ var result = source; | ||
for (var i = 0, len = source.length; i < len; i++) { | ||
result[i] = deep ? clone(source[i], deep) : source[i]; | ||
result[i] = clone(source[i]); | ||
} | ||
@@ -47,3 +46,3 @@ } | ||
if (source.hasOwnProperty(key)) { | ||
result[key] = deep ? clone(source[key], deep) : source[key]; | ||
result[key] = clone(source[key]); | ||
} | ||
@@ -195,8 +194,9 @@ } | ||
* @param {Object|Function} sorce | ||
* @param {boolean} overlay | ||
*/ | ||
function mixin(target, source) { | ||
function mixin(target, source, overlay) { | ||
target = 'prototype' in target ? target.prototype : target; | ||
source = 'prototype' in source ? source.prototype : source; | ||
defaults(target, source); | ||
defaults(target, source, overlay); | ||
} | ||
@@ -435,2 +435,23 @@ | ||
/** | ||
* @memberOf module:zrender/tool/util | ||
* @param {Array} arr | ||
* @param {number} startIndex | ||
* @param {number} endIndex | ||
* @return {Array} | ||
*/ | ||
function slice() { | ||
return Function.call.apply(nativeSlice, arguments); | ||
} | ||
/** | ||
* @param {boolean} condition | ||
* @param {string} message | ||
*/ | ||
function assert(condition, message) { | ||
if (!condition) { | ||
throw new Error(message); | ||
} | ||
} | ||
var util = { | ||
@@ -447,2 +468,3 @@ inherits: inherits, | ||
indexOf: indexOf, | ||
slice: slice, | ||
find: find, | ||
@@ -463,2 +485,3 @@ isArrayLike: isArrayLike, | ||
retrieve: retrieve, | ||
assert: assert, | ||
noop: function () {} | ||
@@ -465,0 +488,0 @@ }; |
@@ -105,4 +105,12 @@ /** | ||
/** | ||
* 是否正在拖拽 | ||
* @name module:/zrender/graphic/Displayable#draggable | ||
* @type {boolean} | ||
* @default false | ||
*/ | ||
dragging: false, | ||
/** | ||
* 是否相应鼠标事件 | ||
* @name module:/zrender/graphic/Displayable#hoverable | ||
* @name module:/zrender/graphic/Displayable#silent | ||
* @type {boolean} | ||
@@ -127,2 +135,9 @@ * @default false | ||
/** | ||
* If hover area is bounding rect | ||
* @name module:/zrender/graphic/Displayable#rectHover | ||
* @type {string} | ||
*/ | ||
rectHover: false, | ||
beforeBrush: function (ctx) {}, | ||
@@ -129,0 +144,0 @@ |
@@ -35,10 +35,10 @@ /** | ||
var image; | ||
// style.image is an HTMLImageElement or HTMLCanvasElement | ||
if (zrUtil.isDom(src)) { | ||
image = src; | ||
} | ||
// style.image is a url string | ||
else { | ||
if (typeof src === 'string') { | ||
image = this._image; | ||
} | ||
// style.image is an HTMLImageElement or HTMLCanvasElement or Canvas | ||
else { | ||
image = src; | ||
} | ||
// FIXME Case create many images with src | ||
@@ -64,2 +64,3 @@ if (!image && src) { | ||
this._image = image; | ||
return; | ||
} | ||
@@ -70,3 +71,3 @@ else { | ||
// Image is not complete finish, add to pending list | ||
if (!image.width || !image.height || !image.complete) { | ||
if (!image.width || !image.height) { | ||
cachedImgObj.pending.push(this); | ||
@@ -77,9 +78,10 @@ return; | ||
} | ||
else if (image) { | ||
if (image) { | ||
// 图片已经加载完成 | ||
if (image.nodeName.toUpperCase() == 'IMG') { | ||
if (!image.complete) { | ||
return; | ||
} | ||
} | ||
// if (image.nodeName.toUpperCase() == 'IMG') { | ||
// if (!image.complete) { | ||
// return; | ||
// } | ||
// } | ||
// Else is canvas | ||
@@ -86,0 +88,0 @@ |
@@ -73,5 +73,4 @@ /** | ||
y = rect.y + parsePercent(textPosition[1], rect.height); | ||
ctx.textAlign = align; | ||
ctx.textBaseline = baseline; | ||
align = align || 'left'; | ||
baseline = baseline || 'top'; | ||
} | ||
@@ -84,7 +83,10 @@ else { | ||
y = res.y; | ||
// Draw text | ||
ctx.textAlign = res.textAlign; | ||
ctx.textBaseline = res.textBaseline; | ||
// Default align and baseline when has textPosition | ||
align = align || res.textAlign; | ||
baseline = baseline || res.textBaseline; | ||
} | ||
ctx.textAlign = align; | ||
ctx.textBaseline = baseline; | ||
var textFill = style.textFill; | ||
@@ -91,0 +93,0 @@ var textStroke = style.textStroke; |
@@ -80,3 +80,3 @@ /** | ||
this.root.style.cursor = hovered ? hovered.cursor : 'default'; | ||
this.root.style.cursor = hovered ? hovered.cursor : this._defaultCursorStyle; | ||
// Mouse out on previous hovered element | ||
@@ -191,3 +191,3 @@ if (lastHovered && hovered !== lastHovered && lastHovered.__zr) { | ||
// Find hover again to avoid click event is dispatched manually. Or click is triggered without mouseover | ||
var hovered = this._hovered || this._findHover(event.zrX, event.zrY, null); | ||
var hovered = this._findHover(event.zrX, event.zrY, null); | ||
this._dispatchProxy(hovered, name, event); | ||
@@ -267,2 +267,6 @@ }; | ||
*/ | ||
this._defaultCursorStyle = 'default' | ||
/** | ||
* @private | ||
*/ | ||
this._gestureMgr = new GestureMgr(); | ||
@@ -335,2 +339,10 @@ | ||
/** | ||
* 设置默认的cursor style | ||
* @param {string} cursorStyle 例如 crosshair | ||
*/ | ||
setDefaultCursorStyle: function (cursorStyle) { | ||
this._defaultCursorStyle = cursorStyle; | ||
}, | ||
/** | ||
* 事件分发代理 | ||
@@ -366,3 +378,4 @@ * | ||
// 分发事件到用户自定义层 | ||
this.painter.eachOtherLayer(function (layer) { | ||
// 用户有可能在全局 click 事件中 dispose,所以需要判断下 painter 是否存在 | ||
this.painter && this.painter.eachOtherLayer(function (layer) { | ||
if (typeof(layer[eventHandler]) == 'function') { | ||
@@ -398,3 +411,3 @@ layer[eventHandler].call(layer, eventPacket); | ||
function isHover(displayable, x, y) { | ||
if (displayable.contain(x, y)) { | ||
if (displayable[displayable.rectHover ? 'rectContain' : 'contain'](x, y)) { | ||
var p = displayable.parent; | ||
@@ -401,0 +414,0 @@ while (p) { |
@@ -214,3 +214,3 @@ /** | ||
var child = children[i]; | ||
cb.call(context, child); | ||
cb.call(context, child, i); | ||
} | ||
@@ -217,0 +217,0 @@ return this; |
@@ -67,2 +67,8 @@ /** | ||
return function (m) { | ||
// In case usage like this | ||
// el.getBoundingRect().applyTransform(el.transform) | ||
// And element has no transform | ||
if (!m) { | ||
return; | ||
} | ||
min[0] = this.x; | ||
@@ -69,0 +75,0 @@ min[1] = this.y; |
@@ -13,2 +13,7 @@ /** | ||
var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener; | ||
function getBoundingClientRect(el) { | ||
// BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect | ||
return el.getBoundingClientRect ? el.getBoundingClientRect() : { left: 0, top: 0}; | ||
} | ||
/** | ||
@@ -42,14 +47,7 @@ * 如果存在第三方嵌入的一些dom触发的事件,或touch事件,需要转换一下事件坐标 | ||
var elLeft = 0; | ||
var elTop = 0; | ||
while (el.offsetParent) { | ||
elLeft += el.offsetLeft; | ||
elTop += el.offsetTop; | ||
el = el.offsetParent; | ||
} | ||
e.zrX = mouseX - elLeft; | ||
e.zrY = mouseY - elTop; | ||
var box = getBoundingClientRect(el); | ||
var top = box.top + (window.pageYOffset || el.scrollTop) - (el.clientTop || 0); | ||
var left = box.left + (window.pageXOffset || el.scrollLeft) - (el.clientLeft || 0); | ||
e.zrX = mouseX - left; | ||
e.zrY = mouseY - top; | ||
e.zrDelta = (e.wheelDelta) ? e.wheelDelta / 120 : -(e.detail || 0) / 3; | ||
@@ -62,3 +60,3 @@ } | ||
if (touch) { | ||
var rBounding = el.getBoundingClientRect(); | ||
var rBounding = getBoundingClientRect(el); | ||
// touch事件坐标是全屏的~ | ||
@@ -65,0 +63,0 @@ e.zrX = touch.clientX - rBounding.left; |
@@ -25,6 +25,5 @@ /** | ||
* @param {*} source | ||
* @param {boolean} [deep=false] | ||
* @return {*} 拷贝后的新对象 | ||
*/ | ||
function clone(source, deep) { | ||
function clone(source) { | ||
if (typeof source == 'object' && source !== null) { | ||
@@ -35,3 +34,3 @@ var result = source; | ||
for (var i = 0, len = source.length; i < len; i++) { | ||
result[i] = deep ? clone(source[i], deep) : source[i]; | ||
result[i] = clone(source[i]); | ||
} | ||
@@ -47,3 +46,3 @@ } | ||
if (source.hasOwnProperty(key)) { | ||
result[key] = deep ? clone(source[key], deep) : source[key]; | ||
result[key] = clone(source[key]); | ||
} | ||
@@ -195,8 +194,9 @@ } | ||
* @param {Object|Function} sorce | ||
* @param {boolean} overlay | ||
*/ | ||
function mixin(target, source) { | ||
function mixin(target, source, overlay) { | ||
target = 'prototype' in target ? target.prototype : target; | ||
source = 'prototype' in source ? source.prototype : source; | ||
defaults(target, source); | ||
defaults(target, source, overlay); | ||
} | ||
@@ -435,2 +435,23 @@ | ||
/** | ||
* @memberOf module:zrender/tool/util | ||
* @param {Array} arr | ||
* @param {number} startIndex | ||
* @param {number} endIndex | ||
* @return {Array} | ||
*/ | ||
function slice() { | ||
return Function.call.apply(nativeSlice, arguments); | ||
} | ||
/** | ||
* @param {boolean} condition | ||
* @param {string} message | ||
*/ | ||
function assert(condition, message) { | ||
if (!condition) { | ||
throw new Error(message); | ||
} | ||
} | ||
var util = { | ||
@@ -447,2 +468,3 @@ inherits: inherits, | ||
indexOf: indexOf, | ||
slice: slice, | ||
find: find, | ||
@@ -463,2 +485,3 @@ isArrayLike: isArrayLike, | ||
retrieve: retrieve, | ||
assert: assert, | ||
noop: function () {} | ||
@@ -465,0 +488,0 @@ }; |
@@ -105,4 +105,12 @@ /** | ||
/** | ||
* 是否正在拖拽 | ||
* @name module:/zrender/graphic/Displayable#draggable | ||
* @type {boolean} | ||
* @default false | ||
*/ | ||
dragging: false, | ||
/** | ||
* 是否相应鼠标事件 | ||
* @name module:/zrender/graphic/Displayable#hoverable | ||
* @name module:/zrender/graphic/Displayable#silent | ||
* @type {boolean} | ||
@@ -127,2 +135,9 @@ * @default false | ||
/** | ||
* If hover area is bounding rect | ||
* @name module:/zrender/graphic/Displayable#rectHover | ||
* @type {string} | ||
*/ | ||
rectHover: false, | ||
beforeBrush: function (ctx) {}, | ||
@@ -129,0 +144,0 @@ |
@@ -35,10 +35,10 @@ /** | ||
var image; | ||
// style.image is an HTMLImageElement or HTMLCanvasElement | ||
if (zrUtil.isDom(src)) { | ||
image = src; | ||
} | ||
// style.image is a url string | ||
else { | ||
if (typeof src === 'string') { | ||
image = this._image; | ||
} | ||
// style.image is an HTMLImageElement or HTMLCanvasElement or Canvas | ||
else { | ||
image = src; | ||
} | ||
// FIXME Case create many images with src | ||
@@ -64,2 +64,3 @@ if (!image && src) { | ||
this._image = image; | ||
return; | ||
} | ||
@@ -70,3 +71,3 @@ else { | ||
// Image is not complete finish, add to pending list | ||
if (!image.width || !image.height || !image.complete) { | ||
if (!image.width || !image.height) { | ||
cachedImgObj.pending.push(this); | ||
@@ -77,9 +78,10 @@ return; | ||
} | ||
else if (image) { | ||
if (image) { | ||
// 图片已经加载完成 | ||
if (image.nodeName.toUpperCase() == 'IMG') { | ||
if (!image.complete) { | ||
return; | ||
} | ||
} | ||
// if (image.nodeName.toUpperCase() == 'IMG') { | ||
// if (!image.complete) { | ||
// return; | ||
// } | ||
// } | ||
// Else is canvas | ||
@@ -86,0 +88,0 @@ |
@@ -73,5 +73,4 @@ /** | ||
y = rect.y + parsePercent(textPosition[1], rect.height); | ||
ctx.textAlign = align; | ||
ctx.textBaseline = baseline; | ||
align = align || 'left'; | ||
baseline = baseline || 'top'; | ||
} | ||
@@ -84,7 +83,10 @@ else { | ||
y = res.y; | ||
// Draw text | ||
ctx.textAlign = res.textAlign; | ||
ctx.textBaseline = res.textBaseline; | ||
// Default align and baseline when has textPosition | ||
align = align || res.textAlign; | ||
baseline = baseline || res.textBaseline; | ||
} | ||
ctx.textAlign = align; | ||
ctx.textBaseline = baseline; | ||
var textFill = style.textFill; | ||
@@ -91,0 +93,0 @@ var textStroke = style.textStroke; |
@@ -80,3 +80,3 @@ /** | ||
this.root.style.cursor = hovered ? hovered.cursor : 'default'; | ||
this.root.style.cursor = hovered ? hovered.cursor : this._defaultCursorStyle; | ||
// Mouse out on previous hovered element | ||
@@ -191,3 +191,3 @@ if (lastHovered && hovered !== lastHovered && lastHovered.__zr) { | ||
// Find hover again to avoid click event is dispatched manually. Or click is triggered without mouseover | ||
var hovered = this._hovered || this._findHover(event.zrX, event.zrY, null); | ||
var hovered = this._findHover(event.zrX, event.zrY, null); | ||
this._dispatchProxy(hovered, name, event); | ||
@@ -267,2 +267,6 @@ }; | ||
*/ | ||
this._defaultCursorStyle = 'default' | ||
/** | ||
* @private | ||
*/ | ||
this._gestureMgr = new GestureMgr(); | ||
@@ -335,2 +339,10 @@ | ||
/** | ||
* 设置默认的cursor style | ||
* @param {string} cursorStyle 例如 crosshair | ||
*/ | ||
setDefaultCursorStyle: function (cursorStyle) { | ||
this._defaultCursorStyle = cursorStyle; | ||
}, | ||
/** | ||
* 事件分发代理 | ||
@@ -366,3 +378,4 @@ * | ||
// 分发事件到用户自定义层 | ||
this.painter.eachOtherLayer(function (layer) { | ||
// 用户有可能在全局 click 事件中 dispose,所以需要判断下 painter 是否存在 | ||
this.painter && this.painter.eachOtherLayer(function (layer) { | ||
if (typeof(layer[eventHandler]) == 'function') { | ||
@@ -398,3 +411,3 @@ layer[eventHandler].call(layer, eventPacket); | ||
function isHover(displayable, x, y) { | ||
if (displayable.contain(x, y)) { | ||
if (displayable[displayable.rectHover ? 'rectContain' : 'contain'](x, y)) { | ||
var p = displayable.parent; | ||
@@ -401,0 +414,0 @@ while (p) { |
@@ -25,2 +25,3 @@ // TODO Draggable for group | ||
this._draggingTarget = draggingTarget; | ||
draggingTarget.dragging = true; | ||
this._x = e.offsetX; | ||
@@ -45,3 +46,3 @@ this._y = e.offsetY; | ||
draggingTarget.drift(dx, dy); | ||
draggingTarget.drift(dx, dy, e); | ||
this._dispatchProxy(draggingTarget, 'drag', e.event); | ||
@@ -65,4 +66,10 @@ | ||
_dragEnd: function (e) { | ||
this._dispatchProxy(this._draggingTarget, 'dragend', e.event); | ||
var draggingTarget = this._draggingTarget; | ||
if (draggingTarget) { | ||
draggingTarget.dragging = false; | ||
} | ||
this._dispatchProxy(draggingTarget, 'dragend', e.event); | ||
if (this._dropTarget) { | ||
@@ -75,2 +82,3 @@ this._dispatchProxy(this._dropTarget, 'drop', e.event); | ||
} | ||
}; | ||
@@ -77,0 +85,0 @@ |
@@ -204,2 +204,9 @@ /** | ||
/** | ||
* If painter use a single canvas | ||
* @return {boolean} | ||
*/ | ||
isSingleCanvas: function () { | ||
return this._singleCanvas; | ||
}, | ||
/** | ||
* @return {HTMLDivElement} | ||
@@ -210,2 +217,3 @@ */ | ||
}, | ||
/** | ||
@@ -604,18 +612,17 @@ * 刷新 | ||
/** | ||
* 图像导出 | ||
* @param {string} type | ||
* @param {string} [backgroundColor='#fff'] 背景色 | ||
* @return {string} 图片的Base64 url | ||
* Get canvas which has all thing rendered | ||
* @param {Object} opts | ||
* @param {string} [opts.backgroundColor] | ||
*/ | ||
toDataURL: function (type, backgroundColor, args) { | ||
getRenderedCanvas: function (opts) { | ||
opts = opts || {}; | ||
if (this._singleCanvas) { | ||
return this._layers[0].toDataURL(type, args); | ||
return this._layers[0].dom; | ||
} | ||
var imageLayer = new Layer('image', this, this.dpr); | ||
this._domRoot.appendChild(imageLayer.dom); | ||
var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr); | ||
imageLayer.initContext(); | ||
var ctx = imageLayer.ctx; | ||
imageLayer.clearColor = backgroundColor || '#fff'; | ||
imageLayer.clearColor = opts.backgroundColor; | ||
imageLayer.clear(); | ||
@@ -628,17 +635,11 @@ | ||
if (!el.invisible) { | ||
if (!el.onbrush // 没有onbrush | ||
// 有onbrush并且调用执行返回false或undefined则继续粉刷 | ||
|| (el.onbrush && !el.onbrush(ctx, false)) | ||
) { | ||
el.brush(ctx, false); | ||
} | ||
el.beforeBrush && el.beforeBrush(ctx); | ||
// TODO Check image cross origin | ||
el.brush(ctx, false); | ||
el.afterBrush && el.afterBrush(ctx); | ||
} | ||
} | ||
var image = imageLayer.dom.toDataURL(type, args); | ||
ctx = null; | ||
this._domRoot.removeChild(imageLayer.dom); | ||
return image; | ||
return imageLayer.dom; | ||
}, | ||
/** | ||
@@ -645,0 +646,0 @@ * 获取绘图区域宽度 |
@@ -366,4 +366,4 @@ /** | ||
var rightIndex = Math.ceil(value); | ||
var leftColor = parse(colors[leftIndex]); | ||
var rightColor = parse(colors[rightIndex]); | ||
var leftColor = colors[leftIndex]; | ||
var rightColor = colors[rightIndex]; | ||
var dv = value - leftIndex; | ||
@@ -370,0 +370,0 @@ out[0] = clampCssByte(lerp(leftColor[0], rightColor[0], dv)); |
@@ -817,2 +817,5 @@ // http://www.w3.org/TR/NOTE-VML | ||
y = rect.y + textPosition[1]; | ||
align = align || 'left'; | ||
baseline = baseline || 'top'; | ||
} | ||
@@ -825,4 +828,6 @@ else { | ||
y = res.y; | ||
align = res.textAlign; | ||
baseline = res.textBaseline; | ||
// Default align and baseline when has textPosition | ||
align = align || res.textAlign; | ||
baseline = baseline || res.textBaseline; | ||
} | ||
@@ -829,0 +834,0 @@ } |
@@ -287,2 +287,10 @@ /*! | ||
/** | ||
* 设置默认的cursor style | ||
* @param {string} cursorStyle 例如 crosshair | ||
*/ | ||
setDefaultCursorStyle: function (cursorStyle) { | ||
this.handler.setDefaultCursorStyle(cursorStyle); | ||
}, | ||
/** | ||
* 事件绑定 | ||
@@ -289,0 +297,0 @@ * |
@@ -25,2 +25,3 @@ // TODO Draggable for group | ||
this._draggingTarget = draggingTarget; | ||
draggingTarget.dragging = true; | ||
this._x = e.offsetX; | ||
@@ -45,3 +46,3 @@ this._y = e.offsetY; | ||
draggingTarget.drift(dx, dy); | ||
draggingTarget.drift(dx, dy, e); | ||
this._dispatchProxy(draggingTarget, 'drag', e.event); | ||
@@ -65,4 +66,10 @@ | ||
_dragEnd: function (e) { | ||
this._dispatchProxy(this._draggingTarget, 'dragend', e.event); | ||
var draggingTarget = this._draggingTarget; | ||
if (draggingTarget) { | ||
draggingTarget.dragging = false; | ||
} | ||
this._dispatchProxy(draggingTarget, 'dragend', e.event); | ||
if (this._dropTarget) { | ||
@@ -75,2 +82,3 @@ this._dispatchProxy(this._dropTarget, 'drop', e.event); | ||
} | ||
}; | ||
@@ -77,0 +85,0 @@ |
{ | ||
"name": "zrenderjs", | ||
"description": "canvas/svg/vml graph lib。一个轻量级的Canvas类库,MVC封装,数据驱动,提供类Dom事件模型,让canvas绘图大不同!", | ||
"version": "3.0.0-beta4", | ||
"version": "3.0.0-beta5", | ||
"main": "zrender", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -204,2 +204,9 @@ /** | ||
/** | ||
* If painter use a single canvas | ||
* @return {boolean} | ||
*/ | ||
isSingleCanvas: function () { | ||
return this._singleCanvas; | ||
}, | ||
/** | ||
* @return {HTMLDivElement} | ||
@@ -210,2 +217,3 @@ */ | ||
}, | ||
/** | ||
@@ -604,18 +612,17 @@ * 刷新 | ||
/** | ||
* 图像导出 | ||
* @param {string} type | ||
* @param {string} [backgroundColor='#fff'] 背景色 | ||
* @return {string} 图片的Base64 url | ||
* Get canvas which has all thing rendered | ||
* @param {Object} opts | ||
* @param {string} [opts.backgroundColor] | ||
*/ | ||
toDataURL: function (type, backgroundColor, args) { | ||
getRenderedCanvas: function (opts) { | ||
opts = opts || {}; | ||
if (this._singleCanvas) { | ||
return this._layers[0].toDataURL(type, args); | ||
return this._layers[0].dom; | ||
} | ||
var imageLayer = new Layer('image', this, this.dpr); | ||
this._domRoot.appendChild(imageLayer.dom); | ||
var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr); | ||
imageLayer.initContext(); | ||
var ctx = imageLayer.ctx; | ||
imageLayer.clearColor = backgroundColor || '#fff'; | ||
imageLayer.clearColor = opts.backgroundColor; | ||
imageLayer.clear(); | ||
@@ -628,17 +635,11 @@ | ||
if (!el.invisible) { | ||
if (!el.onbrush // 没有onbrush | ||
// 有onbrush并且调用执行返回false或undefined则继续粉刷 | ||
|| (el.onbrush && !el.onbrush(ctx, false)) | ||
) { | ||
el.brush(ctx, false); | ||
} | ||
el.beforeBrush && el.beforeBrush(ctx); | ||
// TODO Check image cross origin | ||
el.brush(ctx, false); | ||
el.afterBrush && el.afterBrush(ctx); | ||
} | ||
} | ||
var image = imageLayer.dom.toDataURL(type, args); | ||
ctx = null; | ||
this._domRoot.removeChild(imageLayer.dom); | ||
return image; | ||
return imageLayer.dom; | ||
}, | ||
/** | ||
@@ -645,0 +646,0 @@ * 获取绘图区域宽度 |
@@ -366,4 +366,4 @@ /** | ||
var rightIndex = Math.ceil(value); | ||
var leftColor = parse(colors[leftIndex]); | ||
var rightColor = parse(colors[rightIndex]); | ||
var leftColor = colors[leftIndex]; | ||
var rightColor = colors[rightIndex]; | ||
var dv = value - leftIndex; | ||
@@ -370,0 +370,0 @@ out[0] = clampCssByte(lerp(leftColor[0], rightColor[0], dv)); |
@@ -817,2 +817,5 @@ // http://www.w3.org/TR/NOTE-VML | ||
y = rect.y + textPosition[1]; | ||
align = align || 'left'; | ||
baseline = baseline || 'top'; | ||
} | ||
@@ -825,4 +828,6 @@ else { | ||
y = res.y; | ||
align = res.textAlign; | ||
baseline = res.textBaseline; | ||
// Default align and baseline when has textPosition | ||
align = align || res.textAlign; | ||
baseline = baseline || res.textBaseline; | ||
} | ||
@@ -829,0 +834,0 @@ } |
@@ -287,2 +287,10 @@ /*! | ||
/** | ||
* 设置默认的cursor style | ||
* @param {string} cursorStyle 例如 crosshair | ||
*/ | ||
setDefaultCursorStyle: function (cursorStyle) { | ||
this.handler.setDefaultCursorStyle(cursorStyle); | ||
}, | ||
/** | ||
* 事件绑定 | ||
@@ -289,0 +297,0 @@ * |
2545746
62350