Skip to content

Add animation on the timeline content, to avoid glitch (#1323) #1405

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

Merged
merged 2 commits into from
Sep 21, 2023

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented Sep 21, 2023

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Workaround the load of the timeline by delayed the display to 150ms and passing from 0 to 1 for alpha in 150ms.
This reduce the glitches, and is independant of the loading of the messages behind the scene.

Motivation and context

Fixes #1323

Screenshots / GIFs

TimelineAnimation

Tests

  • Open a timeline and see there is less glitch

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@bmarty bmarty requested a review from a team as a code owner September 21, 2023 16:47
@bmarty bmarty requested review from ganfra and removed request for a team September 21, 2023 16:47
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@github-actions
Copy link
Contributor

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/xNf2DK

@codecov
Copy link

codecov bot commented Sep 21, 2023

Codecov Report

Patch coverage: 52.94% and project coverage change: -0.01% ⚠️

Comparison is base (3ff7c62) 58.06% compared to head (1411b7d) 58.06%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1405      +/-   ##
===========================================
- Coverage    58.06%   58.06%   -0.01%     
===========================================
  Files         1128     1129       +1     
  Lines        29863    29879      +16     
  Branches      6060     6067       +7     
===========================================
+ Hits         17341    17349       +8     
- Misses        9930     9932       +2     
- Partials      2592     2598       +6     
Files Changed Coverage Δ
...libraries/designsystem/animation/AlphaAnimation.kt 46.66% <46.66%> (ø)
...id/features/messages/impl/timeline/TimelineView.kt 44.51% <100.00%> (+0.34%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

): State<Float> {
val firstAlpha = if (LocalInspectionMode.current) 1f else fromAlpha
var alpha by remember { mutableFloatStateOf(firstAlpha) }
LaunchedEffect(Unit) { alpha = toAlpha }
Copy link
Member

Choose a reason for hiding this comment

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

I don't get the LaunchedEffect, how is it needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a way to pass the alpha from 0 to 1.

Copy link
Member Author

Choose a reason for hiding this comment

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

As you suggested, it could have been implemented like this:

    var isVisible by remember { mutableStateOf(false) }
    LaunchedEffect(Unit) {
        isVisible = true
    }
    val alpha by animateFloatAsState(
        targetValue = if (isVisible) 1f else 0f,
        animationSpec = tween(
            delayMillis = 150,
            durationMillis = 150,
        ),
        label = "label"
    )

We may iterate later.

@bmarty bmarty merged commit 8fc7a79 into develop Sep 21, 2023
@bmarty bmarty deleted the feature/bma/timelineGlitch branch September 21, 2023 20:13
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.

Avoid flashes of glitching when viewing rooms
2 participants