mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Upgrade ember-cloaking to not trigger scroll events when the back button
is hit.
This commit is contained in:
parent
748767e222
commit
61ff04d68b
2 changed files with 16 additions and 7 deletions
|
@ -71,12 +71,12 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
||||||
}
|
}
|
||||||
}.observes('controller.enteredAt'),
|
}.observes('controller.enteredAt'),
|
||||||
|
|
||||||
didInsertElement: function() {
|
_inserted: function() {
|
||||||
this.bindScrolling({name: 'topic-view'});
|
this.bindScrolling({name: 'topic-view'});
|
||||||
|
|
||||||
var topicView = this;
|
var self = this;
|
||||||
$(window).resize('resize.discourse-on-scroll', function() {
|
$(window).resize('resize.discourse-on-scroll', function() {
|
||||||
topicView.scrolled();
|
self.scrolled();
|
||||||
});
|
});
|
||||||
|
|
||||||
// This get seems counter intuitive, but it's to trigger the observer on
|
// This get seems counter intuitive, but it's to trigger the observer on
|
||||||
|
@ -88,10 +88,10 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
||||||
if ($(e.target).hasClass('mention')) { return false; }
|
if ($(e.target).hasClass('mention')) { return false; }
|
||||||
return Discourse.ClickTrack.trackClick(e);
|
return Discourse.ClickTrack.trackClick(e);
|
||||||
});
|
});
|
||||||
},
|
}.on('didInsertElement'),
|
||||||
|
|
||||||
// This view is being removed. Shut down operations
|
// This view is being removed. Shut down operations
|
||||||
willDestroyElement: function() {
|
_destroyed: function() {
|
||||||
this.unbindScrolling('topic-view');
|
this.unbindScrolling('topic-view');
|
||||||
$(window).unbind('resize.discourse-on-scroll');
|
$(window).unbind('resize.discourse-on-scroll');
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
||||||
|
|
||||||
// this happens after route exit, stuff could have trickled in
|
// this happens after route exit, stuff could have trickled in
|
||||||
this.set('controller.controllers.header.showExtraInfo', false);
|
this.set('controller.controllers.header.showExtraInfo', false);
|
||||||
},
|
}.on('willDestroyElement'),
|
||||||
|
|
||||||
debounceLoadSuggested: Discourse.debounce(function(){
|
debounceLoadSuggested: Discourse.debounce(function(){
|
||||||
if (this.get('isDestroyed') || this.get('isDestroying')) { return; }
|
if (this.get('isDestroyed') || this.get('isDestroying')) { return; }
|
||||||
|
|
11
vendor/assets/javascripts/ember-cloaking.js
vendored
11
vendor/assets/javascripts/ember-cloaking.js
vendored
|
@ -95,6 +95,8 @@
|
||||||
@method scrolled
|
@method scrolled
|
||||||
**/
|
**/
|
||||||
scrolled: function() {
|
scrolled: function() {
|
||||||
|
if (!this.get('scrollingEnabled')) { return; }
|
||||||
|
|
||||||
var childViews = this.get('childViews');
|
var childViews = this.get('childViews');
|
||||||
if ((!childViews) || (childViews.length === 0)) { return; }
|
if ((!childViews) || (childViews.length === 0)) { return; }
|
||||||
|
|
||||||
|
@ -189,11 +191,18 @@
|
||||||
$(window).bind('scroll.ember-cloak', onScrollMethod);
|
$(window).bind('scroll.ember-cloak', onScrollMethod);
|
||||||
this.addObserver('wrapperTop', self, onScrollMethod);
|
this.addObserver('wrapperTop', self, onScrollMethod);
|
||||||
this.addObserver('wrapperHeight', self, onScrollMethod);
|
this.addObserver('wrapperHeight', self, onScrollMethod);
|
||||||
|
|
||||||
|
this.set('scrollingEnabled', true);
|
||||||
}.on('didInsertElement'),
|
}.on('didInsertElement'),
|
||||||
|
|
||||||
_endEvents: function() {
|
cleanUp: function() {
|
||||||
$(document).unbind('touchmove.ember-cloak');
|
$(document).unbind('touchmove.ember-cloak');
|
||||||
$(window).unbind('scroll.ember-cloak');
|
$(window).unbind('scroll.ember-cloak');
|
||||||
|
this.set('scrollingEnabled', false);
|
||||||
|
},
|
||||||
|
|
||||||
|
_endEvents: function() {
|
||||||
|
this.cleanUp();
|
||||||
}.on('willDestroyElement')
|
}.on('willDestroyElement')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue