Commit 5190adec authored by Andrew Newdigate's avatar Andrew Newdigate

Nanoscroller with mutant to update on change

parent 26bcbea7
{
"directory" : "output/client-libs",
"json" : "component.json"
}
# EditorConfig is awesome: http://EditorConfig.org
#editorconfig.org
# top-most EditorConfig file
root = true
......
'use strict';
var mutant = require('mutant')
var $ = require('jquery');
var _ = require('underscore');
require('nanoscroller');
function MutantWrapper(target, options) {
this.$target = $(target);
var adjustNanoScrollerThrottled = _.throttle(this.adjust.bind(this), 100, { leading: false });
this.mutant = new Mutant(target, adjustNanoScrollerThrottled, { transitions: true, observers: { attributes: true, characterData: true } } );
this.$target.nanoScroller(options);
}
MutantWrapper.prototype = {
disconnect: function() {
this.mutant.disconnect();
this.$target.nanoScroller({ destroy: true });
},
adjust: function() {
this.$target.nanoScroller();
}
}
module.exports = function(target, options) {
return new MutantWrapper(target, options);
}
"use strict";
var $ = require('jquery');
var nanoscrollWrapper = require('../../utils/nanoscroll-wrapper');
var Marionette = require('marionette');
var context = require('utils/context');
var appEvents = require('utils/appevents');
......@@ -15,6 +16,7 @@ var CollectionWrapperViewTemplate = require('./tmpl/collection-wrapper-view.hbs'
var SearchView = require('./searchView');
var ProfileView = require('./profileView');
var OrgCollectionView = require('./orgCollectionView');
require('nanoscroller');
module.exports = (function() {
......@@ -81,6 +83,10 @@ module.exports = (function() {
suggested: '#left-menu-list-suggested'
},
ui: {
nano: '.nano'
},
events: function() {
var events = {
// 'click #search-clear-icon': 'onSearchClearIconClick'
......@@ -127,13 +133,6 @@ module.exports = (function() {
if (index) self.selectedIndex = index;
});
// nanoscroller has to be reset when regions are rerendered
this.regionManager.forEach(function (region) {
self.listenTo(region, 'show', function () {
var $nano = this.$el.find('.nano');
$nano.nanoScroller({ iOSNativeScrolling: true });
});
});
// determining whether we should show the suggested rooms or not
var hasItems = troupeCollections.troupes && !!(troupeCollections.troupes.length);
......@@ -214,6 +213,10 @@ module.exports = (function() {
onRender: function () {
this.isRendered = true;
if(!this.nano) {
this.nano = nanoscrollWrapper(this.ui.nano[0], { iOSNativeScrolling: true });
}
this.profile.show(new ProfileView());
// mega-list: recent troupe view
......@@ -260,4 +263,3 @@ module.exports = (function() {
return View;
})();
......@@ -101,7 +101,8 @@ var webpackConfig = {
plugins: [
new CommonsChunkPlugin("vendor", "[name].js"),
new ContextReplacementPlugin(/moment\/lang$/, /cs|da|de|en-gb|es|fr|it|ja|ko|nl|pl|pt|ru|sv|zh-cn/)
]
],
bail: true
};
if(devMode) {
......@@ -113,5 +114,3 @@ if(devMode) {
webpackConfig.plugins.push(new UglifyJsPlugin());
}
module.exports = webpackConfig;
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment