Merge pull request #2780 from mbasaglia/hybrid_stroke_bbox
Expand the hybrid shape bounding box on stroke
diff --git a/player/js/elements/htmlElements/HShapeElement.js b/player/js/elements/htmlElements/HShapeElement.js
index 7f1dfa4..464116f 100644
--- a/player/js/elements/htmlElements/HShapeElement.js
+++ b/player/js/elements/htmlElements/HShapeElement.js
@@ -182,10 +182,32 @@
this.calculateShapeBoundingBox(itemsData[i], boundingBox);
} else if (itemsData[i] && itemsData[i].it) {
this.calculateBoundingBox(itemsData[i].it, boundingBox);
+ } else if (itemsData[i] && itemsData[i].style && itemsData[i].w ) {
+ this.expandStrokeBoundingBox(itemsData[i].w, boundingBox);
}
}
};
+HShapeElement.prototype.expandStrokeBoundingBox = function (widthProperty, boundingBox) {
+ var width = 0;
+ if (widthProperty.keyframes) {
+ for ( var i = 0; i < widthProperty.keyframes.length; i++ ) {
+ var kfw = widthProperty.keyframes[i].s;
+ if ( kfw > width ) {
+ width = kfw;
+ }
+ }
+ width *= widthProperty.mult;
+ } else {
+ width = widthProperty.v * widthProperty.mult;
+ }
+
+ boundingBox.x -= width;
+ boundingBox.xMax += width;
+ boundingBox.y -= width;
+ boundingBox.yMax += width;
+};
+
HShapeElement.prototype.currentBoxContains = function (box) {
return this.currentBBox.x <= box.x
&& this.currentBBox.y <= box.y