Skip to content

Commit 3f50bd5

Browse files
authored
feat: smoother animation when showing results (#208)
* feat: smoother animation when showing results * rem: duplicated variables * rem: changes in gitginore file
1 parent c6bec2e commit 3f50bd5

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/main.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,19 @@ const FINAL_WIDTH = 300;
2727
let attributeValue: string | null = null;
2828
let imageSRC: string;
2929
let imageHeight: number;
30-
const sideBarSlide = [{left: '100%'}, {left: '0%'}];
30+
const sideBarSlide = [
31+
{left: '30%', opacity: '0'},
32+
{left: '0%', opacity: '1'},
33+
];
34+
const sideBarSlideOut = [
35+
{left: '0%', opacity: '1'},
36+
{left: '30%', opacity: '0'},
37+
];
3138

3239
const sideBarTiming = {
33-
duration: 500,
40+
duration: 450,
3441
iterations: 1,
35-
easing: 'ease-in',
42+
easing: 'ease',
3643
};
3744

3845
// Elements
@@ -144,6 +151,7 @@ FilePond.create(getImageEntryElement, {
144151
enableImgResultBtn();
145152

146153
// disable btn also when close btn clicked on image display
154+
147155
const closeBtn = document.querySelector(
148156
'.filepond--action-remove-item'
149157
) as HTMLButtonElement;
@@ -274,12 +282,11 @@ showResult(null);
274282

275283
// onClick event listener for the closebar icon
276284
closeBar?.addEventListener('click', () => {
277-
const sideBarSlide = [{left: '0%'}, {left: '100%'}];
278-
sidebar.animate(sideBarSlide, sideBarTiming);
285+
sidebar.animate(sideBarSlideOut, sideBarTiming);
279286
sidebar.style.left = '100%';
280287
showResult(null);
281288
setTimeout(() => {
282-
sidebar.style.display = 'none'
289+
sidebar.style.display = 'none';
283290
}, 600);
284291
});
285292

0 commit comments

Comments
 (0)