Skip to content

Commit 0ea59bc

Browse files
author
Divyanshi Vashist
committed
Added element as an argument for offset-path functions
1 parent a4a4483 commit 0ea59bc

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = function(config) {
2323
'tools/internal-scope.js',
2424
],
2525
require('fs').readFileSync('src/fileOrder.txt', 'utf8').split('\n'),
26-
['test/testFunctions.js', 'test/basicShapePolygonTest.js']
26+
['test/*.js']
2727
),
2828

2929
// list of files to exclude

src/offsetPath.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'use strict';
33

44
(function () {
5-
function basicShapePolygonParse (input) {
5+
function basicShapePolygonParse (input, element) {
66
// TODO: Support the fill-rule option and %
77
var argumentList = input.split(',');
88
var coordinate = null;
@@ -34,7 +34,7 @@
3434
return {type: 'path', path: path};
3535
}
3636

37-
function basicShapeCircleParse (input) {
37+
function basicShapeCircleParse (input, element) {
3838
// TODO: Need element as an argument to this function
3939
var radius;
4040
var position = /at (.*?)$/.exec(input);
@@ -69,23 +69,23 @@
6969
return {type: 'path', path: pathString};
7070
}
7171

72-
function basicShapeInsetParse (input) {
72+
function basicShapeInsetParse (input, element) {
7373
// WIP
7474
return null;
7575
}
7676

77-
function basicShapeEllipseParse (input) {
77+
function basicShapeEllipseParse (input, element) {
7878
// WIP
7979
return null;
8080
}
8181

82-
function parseNone (input) {
82+
function parseNone (input, element) {
8383
if (input === 'none') {
8484
return {type: null, angle: null, path: null};
8585
}
8686
}
8787

88-
function parseRay (input) {
88+
function parseRay (input, element) {
8989
var isInArray = internalScope.isInArray;
9090
var parseAngleAsDegrees = internalScope.parseAngleAsDegrees;
9191
var ray = /^ray\((.*)\)$/.exec(input);
@@ -125,7 +125,7 @@
125125
return result;
126126
}
127127

128-
function parsePath (input) {
128+
function parsePath (input, element) {
129129
var path = /^path\(['"](.*)['"]\)$/.exec(input);
130130
if (path === null) {
131131
return undefined;
@@ -134,7 +134,7 @@
134134
return {type: 'path', path: pathInput};
135135
}
136136

137-
function parseShape (input) {
137+
function parseShape (input, element) {
138138
var isInArray = internalScope.isInArray;
139139
var shapeType = /^[^\(]*/.exec(input);
140140
if (shapeType == null) {
@@ -151,19 +151,19 @@
151151
}
152152
var toParse = [basicShapePolygonParse, basicShapeCircleParse, basicShapeInsetParse, basicShapeEllipseParse];
153153
for (var i = 0; i < toParse.length; i++) {
154-
var result = toParse[i](shapeArguments[1]);
154+
var result = toParse[i](shapeArguments[1], element);
155155
if (result) {
156156
return result;
157157
}
158158
}
159159
return undefined;
160160
}
161161

162-
function offsetPathParse (input) {
162+
function offsetPathParse (input, element) {
163163
// https://drafts.fxtf.org/motion-1/#offset-path-property
164164
var toParse = [parseNone, parseRay, parsePath, parseShape];
165165
for (var i = 0; i < toParse.length; i++) {
166-
var result = toParse[i](input);
166+
var result = toParse[i](input, element);
167167
if (result) {
168168
return result;
169169
}

src/toTransform.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838

3939
var pathElement = document.createElementNS('http://www.w3.org/2000/svg', 'path');
4040

41-
function convertPath (properties, positionAnchor) {
42-
var offsetPath = internalScope.offsetPathParse(properties['offsetPath']);
41+
function convertPath (properties, positionAnchor, element) {
42+
var offsetPath = internalScope.offsetPathParse(properties['offsetPath'], element);
4343

4444
if (!offsetPath) {
4545
return null;
@@ -291,7 +291,7 @@
291291
https://drafts.fxtf.org/motion-1/#motion-paths-overview
292292
*/
293293
var positionAnchor = convertOffsetAnchorPosition(properties, element);
294-
var pathTransform = convertPath(properties, positionAnchor);
294+
var pathTransform = convertPath(properties, positionAnchor, element);
295295
var parsedRotate = convertOffsetRotate(properties);
296296
var rotation = parsedRotate.angle;
297297
var path = internalScope.offsetPathParse(properties['offsetPath']);

0 commit comments

Comments
 (0)