Mutualisation de code, scroll sur la div en mode desktop

This commit is contained in:
Vincent LAURENT 2021-10-11 01:17:06 +02:00
parent 5b2ae3a80e
commit 08465b5d4e
2 changed files with 29 additions and 29 deletions

View File

@ -18,17 +18,32 @@ loadingTask.promise.then(function(pdf) {
var pdfRenderTasks = [];
var pdfPages = [];
var svgCollections = [];
var is_mobile = !(window.getComputedStyle(document.getElementById('is_mobile')).display === "none");
var resizeTimeout;
var currentScale = 1.5;
var windowWidth = window.innerWidth;
var menu = document.getElementById('offcanvasTop')
var menuOffcanvas = new bootstrap.Offcanvas(menu)
if(is_mobile) {
menu.classList.remove('show');
menuOffcanvas.hide();
var is_mobile = function() {
return !(window.getComputedStyle(document.getElementById('is_mobile')).display === "none");
}
menu.classList.remove('d-md-block');
menu.classList.remove('d-none');
var responsiveDisplay = function() {
if(is_mobile()) {
document.body.style.paddingRight = "";
menu.classList.remove('show');
menuOffcanvas.hide();
document.getElementById('container-pages').classList.remove('vh-100');
} else {
menuOffcanvas.show();
document.body.style.paddingRight = "350px";
document.getElementById('container-pages').classList.add('vh-100');
}
menu.classList.remove('d-md-block');
menu.classList.remove('d-none');
}
responsiveDisplay();
if(localStorage.getItem('svgCollections')) {
svgCollections = JSON.parse(localStorage.getItem('svgCollections'));
@ -64,7 +79,7 @@ loadingTask.promise.then(function(pdf) {
canvasEdition.defaultCursor = 'default';
}
})
if(is_mobile) {
if(is_mobile()) {
menuOffcanvas.hide();
}
});
@ -407,25 +422,14 @@ loadingTask.promise.then(function(pdf) {
canvas.add(svg).renderAll();
});
}
var resizeTimeout;
var currentScale = 1.5;
var windowWidth = window.innerWidth;
window.addEventListener('resize', function(event) {
event.preventDefault() && event.stopPropagation();
if(windowWidth == window.innerWidth) {
return;
}
responsiveDisplay();
windowWidth = window.innerWidth;
is_mobile = !(window.getComputedStyle(document.getElementById('is_mobile')).display === "none");
if(is_mobile) {
menu.classList.remove('show');
menuOffcanvas.hide();
} else {
menuOffcanvas.show();
}
menu.classList.remove('d-md-block');
menu.classList.remove('d-none');
autoZoom();
});
document.addEventListener('wheel', function(event) {

View File

@ -23,15 +23,12 @@
</style>
<title>Signature PDF</title>
</head>
<body class="bg-light">
<div class="container-fluid">
<body class="bg-light" style="padding-right: 350px;">
<div style="height: 65px;" class="d-md-none"></div>
<div class="row">
<div id="container-pages" style="overflow-x: auto" class="col-xxl-9 col-xl-8 col-lg-7 col-md-6 col-sm-12 col-xs-12 pt-1 pb-1 text-center">
</div>
<div id="container-pages" style="overflow: auto" class="col-12 pt-1 pb-1 text-center vh-100">
</div>
<div style="height: 55px;" class="d-md-none"></div>
<div class="offcanvas offcanvas-end show d-none d-md-block shadow-sm" data-bs-backdrop="false" data-bs-scroll="true" data-keyboard="false" tabindex="-1" id="offcanvasTop" aria-labelledby="offcanvasTopLabel">
<div class="offcanvas offcanvas-end show d-none d-md-block shadow-sm" data-bs-backdrop="false" data-bs-scroll="true" data-keyboard="false" tabindex="-1" id="offcanvasTop" aria-labelledby="offcanvasTopLabel" style="width: 350px;">
<div class="offcanvas-header">
<h5 id="offcanvasTopLabel">Signature du PDF</h5>
<button type="button" class="btn-close text-reset d-md-none" data-bs-dismiss="offcanvas" aria-label="Close"></button>
@ -126,7 +123,6 @@
</div>
</div>
</div>
</div>
<span id="is_mobile" class="d-md-none"></span>
<script src="/vendor/bootstrap.min.js?5.1.1"></script>