-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
43 lines (40 loc) · 1.02 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Basic Backbone view for testing
require('../index.js');
const _ = require('underscore');
const Backbone = require('backbone');
const layoutView = Backbone.View.extend({
el: '#app',
template: `
<br>
<h3> thann/backbone_scrollbottom demo </h3>
<div> scroll to the bottom, and see more stuff appear </div>
<br>
`,
initialize() {
this._tmpl = _.template(this.template);
this.initScrollBottom();
// this.initScrollBottom(undefined, factor=.75);
// this.initScrollBottom(undefined, factor=1, offset=200);
let i = 0;
this.on('scroll:bottom', (e) => {
i++;
console.log("scrollbottom!!!!", i, e);
this.render(i);
});
},
render(x) {
this.$el.html(this._tmpl());
// Add a bunch of nonsense
for (let i = 0; i <= (x||0); i++) {
for (let j = 0; j < 100; j++) {
this.$el.append(`<div> line: ${i}, ${j} </div>`);
}
}
},
});
Backbone.$(document).ready(() => {
const lv = new layoutView();
lv.render();
window.layoutView= lv;
console.log("disable with: window.layoutView.stopListening()");
});