Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const _parseTransform = function (domElement) {
let matrix = Matrix.identity();
const string = domElement.attributes && domElement.attributes.transform && domElement.attributes.transform.value;
if (!string) return matrix;
// https://www.w3.org/TR/SVG/types.html#DataTypeTransformList
// Parse SVG transform string. First we split at /)\s*/, to separate
// commands
const transforms = string.split(/\)\s*/g);
for (const transform of transforms) {
if (!transform) break;
// Command come before the '(', values after
const parts = transform.split(/\(\s*/);
const command = parts[0].trim();
const v = parts[1].split(/[\s,]+/g);
// Convert values to floats
for (let j = 0; j < v.length; j++) {
v[j] = parseFloat(v[j]);
}
const transformStrokeWidths = function (svgTag, windowRef, bboxForTesting) {
const inherited = Matrix.identity();
const applyTransforms = (element, matrix, strokeWidth, fill) => {
if (_isContainerElement(element)) {
// Push fills and stroke width down to leaves
if (element.attributes['stroke-width']) {
strokeWidth = element.attributes['stroke-width'].value;
}
if (element.attributes && element.attributes.fill) {
fill = element.attributes.fill.value;
}
// If any child nodes don't take attributes, leave the attributes
// at the parent level.
for (let i = 0; i < element.childNodes.length; i++) {
applyTransforms(
element.childNodes[i],
Matrix.compose(matrix, _parseTransform(element)),
test('testMatrix', () => {
const value = getDefaultValue(
200, 200, //viewer 200x200
0, 0, 400, 400, //svg 400x400
)
const matrix = testMatrix(value)
expect(matrix).toEqual(identity())
expect(matrix).toMatchSnapshot()
})
export function reset(value) {
return set(value, _extends({
mode: MODE_IDLE
}, identity()));
}
export function reset(value) {
return set(value, {
mode: MODE_IDLE,
...identity()
});
}
constructor(matrix) {
this.matrix = matrix || identity();
}
_this.minZoomLevel = 0.1;
_this.maxZoomLevel = 4.0;
_this.autoZoom = false;
_this.panOnZoom = true;
_this.autoCenter = false;
_this.activate = new EventEmitter();
_this.deactivate = new EventEmitter();
_this.subscriptions = [];
_this.margin = [0, 0, 0, 0];
_this.results = [];
_this.isPanning = false;
_this.isDragging = false;
_this.initialized = false;
_this.graphDims = { width: 0, height: 0 };
_this._oldLinks = [];
_this.transformationMatrix = identity();
_this._touchLastX = null;
_this._touchLastY = null;
_this.groupResultsBy = function (node) { return node.label; };
return _this;
}
Object.defineProperty(GraphComponent.prototype, "zoomLevel", {
export function getDefaultValue(viewerWidth, viewerHeight, SVGWidth, SVGHeight) {
return set({}, _extends({}, identity(), {
version: 2,
mode: MODE_IDLE,
focus: false,
viewerWidth: viewerWidth,
viewerHeight: viewerHeight,
SVGWidth: SVGWidth,
SVGHeight: SVGHeight,
startX: null,
startY: null,
endX: null,
endY: null,
miniatureOpen: true
}));
}