joe223 / tiny-swiper

Ingenious JavaScript Carousel powered by wonderful plugins. Lightweight yet extensible. Import plugins as needed, No more, no less.
https://tiny-swiper.js.org
1.29k stars 58 forks source link

Issues with nextTick.ts & SSR #77

Open josemrodrigu opened 2 years ago

josemrodrigu commented 2 years ago

Describe the bug Since the last version (2.2.0), our implementation (with server side rendering) returns the following error:

2022-02-11T15:17:14.232Z - error: uncaughtException: requestAnimationFrame is not defined
ReferenceError: requestAnimationFrame is not defined
    at /Users/josemrodrigu/Projects/andes-library-test/node_modules/tiny-swiper/lib/index.min.js:1:2592
    at /Users/josemrodrigu/Projects/andes-library-test/node_modules/tiny-swiper/lib/index.min.js:1:84
    at Object.<anonymous> (/Users/josemrodrigu/Projects/andes-library-test/node_modules/tiny-swiper/lib/index.min.js:1:201)

Checking nextTick.ts, I noticed that nextFrame and cancelNextFrame constants are defined outside Tick(). Of course, Tick is never executed on the server. Now that those connstants are defined at file scope, this bug can see the light.

I'll make a PR in order to support both client and server side implementations

Expected behavior The error doesn't happen

Information

Captura de Pantalla 2022-02-11 a la(s) 12 27 10 Captura de Pantalla 2022-02-11 a la(s) 12 27 18
josemrodrigu commented 2 years ago

@joe223 Any updates on this issue? do yo have a better solution for this scenario?

Thanks!

themrdanielvp commented 2 years ago

I am also having this issue..

shkipan commented 5 months ago

@joe223 , is there any chance this issue will be solved?