This repository was archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparent-iframe.js
More file actions
43 lines (43 loc) · 1.64 KB
/
parent-iframe.js
File metadata and controls
43 lines (43 loc) · 1.64 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
if(typeof liveblog !== 'undefined') {
liveblog.loadCallback = function() {
var timer = null;
function debounce(fn,time){
if (null === timer){
timer = setTimeout(function(){
timer = null;
fn();
}, time);
}
}
function callbackJquery() {
liveblog.load("https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/3.5.14/iframeResizer.min.js", function() {
var iframe = jQuery('#liveblog-iframe');
iFrameResize({
minHeight: 1000,
heightCalculationMethod: 'lowestElement'
}, iframe[0]);
var reached = false;
var detectEndOfBlog = function() {
if (jQuery(window).scrollTop() > iframe.height() + iframe.offset().top - 50 - jQuery(window).height()) {
if (reached) {
return;
}
iframe.get(0).contentWindow.postMessage('loadMore', '*');
reached = true;
} else {
reached = false;
}
};
jQuery(window).scroll(function(){
debounce(detectEndOfBlog, 200, true);
});
});
};
if (typeof jQuery === "undefined") {
liveblog.load("https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js", callbackJquery);
} else {
// maybe add version support here.
callbackJquery();
}
};
}