turn.js/demos/minimal/index.html
2026-06-08 17:13:58 +02:00

204 lines
5.1 KiB
HTML

<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>turn.js - exemple minimal</title>
<style>
html,
body {
margin: 0;
min-height: 100%;
font-family: Arial, sans-serif;
background: #eef1f5;
color: #1f2937;
}
main {
min-height: 100vh;
display: grid;
align-content: center;
justify-items: center;
gap: 18px;
padding: 28px;
box-sizing: border-box;
}
#book {
width: 720px;
height: 460px;
background: #cbd3df;
}
#book .page {
display: flex;
flex-direction: column;
gap: 16px;
width: 360px;
height: 460px;
box-sizing: border-box;
padding: 28px;
border: 1px solid #aeb8c8;
background: #fff8df;
font-size: 18px;
line-height: 1.2;
}
#book .page:nth-child(even) {
background: #e7f1ff;
}
#book .page h1,
#book .page h2 {
margin: 0;
font-size: 30px;
line-height: 1.05;
}
#book .page p {
margin: 0;
line-height: 1.45;
}
#book .page img {
display: block;
width: 100%;
height: 180px;
object-fit: cover;
border: 1px solid #aeb8c8;
background: #fff;
}
.kicker {
font-size: 12px;
font-weight: bold;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #536173;
}
.controls {
display: flex;
gap: 10px;
align-items: center;
font-size: 15px;
}
button {
min-width: 96px;
min-height: 38px;
border: 1px solid #9aa7ba;
border-radius: 6px;
background: #fff;
color: #1f2937;
font: inherit;
cursor: pointer;
}
button:hover {
background: #f6f8fb;
}
#status {
min-width: 92px;
text-align: center;
}
@media (max-width: 820px) {
#book {
width: 92vw;
height: 58vw;
max-height: 460px;
}
}
</style>
</head>
<body>
<main>
<div id="book">
<div class="page">
<span class="kicker">Demo minimale</span>
<h1>Explorer turn.js</h1>
<img src="assets/cover.svg" alt="Livre ouvert avec pages colorees">
<p>Un exemple autonome pour verifier rapidement le chargement de jQuery 4, l'initialisation du plugin et le changement de page.</p>
</div>
<div class="page">
<span class="kicker">Page 2</span>
<h2>Un livre HTML</h2>
<p>Chaque page est un simple element HTML. Le plugin ajoute les wrappers, gere les vues et anime le passage d'une page a l'autre.</p>
<img src="assets/layout.svg" alt="Composition de pages dans un navigateur">
</div>
<div class="page">
<span class="kicker">Page 3</span>
<h2>Images et texte</h2>
<img src="assets/media.svg" alt="Image abstraite avec cadres de contenu">
<p>La demo contient du texte et des images locales afin de tester un rendu un peu plus proche d'un cas reel.</p>
</div>
<div class="page">
<span class="kicker">Page 4</span>
<h2>Navigation</h2>
<p>Utilise les boutons, les fleches du clavier ou le coin de page pour changer de vue.</p>
<img src="assets/navigation.svg" alt="Fleches de navigation autour d'un livre">
</div>
<div class="page">
<span class="kicker">Page 5</span>
<h2>Compatibilite</h2>
<img src="assets/browser.svg" alt="Fenetre de navigateur avec indicateurs de compatibilite">
<p>Cette page charge jQuery 4.0.0 depuis le CDN officiel et la version locale de turn.js depuis le depot clone.</p>
</div>
<div class="page">
<span class="kicker">Page 6</span>
<h2>Fin du test</h2>
<p>Si cette derniere page s'affiche et que le retour fonctionne, le scenario minimal est operationnel.</p>
<img src="assets/finish.svg" alt="Marque de validation sur une page">
</div>
</div>
<div class="controls">
<button type="button" id="previous">Previous</button>
<span id="status">Page 1</span>
<button type="button" id="next">Next</button>
</div>
</main>
<script src="https://code.jquery.com/jquery-4.0.0.min.js"></script>
<script src="../../turn.js"></script>
<script>
$(function() {
var $book = $('#book');
var $status = $('#status');
function updateStatus() {
$status.text('Page ' + $book.turn('page') + ' / ' + $book.turn('pages'));
}
$book.turn({
width: 720,
height: 460,
display: 'double',
gradients: true,
acceleration: true,
when: {
turned: updateStatus
}
});
$('#previous').on('click', function() {
$book.turn('previous');
});
$('#next').on('click', function() {
$book.turn('next');
});
$(document).on('keydown', function(event) {
if (event.key === 'ArrowLeft') $book.turn('previous');
if (event.key === 'ArrowRight') $book.turn('next');
});
updateStatus();
});
</script>
</body>
</html>