forked from tdreyno/morlock.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.html
78 lines (66 loc) · 1.98 KB
/
debug.html
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
75
76
77
78
<html>
<head>
<meta charset="utf-8">
<title>morlock.js Debugger</title>
</head>
<body>
<div class="js-responsive-image">
<div style="height: 1000px;"></div>
<div id="hi" style="height: 500px; background: red;"></div>
<div style="height: 5000px;"></div>
<script src="dist/morlock.min.js"></script>
<script>
rc = new ResizeController({
breakpoints: {
'mobile': { max: 767 },
'tablet': { min: 768, max: 1043 },
'desktop': { min: 1044 }
}
});
rc.on('resize', function(e) {
console.log('resize', e[0], e[1]);
});
// var intervalStream = s.interval(1000);
// var resizeStream = r.create({ throttleMs: 0 });
// var dimensionsStream = s.map(function() {
// return [window.innerWidth, window.innerHeight];
// }, resizeStream);
// s.onValue(s.sample(dimensionsStream, intervalStream), function(v) {
// console.log('Every 1000ms', v);
// });
// s.onValue(s.createFromRAF(), function(t) {
// console.log(t)
// })
var responsiveImages = [];
var elems = document.getElementsByClassName('js-responsive-image');
for (var i = 0; i < elems.length; i++) {
responsiveImages.push(ResponsiveImage.createFromElement(elems[i]));
}
rc.on('breakpoint', function(e) {
console.log('breakpoint', e);
for (var i = 0; i < responsiveImages.length; i++) {
ResponsiveImage.update(responsiveImages[i]);
}
});
sc = new ScrollController({
debounceMs: 400
});
sc.on('scrollEnd', function(e) {
console.log('scrollEnd');
});
var observer = sc.observeElement(document.getElementById('hi'));
observer.on('enter', function() {
console.log('enter');
});
observer.on('exit', function() {
console.log('exit');
});
ScrollController.observeScrollPosition(200)
.on('before', function() {
console.log('before 200');
}).on('after', function() {
console.log('after 200');
});
</script>
</body>
</html>