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

Easing function improvements #77

Open
sarmong opened this issue Feb 4, 2023 · 2 comments
Open

Easing function improvements #77

sarmong opened this issue Feb 4, 2023 · 2 comments

Comments

@sarmong
Copy link

sarmong commented Feb 4, 2023

  1. Allow passing custom function to both global and local settings.
  2. Make it more clear in the readme what kind of function these are - EaseIn, EaseOut or EaseInOut (perhaps using standardized names like easings.net does?)
  3. When I press and hold <C-d>, everything slows down as if I am holding j. (same for upwards movement)
  4. I am trying to use easeOutCirc, however it is still slow on the start, quick at the end. But this function should be reverse. I am return this math.sqrt(1 - math.pow(x - 1, 2)). What am I doing wrong?
@baptisteArno
Copy link

Definitely need more info, is it in, out or in and out ?

@karb94
Copy link
Owner

karb94 commented Jul 25, 2024

  • All the animations are easing-out. I don't really think anyone would want easing-in for a scrolling motion.
  • The functions are defined in scroll.lua (easing_function table) but it is not exposed as part of the module at this time. I can expose it if you really want to define your own functions.
  • Easing functions are generally defined as $x(t)$ because you want to know what will be the position at time $t$. However, Neoscroll already knows the next immediate position (next line) and what needs to know instead is how much time it should wait until it moves to the next line. Therefore, Neoscroll wants $t(x)$ instead of $x(t)$. So once you have a function that you like you need to invert it before passing it to Neoscroll.
    Example: easeOutQuad function is
local function t(x)
  return 1 - math.pow(1 - x, 2)
end

but Neoscroll uses its inverse:

local function x(t)
  return 1 - math.pow(1 - x, 1 / 2)
end

Likewise, for easeOutCirc you would need:

local function x(t)
  return 1 - math.pow(1 - x * x, 1 / 2)
end

Note that these two examples are already implemented as the quadratic and circular easing functions in Neoscroll.

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

No branches or pull requests

3 participants