Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip - add css filters #8

Merged
merged 1 commit into from
Nov 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 29 additions & 26 deletions motion/customMotion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ const getSelectProperyElement = (animationIx, keyframeIx, propertyIx, selectedPr
const availableProperties = [
"opacity",
"transform",
// "clip-path"
"clip-path",
"filter"
];

return `
Expand Down Expand Up @@ -51,30 +52,34 @@ const getPropertyFunctionElement = (animationIx, keyframeIx, propertyIx, selecte
"inset",
"circle",
"ellipse",
"polygon",
"path"
// "polygon",
// "path"
],
"filter": [
// "blur",
"brightness",
"contrast",
// "drop-shadow",
"grayscale",
"hue-rotate",
"invert",
// "opacity",
"saturate",
"sepia"
]

}

console.log(selectedProperty);

switch (selectedProperty) {
case 'transform':
case 'clip-path':
return `
<select onchange="setPropertyFunction(${animationIx}, ${keyframeIx}, ${propertyIx}, this);">
<option selected="${selectedFunction ? 'false' : 'true'}" disabled="disabled">Select function</option>
${availableFunctions[selectedProperty]?.map(f => {
return `<option value="${f}" ${f == selectedFunction ? 'selected' : ''}>${f}</option>`
})}
</select>`;

default:
return '';
if (selectedProperty in availableFunctions) {
return `
<select onchange="setPropertyFunction(${animationIx}, ${keyframeIx}, ${propertyIx}, this);">
<option selected="${selectedFunction ? 'false' : 'true'}" disabled="disabled">Select function</option>
${availableFunctions[selectedProperty]?.map(f => {
return `<option value="${f}" ${f == selectedFunction ? 'selected' : ''}>${f}</option>`
})}
</select>`;
} else {
return '';
}


};

const trashIcon = (animationIx, keyframeIx, propertyIx) =>`
Expand Down Expand Up @@ -375,7 +380,8 @@ function runAnimation() {
const thisKey = {
"opacity": '',
"transform": [],
"clip-path": []
"clip-path": [],
"filter": []
}

keyframe.properties.forEach(({propertyName, propertyFunction, value}) => {
Expand All @@ -393,15 +399,12 @@ function runAnimation() {
return p.replace('A_', '').replace('B_', '').replace('C_', '').replace('D_', '');
});

const newClip = thisKey['clip-path']?.map(p => {
return ``
})

return `
${keyframe.key}% {
${thisKey.opacity !== '' ? `opacity: ${thisKey.opacity};` : ''}
${newTransforms.length > 0 ? `transform: ${newTransforms.join(' ')};` : ''}
${thisKey['clip-path'].length > 0 ? `clip-path: ${thisKey['clip-path'].join(' ')};` : ''}
${thisKey['filter'].length > 0 ? `filter: ${thisKey['filter'].join(' ')};` : ''}
}`;
});

Expand Down