mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-17 19:12:37 -05:00
update ember-cloaking to support bottom fixed element
This commit is contained in:
parent
e0b72997db
commit
8262279380
2 changed files with 27 additions and 10 deletions
|
@ -86,7 +86,8 @@
|
|||
loadingHTML=controller.loadingHTML
|
||||
preservesContext="true"
|
||||
uncloakDefault="true"
|
||||
offsetFixed="header"}}
|
||||
offsetFixed="header"
|
||||
offsetFixedBottom="#reply-control"}}
|
||||
{{/unless}}
|
||||
|
||||
{{#if postStream.loadingBelow}}
|
||||
|
|
34
vendor/assets/javascripts/ember-cloaking.js
vendored
34
vendor/assets/javascripts/ember-cloaking.js
vendored
|
@ -10,7 +10,8 @@
|
|||
Ember.CloakedCollectionView = Ember.CollectionView.extend({
|
||||
topVisible: null,
|
||||
bottomVisible: null,
|
||||
offsetFixedElement: null,
|
||||
offsetFixedTopElement: null,
|
||||
offsetFixedBottomElement: null,
|
||||
|
||||
init: function() {
|
||||
var cloakView = this.get('cloakView'),
|
||||
|
@ -119,21 +120,27 @@
|
|||
topView = this.findTopView(childViews, viewportTop, 0, childViews.length-1),
|
||||
bodyHeight = this.get('wrapperHeight') ? this.$().height() : $('body').height(),
|
||||
bottomView = topView,
|
||||
offsetFixedElement = this.get('offsetFixedElement');
|
||||
offsetFixedTopElement = this.get('offsetFixedTopElement'),
|
||||
offsetFixedBottomElement = this.get('offsetFixedBottomElement');
|
||||
|
||||
if (windowBottom > bodyHeight) { windowBottom = bodyHeight; }
|
||||
if (viewportBottom > bodyHeight) { viewportBottom = bodyHeight; }
|
||||
|
||||
if (offsetFixedElement) {
|
||||
windowTop += (offsetFixedElement.outerHeight(true) || 0);
|
||||
if (offsetFixedTopElement) {
|
||||
windowTop += (offsetFixedTopElement.outerHeight(true) || 0);
|
||||
}
|
||||
|
||||
if (offsetFixedBottomElement) {
|
||||
windowBottom -= (offsetFixedBottomElement.outerHeight(true) || 0);
|
||||
}
|
||||
|
||||
// Find the bottom view and what's onscreen
|
||||
while (bottomView < childViews.length) {
|
||||
var view = childViews[bottomView],
|
||||
$view = view.$(),
|
||||
// in case of not full-window scrolling
|
||||
scrollOffset = this.get('wrapperTop') >> 0,
|
||||
viewTop = $view.position().top + scrollOffset,
|
||||
scrollOffset = this.get('wrapperTop') || 0,
|
||||
viewTop = $view.offset().top + scrollOffset,
|
||||
viewBottom = viewTop + $view.height();
|
||||
|
||||
if (viewTop > viewportBottom) { break; }
|
||||
|
@ -183,14 +190,23 @@
|
|||
},
|
||||
|
||||
_startEvents: function() {
|
||||
if (this.get('offsetFixed')) {
|
||||
Em.warn("Cloaked-collection's `offsetFixed` is deprecated. Use `offsetFixedTop` instead.");
|
||||
}
|
||||
|
||||
var self = this,
|
||||
offsetFixed = this.get('offsetFixed'),
|
||||
offsetFixedTop = this.get('offsetFixedTop') || this.get('offsetFixed'),
|
||||
offsetFixedBottom = this.get('offsetFixedBottom'),
|
||||
onScrollMethod = function() {
|
||||
Ember.run.debounce(self, 'scrollTriggered', 10);
|
||||
};
|
||||
|
||||
if (offsetFixed) {
|
||||
this.set('offsetFixedElement', $(offsetFixed));
|
||||
if (offsetFixedTop) {
|
||||
this.set('offsetFixedTopElement', $(offsetFixedTop));
|
||||
}
|
||||
|
||||
if (offsetFixedBottom) {
|
||||
this.set('offsetFixedBottomElement', $(offsetFixedBottom));
|
||||
}
|
||||
|
||||
$(document).bind('touchmove.ember-cloak', onScrollMethod);
|
||||
|
|
Loading…
Reference in a new issue