Fixed scroll link
This commit is contained in:
parent
d0bee28c8b
commit
95127dcdc3
@ -96,9 +96,9 @@ define([
|
|||||||
height: scrollHeight - htmlSectionOffset
|
height: scrollHeight - htmlSectionOffset
|
||||||
});
|
});
|
||||||
|
|
||||||
// apply Scroll Link
|
// apply Scroll Link (-10 to have a gap > 9 px)
|
||||||
lastEditorScrollTop = editorElt.scrollTop();
|
lastEditorScrollTop = -10;
|
||||||
lastPreviewScrollTop = previewScrollTop;
|
lastPreviewScrollTop = -10;
|
||||||
runScrollLink();
|
runScrollLink();
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ define([
|
|||||||
var editorScrollTop = editorElt.scrollTop();
|
var editorScrollTop = editorElt.scrollTop();
|
||||||
var previewElt = $(".preview-container");
|
var previewElt = $(".preview-container");
|
||||||
var previewScrollTop = previewElt.scrollTop();
|
var previewScrollTop = previewElt.scrollTop();
|
||||||
function animate(srcScrollTop, srcSectionList, destElt, destSectionList, lastDestScrollTop, callback) {
|
function animate(srcScrollTop, srcSectionList, destElt, destSectionList, currentDestScrollTop, callback) {
|
||||||
// Find the section corresponding to the offset
|
// Find the section corresponding to the offset
|
||||||
var sectionIndex = undefined;
|
var sectionIndex = undefined;
|
||||||
var srcSection = _.find(srcSectionList, function(section, index) {
|
var srcSection = _.find(srcSectionList, function(section, index) {
|
||||||
@ -130,9 +130,9 @@ define([
|
|||||||
destScrollTop,
|
destScrollTop,
|
||||||
destElt.prop('scrollHeight') - destElt.outerHeight()
|
destElt.prop('scrollHeight') - destElt.outerHeight()
|
||||||
]);
|
]);
|
||||||
if(Math.abs(destScrollTop - lastDestScrollTop) < 9) {
|
if(Math.abs(destScrollTop - currentDestScrollTop) <= 9) {
|
||||||
// Skip the animation in case it's not necessary
|
// Skip the animation in case it's not necessary
|
||||||
callback(lastDestScrollTop);
|
callback(currentDestScrollTop);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
destElt.animate({
|
destElt.animate({
|
||||||
@ -146,7 +146,7 @@ define([
|
|||||||
isScrollEditor = false;
|
isScrollEditor = false;
|
||||||
// Animate the preview
|
// Animate the preview
|
||||||
lastEditorScrollTop = editorScrollTop;
|
lastEditorScrollTop = editorScrollTop;
|
||||||
animate(editorScrollTop, mdSectionList, previewElt, htmlSectionList, lastPreviewScrollTop, function(destScrollTop) {
|
animate(editorScrollTop, mdSectionList, previewElt, htmlSectionList, previewScrollTop, function(destScrollTop) {
|
||||||
lastPreviewScrollTop = destScrollTop;
|
lastPreviewScrollTop = destScrollTop;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ define([
|
|||||||
isScrollPreview = false;
|
isScrollPreview = false;
|
||||||
// Animate the editor
|
// Animate the editor
|
||||||
lastPreviewScrollTop = previewScrollTop;
|
lastPreviewScrollTop = previewScrollTop;
|
||||||
animate(previewScrollTop, htmlSectionList, editorElt, mdSectionList, lastEditorScrollTop, function(destScrollTop) {
|
animate(previewScrollTop, htmlSectionList, editorElt, mdSectionList, editorScrollTop, function(destScrollTop) {
|
||||||
lastEditorScrollTop = destScrollTop;
|
lastEditorScrollTop = destScrollTop;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user