jshjohnson / Animate

A tiny JS (5KB) library to trigger animations on elements when they are within the viewport 👓

Home Page:https://joshuajohnson.co.uk/Animate/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could `offset` logic be reversed?

StudioRATATA opened this issue · comments

Hey,
I was wondering. Could the offset logic also be reversed?
Now the logic is the number of the input is the percentage of which the element is visible in the viewport.
I would like to see a way to input a number of the percentage of which the element is inside the viewport. So, the other way around. I you would enter 0.1 it checks if the element, not matter the size of the element, had entered 10% of the viewport.

The reason is that, now it works nicely on desktop. But it becomes a mess sometimes on mobile. For example, I've got a block with 2 rows and 4 columns on desktop. But on mobile they are 8 rows of 1 column. In other words, a long-long block. Now you have to scroll, say, 50% of the element to be visible. Leaving the visitor puzzled why for four scrolls nothing shows.

I know I can disable the effect on mobile or even make a conditional second option with an offset of 0.05. But I think a trigger of the view percentage within the viewport would solve a lot for me.