Skip to content

Commit

Permalink
fixes #10. fixes #11
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjlockwood committed Dec 8, 2017
1 parent 91964cb commit d184edc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/plugins/convertPathData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export type Params = typeof defaultParams;
function fn(item: JsApi, params: Params) {
if (
!(item.isElem('path') || item.isElem('clip-path')) ||
// TODO: don't optimize the path if it has a name?
// TODO: detect if a path w/ a name can be optimized (i.e. if it isn't being morphed)
item.hasAttr('android:name') ||
!item.hasAttr('android:pathData')
) {
return item;
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/removeEmptyGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import { Plugin } from './_types';
* TODO: are there any empty containers that could be removed in an animated-vector?
*/
function fn(item: JsApi) {
// TODO: should we remove an empty group if it has a name? we could break an AVD...
return item.isElem('group') && item.isEmpty() ? undefined : item;
// TODO: detect if the group w/ a name is being referenced by an AVD
return item.isElem('group') && !item.hasAttr('android:name') && item.isEmpty()
? undefined
: item;
}

export const removeEmptyGroups: Plugin<undefined> = {
Expand Down
9 changes: 9 additions & 0 deletions test/plugins/convertPathData.21.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:name="..." android:pathData="m100,200 300,400 z m100,200 L 300,400"/>
</vector>

@@@

<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:name="..." android:pathData="m100,200 300,400 z m100,200 L 300,400"/>
</vector>
18 changes: 18 additions & 0 deletions test/plugins/removeEmptyGroups.02.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android">
<group/>
<group>
<path android:pathData="..."/>
<group android:name="..."/>
</group>
<group/>
</vector>

@@@

<vector xmlns:android="http://schemas.android.com/apk/res/android">
<group>
<path android:pathData="..."/>
<group android:name="..."/>
</group>
</vector>

0 comments on commit d184edc

Please sign in to comment.