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

Add a scroll smooth step function #3909

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CauchyUnderground
Copy link

A very simple smooth step function for scroll based on a cosine.

actionless
actionless previously approved these changes Apr 6, 2024
Copy link

codecov bot commented Apr 6, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 91.26%. Comparing base (8b1f895) to head (c9a7698).

❗ Current head c9a7698 differs from pull request most recent head a38e316. Consider uploading reports for the commit a38e316 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3909      +/-   ##
==========================================
- Coverage   91.27%   91.26%   -0.01%     
==========================================
  Files         935      935              
  Lines       60129    60131       +2     
==========================================
- Hits        54880    54877       -3     
- Misses       5249     5254       +5     
Flag Coverage Δ
gcov 91.26% <33.33%> (-0.01%) ⬇️
luacov 93.89% <33.33%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
lib/wibox/container/scroll.lua 57.70% <33.33%> (-0.33%) ⬇️

... and 5 files with indirect coverage changes

local state = ((elapsed * speed) % (size)) / size
-- The cosine function is scaled to map [0,1] to [0,2π] then it’s output is
-- scaled from [1 -- -1 -- 1] to [0 -- 1 -- 0]
return (size - visible_size) * (0.5 - 0.5*math.cos(state*6.2832))
Copy link
Contributor

Choose a reason for hiding this comment

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

2 * math.pi would be preferable to some magic number literal.

Copy link
Author

Choose a reason for hiding this comment

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

It’s clearly more readable with it, I must admit I did not check if it existed in lua.

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.

4 participants