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

fix: reduce flickering #30

Merged
merged 7 commits into from
Jan 9, 2023
Merged

Conversation

Ty3uK
Copy link
Contributor

@Ty3uK Ty3uK commented Jan 5, 2023

Related to #25.

Search results flickers because of three things (IMO):

  • handleInput resets the results array, which immediately dropping list with #if directive in SearchResult component
  • Changing styles on focus and blur are not immediate operation, that's why another kind of flickering is a transition between focused and non-focused state (gray background)
  • getIcon function is another "bottleneck"; preservation of space for upcomming tag is a key for rescue

Most "ugly" part of this code is manipulating with classes. Changing classes through Svelte's class: binding leads to focus lost.

Unfortunately, manipulating classes through script cannot be made with obfuscated selectors, that's why you can see :global in code. Maybe you know better way to change classes without losing focus.

Related to ParthJadhav#25.

Search results flickers because of three things (IMO):

- `handleInput` resets the `results` array, which immediately dropping
  list with `#if` directive in `SearchResult` component
- Changing styles on `focus` and `blur` are not immediate operation, that's why another
  kind of flickering is a transition between focused and non-focused
  state (gray background)
- `getIcon` function is another "bottleneck"; preservation of space for
  upcomming <img> tag is a key for rescue

Most "ugly" part of this code is manipulating with classes. Changing
classes through Svelte's `class:` binding leads to focus lost.

Unfortunately, manipulating classes through script cannot be made with
obfuscated selectors, that's why you can see `:global` in code. Maybe you
know better way to change classes without losing focus.
@Ty3uK
Copy link
Contributor Author

Ty3uK commented Jan 5, 2023

Also, I can't fully beat icons flickering. When I have some applications in list and I typing another letter or remove old one, icons of apps that already in list flickers because of fully re-render results list.

Maybe we need to use array with ids, or something like that so Svelte can re-render only changed parts (not so familiar with Svelte, but expects similar behaviour with React)

@Ty3uK
Copy link
Contributor Author

Ty3uK commented Jan 5, 2023

I figured out that non-beated icon flickering is about getIcon function and #await block: Svelte re-renders <img> to a <span> and vice verse almost "blazingly fast", but it leads to annoying blinking 🥲

@Ty3uK
Copy link
Contributor Author

Ty3uK commented Jan 5, 2023

So I finally beat it with Map as a cache 🙈

Screen.Recording.2023-01-05.at.22.27.31.mp4

@ParthJadhav
Copy link
Owner

Woahh, That's amazing man !! It looks wayy better now.. I'm actually having an Exam tomorrow so will be studying, I'll review the code once i'm done with tomorrow's exam.

Non the less, Great work ! It really feels good 🙌

@Ty3uK
Copy link
Contributor Author

Ty3uK commented Jan 5, 2023

Thanks!

Good luck at exam ❤️

@ParthJadhav
Copy link
Owner

Thanks!

Good luck at exam ❤️

Thanks @Ty3uK 😄

@ParthJadhav
Copy link
Owner

Hey @, I just got some time to test it and I noticed that the results aren't cleared after the search bar is empty. It should return to it's original state when the searchBar doesn't have any search term..

@Ty3uK
Copy link
Contributor Author

Ty3uK commented Jan 5, 2023

Hey @, I just got some time to test it and I noticed that the results aren't cleared after the search bar is empty. It should return to it's original state when the searchBar doesn't have any search term..

Got it!

@Ty3uK
Copy link
Contributor Author

Ty3uK commented Jan 5, 2023

Hey @, I just got some time to test it and I noticed that the results aren't cleared after the search bar is empty. It should return to it's original state when the searchBar doesn't have any search term..

Fixed 🙂

@ParthJadhav
Copy link
Owner

Hey @Ty3uK , It works as expected now. Thanks for the changes.

Just I discovered a bug which is seemingly crucial. And this bug does not work in Dev.

Run:
yarn tauri build

And run the generated verve.app.

Try adding some numbers and inserting a space afterwards. This causes it to minimise.

Screen.Recording.2023-01-06.at.11.16.25.AM.mov

@ParthJadhav ParthJadhav linked an issue Jan 6, 2023 that may be closed by this pull request
Copy link
Owner

@ParthJadhav ParthJadhav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Ty3uK , Whenever free please do check the comment I left about the calculations being closed after typing Space

@ParthJadhav
Copy link
Owner

That issue of windows being closed after pressing space on calculations was because space was considered as a click on the result.. Hence it was copying the value & closing the result when we pressed space.

@ParthJadhav
Copy link
Owner

Will merge this, Tested it thoroughly and it works great. Thanks for this amazing improvement @Ty3uK 🤝

@ParthJadhav ParthJadhav merged commit 19ff234 into ParthJadhav:master Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stop flickery svelte components on input
2 participants