[OPENMEETINGS-1738] fabricjs version is updated
Project: http://git-wip-us.apache.org/repos/asf/openmeetings/repo Commit: http://git-wip-us.apache.org/repos/asf/openmeetings/commit/3511369f Tree: http://git-wip-us.apache.org/repos/asf/openmeetings/tree/3511369f Diff: http://git-wip-us.apache.org/repos/asf/openmeetings/diff/3511369f Branch: refs/heads/4.0.x Commit: 3511369f162314402a75bc530538769386d080af Parents: 50d6318 Author: Maxim Solodovnik <[email protected]> Authored: Thu Nov 23 08:51:11 2017 +0700 Committer: Maxim Solodovnik <[email protected]> Committed: Thu Nov 23 08:51:11 2017 +0700 ---------------------------------------------------------------------- .../apache/openmeetings/web/room/wb/fabric.js | 92 ++++++++++++++------ .../openmeetings/web/room/wb/fabric.min.js | 2 +- .../apache/openmeetings/web/room/wb/player.js | 4 +- .../apache/openmeetings/web/room/wb/wb-board.js | 7 +- 4 files changed, 75 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/openmeetings/blob/3511369f/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/fabric.js ---------------------------------------------------------------------- diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/fabric.js b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/fabric.js index d833782..a8931f7 100644 --- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/fabric.js +++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/wb/fabric.js @@ -2,7 +2,7 @@ /* build: `node build.js modules=ALL exclude=json,gestures minifier=uglifyjs` */ /*! Fabric.js Copyright 2008-2015, Printio (Juriy Zaytsev, Maxim Chernyak) */ -var fabric = fabric || { version: "1.7.19" }; +var fabric = fabric || { version: "1.7.20" }; if (typeof exports !== 'undefined') { exports.fabric = fabric; } @@ -8097,6 +8097,9 @@ fabric.BaseBrush = fabric.util.createClass(/** @lends fabric.BaseBrush.prototype * @param {fabric.Point} point Point to be added to points array */ _addPoint: function(point) { + if (this._points.length > 1 && point.eq(this._points[this._points.length - 1])) { + return; + } this._points.push(point); }, @@ -8173,9 +8176,13 @@ fabric.BaseBrush = fabric.util.createClass(/** @lends fabric.BaseBrush.prototype var path = [], i, width = this.width / 1000, p1 = new fabric.Point(points[0].x, points[0].y), p2 = new fabric.Point(points[1].x, points[1].y), - len = points.length; + len = points.length, multSignX, multSignY, manyPoints = len > 2; - path.push('M ', p1.x - width, ' ', p1.y, ' '); + if (manyPoints) { + multSignX = points[2].x < p2.x ? -1 : points[2].x === p2.x ? 0 : 1; + multSignY = points[2].y < p2.y ? -1 : points[2].y === p2.y ? 0 : 1; + } + path.push('M ', p1.x - multSignX * width, ' ', p1.y - multSignY * width, ' '); for (i = 1; i < len; i++) { if (!p1.eq(p2)) { var midPoint = p1.midPointFrom(p2); @@ -8189,7 +8196,11 @@ fabric.BaseBrush = fabric.util.createClass(/** @lends fabric.BaseBrush.prototype p2 = points[i + 1]; } } - path.push('L ', p1.x + width, ' ', p1.y, ' '); + if (manyPoints) { + multSignX = p1.x > points[i - 2].x ? 1 : p1.x === points[i - 2].x ? 0 : -1; + multSignY = p1.y > points[i - 2].y ? 1 : p1.y === points[i - 2].y ? 0 : -1; + } + path.push('L ', p1.x + multSignX * width, ' ', p1.y + multSignY * width); return path; }, @@ -12639,6 +12650,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati * Return the dimension and the zoom level needed to create a cache canvas * big enough to host the object to be cached. * @private + * @param {Object} dim.x width of object to be cached + * @param {Object} dim.y height of object to be cached * @return {Object}.width width of canvas * @return {Object}.height height of canvas * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache @@ -12647,8 +12660,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati _getCacheCanvasDimensions: function() { var zoom = this.canvas && this.canvas.getZoom() || 1, objectScale = this.getObjectScaling(), - dim = this._getNonTransformedDimensions(), retina = this.canvas && this.canvas._isRetinaScaling() ? fabric.devicePixelRatio : 1, + dim = this._getNonTransformedDimensions(), zoomX = objectScale.scaleX * zoom * retina, zoomY = objectScale.scaleY * zoom * retina, width = dim.x * zoomX, @@ -12657,7 +12670,9 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati width: width + ALIASING_LIMIT, height: height + ALIASING_LIMIT, zoomX: zoomX, - zoomY: zoomY + zoomY: zoomY, + x: dim.x, + y: dim.y }; }, @@ -12669,14 +12684,16 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati */ _updateCacheCanvas: function() { if (this.noScaleCache && this.canvas && this.canvas._currentTransform) { - var action = this.canvas._currentTransform.action; - if (action.slice && action.slice(0, 5) === 'scale') { + var target = this.canvas._currentTransform.target, + action = this.canvas._currentTransform.action; + if (this === target && action.slice && action.slice(0, 5) === 'scale') { return false; } } - var dims = this._limitCacheSize(this._getCacheCanvasDimensions()), + var canvas = this._cacheCanvas, + dims = this._limitCacheSize(this._getCacheCanvasDimensions()), minCacheSize = fabric.minCacheSideLimit, - width = dims.width, height = dims.height, + width = dims.width, height = dims.height, drawingWidth, drawingHeight, zoomX = dims.zoomX, zoomY = dims.zoomY, dimensionsChanged = width !== this.cacheWidth || height !== this.cacheHeight, zoomChanged = this.zoomX !== zoomX || this.zoomY !== zoomY, @@ -12690,21 +12707,23 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati canvasWidth > minCacheSize && canvasHeight > minCacheSize; shouldResizeCanvas = sizeGrowing || sizeShrinking; if (sizeGrowing) { - additionalWidth = (width * 0.1) & ~1; - additionalHeight = (height * 0.1) & ~1; + additionalWidth = width * 0.1; + additionalHeight = height * 0.1; } } if (shouldRedraw) { if (shouldResizeCanvas) { - this._cacheCanvas.width = Math.max(Math.ceil(width) + additionalWidth, minCacheSize); - this._cacheCanvas.height = Math.max(Math.ceil(height) + additionalHeight, minCacheSize); - this.cacheTranslationX = (width + additionalWidth) / 2; - this.cacheTranslationY = (height + additionalHeight) / 2; + canvas.width = Math.max(Math.ceil(width + additionalWidth), minCacheSize); + canvas.height = Math.max(Math.ceil(height + additionalHeight), minCacheSize); } else { this._cacheContext.setTransform(1, 0, 0, 1, 0, 0); - this._cacheContext.clearRect(0, 0, this._cacheCanvas.width, this._cacheCanvas.height); + this._cacheContext.clearRect(0, 0, canvas.width, canvas.height); } + drawingWidth = dims.x * zoomX / 2; + drawingHeight = dims.y * zoomY / 2; + this.cacheTranslationX = Math.round(canvas.width / 2 - drawingWidth) + drawingWidth; + this.cacheTranslationY = Math.round(canvas.height / 2 - drawingHeight) + drawingHeight; this.cacheWidth = width; this.cacheHeight = height; this._cacheContext.translate(this.cacheTranslationX, this.cacheTranslationY); @@ -12860,7 +12879,8 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati * @return {fabric.Object} thisArg */ _set: function(key, value) { - var shouldConstrainValue = (key === 'scaleX' || key === 'scaleY'); + var shouldConstrainValue = (key === 'scaleX' || key === 'scaleY'), + isChanged = this[key] !== value; if (shouldConstrainValue) { value = this._constrainScale(value); @@ -12882,14 +12902,14 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati this[key] = value; - if (this.cacheProperties.indexOf(key) > -1) { + if (isChanged && this.cacheProperties.indexOf(key) > -1) { if (this.group) { this.group.set('dirty', true); } this.dirty = true; } - if (this.group && this.stateProperties.indexOf(key) > -1) { + if (isChanged && this.group && this.stateProperties.indexOf(key) > -1) { this.group.set('dirty', true); } @@ -12982,6 +13002,7 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati this.drawCacheOnCanvas(ctx); } else { + this._removeCacheCanvas(); this.dirty = false; this.drawObject(ctx, noTransform); if (noTransform && this.objectCaching && this.statefullCache) { @@ -12993,7 +13014,16 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @lends fabric.Stati }, /** - * When returns `true`, force the object to have its own cache, even if it is inside a group + * Remove cacheCanvas and its dimensions from the objects + */ + _removeCacheCanvas: function() { + this._cacheCanvas = null; + this.cacheWidth = 0; + this.cacheHeight = 0; + }, + + /** + * When set to `true`, force the object to have its own cache, even if it is inside a group * it may be needed when your object behave in a particular way on the cache and always needs * its own isolated canvas to render correctly. * This function is created to be subclassed by custom classes. @@ -18437,6 +18467,7 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot // do not change coordinate of objects enclosed in a group, // because objects coordinate system have been group coodinate system already. this._updateObjectsCoords(true); + this._updateObjectsACoords(); } else { this._calcBounds(); @@ -18448,6 +18479,13 @@ fabric.util.object.extend(fabric.Object.prototype, /** @lends fabric.Object.prot this.saveCoords(); }, + _updateObjectsACoords: function() { + var ignoreZoom = true, skipAbsolute = true; + for (var i = this._objects.length; i--; ){ + this._objects[i].setCoords(ignoreZoom, skipAbsolute); + } + }, + /** * @private * @param {Boolean} [skipCoordsChange] if true, coordinates of objects enclosed in a group do not change @@ -22255,6 +22293,7 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) { this._clearCache(); this.width = this._getTextWidth(ctx) || this.cursorWidth || MIN_TEXT_WIDTH; this.height = this._getTextHeight(ctx); + this.setCoords(); }, /** @@ -22270,17 +22309,19 @@ fabric.Image.filters.BaseFilter.fromObject = function(object, callback) { * Return the dimension and the zoom level needed to create a cache canvas * big enough to host the object to be cached. * @private + * @param {Object} dim.x width of object to be cached + * @param {Object} dim.y height of object to be cached * @return {Object}.width width of canvas * @return {Object}.height height of canvas * @return {Object}.zoomX zoomX zoom value to unscale the canvas before drawing cache * @return {Object}.zoomY zoomY zoom value to unscale the canvas before drawing cache */ _getCacheCanvasDimensions: function() { - var dim = this.callSuper('_getCacheCanvasDimensions'); + var dims = this.callSuper('_getCacheCanvasDimensions'); var fontSize = this.fontSize; - dim.width += fontSize * dim.zoomX; - dim.height += fontSize * dim.zoomY; - return dim; + dims.width += fontSize * dims.zoomX; + dims.height += fontSize * dims.zoomY; + return dims; }, /** @@ -26330,6 +26371,7 @@ fabric.util.object.extend(fabric.IText.prototype, /** @lends fabric.IText.protot // clear cache and re-calculate height this._clearCache(); this.height = this._getTextHeight(ctx); + this.setCoords(); }, /**
