mirror of
https://github.com/blasten/turn.js.git
synced 2026-07-14 05:41:08 +08:00
266 lines
6.7 KiB
HTML
266 lines
6.7 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-frame {
|
|
width: min(720px, calc(100vw - 56px));
|
|
aspect-ratio: 72 / 46;
|
|
}
|
|
|
|
#book {
|
|
width: 100%;
|
|
height: 100%;
|
|
background: #cbd3df;
|
|
}
|
|
|
|
#book .page {
|
|
background: #fff8df;
|
|
overflow: hidden;
|
|
}
|
|
|
|
#book .page.alt {
|
|
background: #e7f1ff;
|
|
}
|
|
|
|
#book .page-content {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 16px;
|
|
box-sizing: border-box;
|
|
width: 100%;
|
|
height: 100%;
|
|
padding: 28px;
|
|
border: 1px solid #aeb8c8;
|
|
font-size: 18px;
|
|
line-height: 1.2;
|
|
overflow: hidden;
|
|
}
|
|
|
|
#book .page.alt .page-content {
|
|
background: #e7f1ff;
|
|
}
|
|
|
|
#book .page:not(.alt) .page-content {
|
|
background: #fff8df;
|
|
}
|
|
|
|
#book .page-content h1,
|
|
#book .page-content h2 {
|
|
margin: 0;
|
|
font-size: 30px;
|
|
line-height: 1.05;
|
|
}
|
|
|
|
#book .page-content p {
|
|
margin: 0;
|
|
line-height: 1.45;
|
|
}
|
|
|
|
#book .page-content 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: 620px) {
|
|
#book .page-content {
|
|
gap: 12px;
|
|
padding: 20px;
|
|
font-size: 15px;
|
|
}
|
|
|
|
#book .page-content h1,
|
|
#book .page-content h2 {
|
|
font-size: 24px;
|
|
}
|
|
|
|
#book .page-content img {
|
|
height: 130px;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<main>
|
|
<div class="book-frame">
|
|
<div id="book">
|
|
<div class="page">
|
|
<div class="page-content">
|
|
<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>
|
|
<div class="page alt">
|
|
<div class="page-content">
|
|
<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>
|
|
<div class="page">
|
|
<div class="page-content">
|
|
<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>
|
|
<div class="page alt">
|
|
<div class="page-content">
|
|
<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>
|
|
<div class="page">
|
|
<div class="page-content">
|
|
<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>
|
|
<div class="page alt">
|
|
<div class="page-content">
|
|
<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>
|
|
</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 $frame = $('.book-frame');
|
|
var $status = $('#status');
|
|
|
|
function currentBookSize() {
|
|
var width = Math.floor($frame.width());
|
|
if (width % 2) width -= 1;
|
|
return {
|
|
width: width,
|
|
height: Math.round(width * 460 / 720)
|
|
};
|
|
}
|
|
|
|
function syncBookSize() {
|
|
var size = currentBookSize();
|
|
$frame.css('height', size.height);
|
|
$book.turn('size', size.width, size.height);
|
|
}
|
|
|
|
function updateStatus() {
|
|
$status.text('Page ' + $book.turn('page') + ' / ' + $book.turn('pages'));
|
|
}
|
|
|
|
var initialSize = currentBookSize();
|
|
$frame.css('height', initialSize.height);
|
|
|
|
$book.turn({
|
|
width: initialSize.width,
|
|
height: initialSize.height,
|
|
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');
|
|
});
|
|
|
|
$(window).on('resize.turnDemo', syncBookSize);
|
|
|
|
updateStatus();
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|