DaveKeehl / svelte-reveal

Svelte action that leverages the Intersection Observer API to trigger reveal on scroll transitions.
https://stackblitz.com/edit/svelte-reveal?file=src%2FApp.svelte
MIT License
131 stars 3 forks source link

[Bug]: Observer options not taken into account #149

Closed 1u0n closed 1 year ago

1u0n commented 1 year ago

Describe the bug

when creating the observer like

<div use:reveal={{ transition: "fly", debug: true, ref: "a", threshold: 0.2, marginBottom: 100, marginTop: 100 }}>

the lib options (transition, x, debug, ref, ...) are correctly used, but the Observer options (threshold, marginBottom, ...) are ignored.

This is I guess due to passing config.observer directly in createObserver() instead of creating an object with the user's parameters.

Changing the Observer options through the API (setObserverThreshold, setObserverRootMargin, ...) works fine.

Reproduction

<div use:reveal={{ transition: "fly", debug: true, ref: "a", threshold: 0.2, marginBottom: 100, marginTop: 100 }}>

the applied threshold will be the default 0.6 instead of the desired 0.2. Same for margins and root.

System Info

this is not system-dependant

Severity

Serious, but I can work around it

Additional Information

No response

DaveKeehl commented 1 year ago

Thanks for reporting it. Will look into it!

DaveKeehl commented 1 year ago

Yes, you were right. It was because the createObserver function was using the default options instead of the ones overridden by the user. I've managed to fix this, but I have also identified other small areas of improvement related to this, so I still want to take a few days to work on it.

Expect a new minor release in the upcoming days.

DaveKeehl commented 1 year ago

I just released version 0.7.0. Feel free to re-open this issue or to create a new one in case of problems!