Browse Source

Fixed Toolbar auto fixed position bugs #292

develop
pandao 6 years ago
parent
commit
8cfdb6831b
  1. 6
      editormd.amd.js
  2. 2
      editormd.amd.min.js
  3. 6
      editormd.js
  4. 2
      editormd.min.js
  5. 15
      examples/toolbar-auto-fixed.html
  6. 6
      src/editormd.js

6
editormd.amd.js

@ -1085,11 +1085,12 @@
return false;
}
if (top - editor.offset().top > 10 && top < editor.height()) {
// Fixed #292
if (top - editor.offset().top > 10 && top - editor.offset().top < editor.height() - toolbar.height()) {
toolbar.css({
position : "fixed",
width : editor.width() + "px",
left : ($window.width() - editor.width()) / 2 + "px"
left : editor.offset().left + 1 + "px"
});
} else {
toolbar.css({
@ -1102,6 +1103,7 @@
if (!state.fullscreen && !state.preview && settings.toolbar && settings.toolbarAutoFixed) {
$(window).bind("scroll", autoFixedHandle);
$(window).bind("resize", autoFixedHandle);
}
return this;

2
editormd.amd.min.js

File diff suppressed because one or more lines are too long

6
editormd.js

@ -1015,11 +1015,12 @@
return false;
}
if (top - editor.offset().top > 10 && top < editor.height()) {
// Fixed #292
if (top - editor.offset().top > 10 && top - editor.offset().top < editor.height() - toolbar.height()) {
toolbar.css({
position : "fixed",
width : editor.width() + "px",
left : ($window.width() - editor.width()) / 2 + "px"
left : editor.offset().left + 1 + "px"
});
} else {
toolbar.css({
@ -1032,6 +1033,7 @@
if (!state.fullscreen && !state.preview && settings.toolbar && settings.toolbarAutoFixed) {
$(window).bind("scroll", autoFixedHandle);
$(window).bind("resize", autoFixedHandle);
}
return this;

2
editormd.min.js

File diff suppressed because one or more lines are too long

15
examples/toolbar-auto-fixed.html

@ -8,7 +8,7 @@
<link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />
</head>
<body>
<div id="layout" style="height:3000px;">
<div id="layout" style="height: 4000px;">
<header>
<h1>工具栏自动固定定位的开启与禁用</h1>
<p>Enable / disable toolbar auto fixed position.</p>
@ -16,6 +16,8 @@
<div class="btns">
<button id="enable-btn">Enable</button>
<button id="disable-btn">Disable</button>
<button id="set-offset-btn">Set editor offset(random)</button>
<button id="reset-offset-btn">Reset editor offset</button>
</div>
<div id="test-editormd">
<textarea style="display:none;">### Hello world!
@ -116,6 +118,17 @@ Bower Distribution of the Sparqlification Mapping Language (SML) Syntax Highligh
// or
//testEditor.config("toolbarAutoFixed", false);
});
$("#set-offset-btn").click(function () {
testEditor.editor.css({
marginLeft: editormd.rand(0, 200) + "px",
marginTop: editormd.rand(0, 1000) + "px"
})
});
$("#reset-offset-btn").click(function () {
testEditor.editor.css("margin", "0 auto");
});
});
</script>
</body>

6
src/editormd.js

@ -1003,11 +1003,12 @@
return false;
}
if (top - editor.offset().top > 10 && top < editor.height()) {
// Fixed #292
if (top - editor.offset().top > 10 && top - editor.offset().top < editor.height() - toolbar.height()) {
toolbar.css({
position : "fixed",
width : editor.width() + "px",
left : ($window.width() - editor.width()) / 2 + "px"
left : editor.offset().left + 1 + "px"
});
} else {
toolbar.css({
@ -1020,6 +1021,7 @@
if (!state.fullscreen && !state.preview && settings.toolbar && settings.toolbarAutoFixed) {
$(window).bind("scroll", autoFixedHandle);
$(window).bind("resize", autoFixedHandle);
}
return this;

Loading…
Cancel
Save