DEV Community

Pull to refresh animation with Vanilla JavaScript

vijitail on May 12, 2019

Pull-to-refresh is a very popular swipe gesture on smartphones that allow users to load new content on top of listed data. Its used in all popula...
Collapse
 
limbara profile image
Nico Limbara

let changeY = pStart.y < pCurrent.y? Math.abs(pStart.y - pCurrent.y) : 0; or it might trigger loading

Collapse
 
vijitail profile image
vijitail • Edited

Thanks man for pointing that out. Yes, otherwise it would trigger loading on swipe up as well. Great observations.

Collapse
 
okokokkkkkkjj profile image
.

what font do you use? I love the comparison operators look. :O

Collapse
 
vijitail profile image
vijitail • Edited

I created those images using carbon

But I guess the font is Fira Code

Collapse
 
flrnd profile image
Florian Rand
Collapse
 
bharathnallamothu profile image
bhaRATh

will it give me events like pull started , pull finessed? so that i can map it with server

Collapse
 
vijitail profile image
vijitail

Yes.. but currently these are not included in this post, you can add it easily using callbacks

Collapse
 
isalevine profile image
Isa Levine

this is so cool, thank you for sharing!!

Collapse
 
vijitail profile image
vijitail

I'm glad you found it helpful

Collapse
 
evankapantais profile image
Evan Kapantais

Is it really ok to self-close divs like that?

Collapse
 
vijitail profile image
vijitail

Yup

Collapse
 
chuksjoe profile image
Chukwunonso Orjiakor

Great post brother. Thanks for sharing 👍👍