flackr / scroll-timeline

A polyfill of ScrollTimeline.
Apache License 2.0
890 stars 84 forks source link

Set default anonymous source to nearest #208

Closed johannesodland closed 5 months ago

johannesodland commented 5 months ago

The progress demo is currently throwing a "TypeError: Invalid ScrollTimeline Source Type".

This happens because

  1. parseAnonymousScrollTimeline() does not set a default source
  2. getAnonymousSourceElement() requires a source, and will throw an error if one is not set.

Adding 'nearest' as a default anonymous source in getAnonymousScrollTimelineOptions(), the same place a default value for axis is set.

https://github.com/flackr/scroll-timeline/blob/db93642a02f0271c2a96a1f15861d04813b67b10/src/scroll-timeline-css-parser.js#L465-L481

https://github.com/flackr/scroll-timeline/blob/db93642a02f0271c2a96a1f15861d04813b67b10/src/scroll-timeline-css-parser.js#L117-L129

https://github.com/flackr/scroll-timeline/blob/db93642a02f0271c2a96a1f15861d04813b67b10/src/scroll-timeline-base.js#L493-L504