MCPcopy Create free account
hub / github.com/TruthHun/BookStack / cmBindScroll

Function cmBindScroll

static/editor.md/editormd.amd.js:1743–1773  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1741 }
1742
1743 var cmBindScroll = function() {
1744 codeMirror.find(".CodeMirror-scroll").bind(mouseOrTouch("scroll", "touchmove"), function(event) {
1745 var height = $(this).height();
1746 var scrollTop = $(this).scrollTop();
1747 var percent = (scrollTop / $(this)[0].scrollHeight);
1748
1749 var tocHeight = 0;
1750
1751 preview.find(".markdown-toc-list").each(function(){
1752 tocHeight += $(this).height();
1753 });
1754
1755 var tocMenuHeight = preview.find(".editormd-toc-menu").height();
1756 tocMenuHeight = (!tocMenuHeight) ? 0 : tocMenuHeight;
1757
1758 if (scrollTop === 0)
1759 {
1760 preview.scrollTop(0);
1761 }
1762 else if (scrollTop + height >= $(this)[0].scrollHeight - 16)
1763 {
1764 preview.scrollTop(preview[0].scrollHeight);
1765 }
1766 else
1767 {
1768 preview.scrollTop((preview[0].scrollHeight + tocHeight + tocMenuHeight) * percent);
1769 }
1770
1771 $.proxy(settings.onscroll, _this)(event);
1772 });
1773 };
1774
1775 var cmUnbindScroll = function() {
1776 codeMirror.find(".CodeMirror-scroll").unbind(mouseOrTouch("scroll", "touchmove"));

Callers

nothing calls this directly

Calls 1

$Function · 0.50

Tested by

no test coverage detected