-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from li-xiaoqing/dev
feat: 编辑器内容支持滚动,预览同步
- Loading branch information
Showing
4 changed files
with
174 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* 滚动条联动 | ||
*/ | ||
export function scrollLink(e, vue) { | ||
let element = e.srcElement ? e.srcElement : e.target | ||
let ratio = element.scrollTop / (element.scrollHeight - element.offsetHeight) | ||
if (vue.edit_scroll_height >= 0 && element.scrollHeight !== vue.edit_scroll_height && (element.scrollHeight - element.offsetHeight - element.scrollTop <= 30)) { | ||
// 内容变化 导致 高度增加 且滚动条距离底部小于25px 自动滚动到底部 | ||
vue.$refs.inputEdit.scrollTop = element.scrollHeight - element.offsetHeight | ||
ratio = 1 | ||
} | ||
vue.edit_scroll_height = element.scrollHeight | ||
// end ---- | ||
if (vue.$refs.renderHtml.scrollHeight > vue.$refs.renderHtml.offsetHeight) { | ||
vue.$refs.renderHtml.scrollTop = (vue.$refs.renderHtml.scrollHeight - vue.$refs.renderHtml.offsetHeight) * ratio | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters