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

Function cmBindScroll

static/editor.md/editormd.js:1715–1745  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1713 }
1714
1715 var cmBindScroll = function() {
1716 codeMirror.find(".CodeMirror-scroll").bind(mouseOrTouch("scroll", "touchmove"), function(event) {
1717 var height = $(this).height();
1718 var scrollTop = $(this).scrollTop();
1719 var percent = (scrollTop / $(this)[0].scrollHeight);
1720
1721 var tocHeight = 0;
1722
1723 preview.find(".markdown-toc-list").each(function(){
1724 tocHeight += $(this).height();
1725 });
1726
1727 var tocMenuHeight = preview.find(".editormd-toc-menu").height();
1728 tocMenuHeight = (!tocMenuHeight) ? 0 : tocMenuHeight;
1729
1730 if (scrollTop === 0)
1731 {
1732 preview.scrollTop(0);
1733 }
1734 else if (scrollTop + height >= $(this)[0].scrollHeight - 16)
1735 {
1736 preview.scrollTop(preview[0].scrollHeight);
1737 }
1738 else
1739 {
1740 preview.scrollTop((preview[0].scrollHeight + tocHeight + tocMenuHeight) * percent);
1741 }
1742
1743 $.proxy(settings.onscroll, _this)(event);
1744 });
1745 };
1746
1747 var cmUnbindScroll = function() {
1748 codeMirror.find(".CodeMirror-scroll").unbind(mouseOrTouch("scroll", "touchmove"));

Callers

nothing calls this directly

Calls 1

$Function · 0.50

Tested by

no test coverage detected