willviles / ember-scrollmagic

An Ember addon for building magical scroll interactions using ScrollMagic.js
https://willviles.github.io/ember-scrollmagic
MIT License
18 stars 4 forks source link

Scroll controllers accessible by nested routes #6

Closed willviles closed 6 years ago

willviles commented 7 years ago

At present, this.get('scrollMagic').getController() only searches for scroll controllers registered on the current route. Currently, preserving the scroll controller for pages with nested routes requires custom scroll controllers to be registered and shared across routes, creating a messy pattern.

Instead, getController() should recursively look up the route tree for a parent ScrollMagic controller if one is not registered for the current route. This way, navigating to a nested child route will not break components initialised on the parent route's scroll controller.

It should also be noted that is unlikely for nested routes to want their own scroll controller if a parent already has one registered.

This also opens up the possibility to have just one scroll controller registered on the ApplicationController and to simply add and remove scenes inside the component didRender and willDestroyElement hooks.

willviles commented 6 years ago

Solved by the overhaul for Ember ScrollMagic 1.0.0 release in PR #11.