1
0
mirror of https://github.com/24eme/signaturepdf.git synced 2023-08-25 09:33:08 +02:00

Fixed drag and drop when page changes line

This commit is contained in:
Vincent LAURENT 2022-10-07 01:41:30 +02:00
parent c300673ab1
commit ebc92a17e5
2 changed files with 17 additions and 3 deletions

View File

@ -120,10 +120,24 @@ var loadPDF = async function(pdfBlob, filename, pdfIndex) {
if (e.preventDefault) { if (e.preventDefault) {
e.preventDefault(); e.preventDefault();
} }
if(e.layerX > e.target.clientWidth / 2) { let element = this;
// vers le haut
if(this.offsetTop < document.querySelector('#'+e.dataTransfer.getData('element')).offsetTop && e.layerX <= element.clientWidth / 2) {
element = this.previousSibling;
}
// vers le bas
if(this.offsetTop > document.querySelector('#'+e.dataTransfer.getData('element')).offsetTop && e.layerX > element.clientWidth / 2) {
element = this.nextSibling;
}
if(!element.draggable && !this.previousSibling.draggable) {
this.insertAdjacentElement('beforebegin', document.querySelector('#'+e.dataTransfer.getData('element'))); this.insertAdjacentElement('beforebegin', document.querySelector('#'+e.dataTransfer.getData('element')));
} else if(!element.draggable && !this.nextSibling.draggable) {
this.insertAdjacentElement('beforebegin', document.querySelector('#'+e.dataTransfer.getData('element')));
} else if (e.layerX > element.clientWidth / 2) {
element.insertAdjacentElement('beforebegin', document.querySelector('#'+e.dataTransfer.getData('element')));
} else { } else {
this.insertAdjacentElement('afterend', document.querySelector('#'+e.dataTransfer.getData('element'))); element.insertAdjacentElement('afterend', document.querySelector('#'+e.dataTransfer.getData('element')));
} }
return false; return false;

View File

@ -103,6 +103,6 @@
<script> <script>
var maxSize = <?php echo $maxSize ?>; var maxSize = <?php echo $maxSize ?>;
</script> </script>
<script src="/js/organization.js?202205310125"></script> <script src="/js/organization.js?202210070140"></script>
</body> </body>
</html> </html>