Allow specifying which element to set scroll position on
Closed this issue · 2 comments
Hi there!
Your promising add-on caught my eye, for I was aspiring to create a fancy scroll transition in an app building on Ember Material Lite. To my grave disappointment I found out it didn't work. Digging into it I quickly found out the cause:
I saw here that it uses html, body
as the selector for the element to set the scroll position off. This is quite common practice, and will work for many websites as a sane default :) There are however quite some frameworks, like Google's popular Material Design Lite, that prefer setting up a specific DOM structure for handling things like responsiveness, containing the main layout etc. You'll probably feel where this is going :) For these frameworks, this nifty add-on could also easily work, giving there were is a way for the user to override the default selector of the main view element. For example, in the case of Material Design Lite it would be main.mdl-layout__content
.
Would you consider facilitating this? If you're rather occupied I could propose a pull request.
Greetings!
Hey @FelixAkk. That sounds pretty reasonable to me. A PR would be awesome. Thanks!
Just realized that this can already quite neatly be achieved using the following router code:
import Ember from 'ember';
export default Ember.Route.extend({
scroller: Ember.inject.service(),
activate: function() {
this.get('scroller').scrollable = Ember.computed(function() {
return Ember.$('main.mdl-layout__content');
});
this._super();
}
});
Not sure if this is good Ember.js practice? (still very new to the framework), but it seems reliable. I guess mentioning that in the README.md is sufficient :) Hence, the following modest PR: