I have a div that got a
transition:1s;
On scroll,I move the div from her actual position to the new position calculated, and thx to the transition, it's smooth. But someone request me that, the div cannot go outside the actual view.
If i scroll really fast, my div will be out of the view for a short period, and then come back.
My question is, is there a way to ignore the transition in some sort? Like, when my calculation say that the div will be outside the view, i can write the minimum top position to make her stay on the view.
Or the only solution is to remove the transition (so let's say a class
.divTransition{
transition:1s;
}
when i need to do that and put it back just after?
Here's a fiddle, basically I want the red cube to always stay on the view.
Here's a fiddle : https://jsfiddle.net/Crocsx/qm1gchtw/
Basically i want the red box to always stay on the view, and never go out of the "screen"
thx