});
$(window).on('mousemove', function (e) {
- let x = e.pageX;
- let w = $(this).innerWidth()
- let ratio = x / w * 100
+ let panelWidth = $("#markdown-revision")[0].getBoundingClientRect().width
+ var x = e.pageX
+ var w = $(this).innerWidth()
if($(".handle").hasClass("dragging")) {
+ if($(".handle.dragging").hasClass("preview-handle")) {
+ x = Math.max(0, e.pageX - panelWidth)
+ w = $(this).innerWidth() - panelWidth
+ }
+
+ let ratio = x / w * 100
+
$("body").addClass("user-select-none")
requestAnimationFrame(function() {
$(".handle.dragging").parent().width(ratio+'%')
})
- if($("#markdown-page img")[0].getBoundingClientRect().top < $("body")[0].getBoundingClientRect().top
- || $("#markdown-page img")[0].getBoundingClientRect().bottom > $("body")[0].getBoundingClientRect().bottom){
+ if($("#markdown-preview img")[0].getBoundingClientRect().top < $("#markdown-preview")[0].getBoundingClientRect().top
+ || $("#markdown-preview img")[0].getBoundingClientRect().bottom > $("body")[0].getBoundingClientRect().bottom){
$("#markdown-preview").addClass("overtake")
}else {
$("#markdown-preview").removeClass("overtake")
},
loadPageHtml: function(p) {
- const container = document.querySelector("#markdown-page")
+ const container = document.querySelector("#markdown-preview .markdown-wrapper")
var imageFormat = FLUIDBOOK_DATA.settings.imageFormat ?? 'jpg';
var c = '<div class="contents">';
@section('content')
@include('fluidbook_publication.link_editor_icons')
<div class="markdown">
- <div class="markdown-revision">
+ <div id="markdown-revision" class="markdown-revision">
<div class="markdown-revision-nav">
<a href="#" id="linkeditor-icon-versions" data-panel="form" data-icon="wayback-machine"
data-action="panels.toggleForm"
</div>
<div id="markdown-preview" class="markdown-container">
<div class="markdown-wrapper">
- <div draggable="false" class="markdown-page" id="markdown-page"></div>
</div>
- <div class="handle"></div>
+ <div class="handle preview-handle"></div>
</div>
<div class="markdown-editor-container">
<div id="editor"></div>