-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathcustom-container.js
More file actions
74 lines (60 loc) · 1.94 KB
/
custom-container.js
File metadata and controls
74 lines (60 loc) · 1.94 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
describe('using a div as a reference container', function() {
require('./fixtures/bootstrap.js');
beforeEach(h.clean);
afterEach(h.clean);
var fakeSrc = '../b.gif?'+(+new Date());
var realSrc = '/test/fixtures/tiny.gif?'+(+new Date());
var container;
var test;
window['customContainerLzld'] = true;
beforeEach(function() {
container = h.createTest({
attributes: {
id: 'container'
},
style: {
width: '500px',
height: '500px',
overflow: 'scroll'
}
});
container.innerHTML = '<div class="scrollTrigger"></div>';
h.insertTest(container);
window['customContainerLzld'] = lazyload({container: document.getElementById('container')});
test = h.createTest({
tagName: 'img',
attributes: {
id: 'custom-container',
src: fakeSrc,
'data-src': realSrc,
width: 10,
height: 100,
onload: 'customContainerLzld(this)'
},
style: {
top: '1000px',
left: '1000px'
}
});
h.insertTest(test, container);
});
describe('when we scroll down on body', function() {
beforeEach(h.scroller(1000, 1000));
it('does not loads the image', h.eltNotLoaded('custom-container'));
});
describe('when we scroll down to 100, 100 inside the container', function() {
beforeEach(function(cb) {
h.scroller(100, 100, container, cb)
});
it('does not loads the image', h.eltNotLoaded('custom-container'));
});
describe('when we scroll down too far at 10000, 10000 inside the container', function() {
beforeEach(h.scroller(10000, 10000, 'container'));
it('does not loads the image', h.eltNotLoaded('custom-container'));
});
describe('when we scroll down inside the container to the element', function() {
beforeEach(h.scroller(1000, 1000, 'container'));
beforeEach(h.scroller(1005, 1005, 'container'));
it('loads the image', h.eltLoaded('custom-container'));
});
});