* We now use a new custom view, {{cloaked-collection}} to display posts in a topic.
* Posts are removed and inserted (cloaked/uncloaked) into the DOM dynamically based on whether they
are visible in the current browser viewport.
* There's been a lot of refactoring to ensure the relationship between the post views and the topic
controller is sane.
* Lots of fixes involving jumping to a post, including a new LockOn component to that tries to stay
focused on an element even if stuff is loading before it in the DOM that would normally push it
down.
68 lines
1.6 KiB
JavaScript
68 lines
1.6 KiB
JavaScript
/**
|
|
This mixin adds support for being notified every time the browser window
|
|
is scrolled.
|
|
|
|
@class Scrolling
|
|
@extends Ember.Mixin
|
|
@namespace Discourse
|
|
@module Discourse
|
|
**/
|
|
|
|
Discourse.Scrolling = Em.Mixin.create({
|
|
|
|
/**
|
|
Begin watching for scroll events. By default they will be called at max every 100ms.
|
|
call with {debounce: N} for a diff time
|
|
|
|
@method bindScrolling
|
|
*/
|
|
bindScrolling: function(opts) {
|
|
opts = opts || {debounce: 100};
|
|
|
|
var self = this,
|
|
onScrollMethod = function(e) {
|
|
return Em.run.scheduleOnce('afterRender', self, 'scrolled');
|
|
};
|
|
|
|
if (opts.debounce) {
|
|
onScrollMethod = Discourse.debounce(onScrollMethod, opts.debounce);
|
|
}
|
|
|
|
Discourse.ScrollingDOMMethods.bindOnScroll(onScrollMethod, opts.name);
|
|
},
|
|
|
|
/**
|
|
Stop watching for scroll events.
|
|
|
|
@method unbindScrolling
|
|
*/
|
|
unbindScrolling: function(name) {
|
|
Discourse.ScrollingDOMMethods.unbindOnScroll(name);
|
|
}
|
|
|
|
});
|
|
|
|
|
|
/**
|
|
This object provides the DOM methods we need for our Mixin to bind to scrolling
|
|
methods in the browser. By removing them from the Mixin we can test them
|
|
easier.
|
|
|
|
@class ScrollingDOMMethods
|
|
@module Discourse
|
|
**/
|
|
Discourse.ScrollingDOMMethods = {
|
|
|
|
bindOnScroll: function(onScrollMethod, name) {
|
|
name = name || 'default';
|
|
$(document).bind('touchmove.discourse-' + name, onScrollMethod);
|
|
$(window).bind('scroll.discourse-' + name, onScrollMethod);
|
|
},
|
|
|
|
unbindOnScroll: function(name) {
|
|
name = name || 'default';
|
|
$(window).unbind('scroll.discourse-' + name);
|
|
$(document).unbind('touchmove.discourse-' + name);
|
|
}
|
|
|
|
}; |