Animation avec scrollIntoView
Bonjour,
savez-vous s'il est possible d'ajouter une animation lors de la sélection d'un d'un scroll, j'ai regardé plusieurs exemple mais suis un peu perdu là...
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| <!DOCTYPE html>
<html>
<head>
<title>Exemple de scrollIntoView()</title>
<script>
function showIt(elID) {
var el = document.getElementById(elID);
el.scrollIntoView(true).scrollTop(300);
}
</script>
</head>
<body>
<div style="height: 80px; width: 30em; overflow: scroll;
border: 1px solid blue;">
<table>
<tr>
<td id="pToShow">Le paragraphe à afficher</td>
</tr>
<tr>
<td id="pToShow2">Le paragraphe à afficher</td>
</tr>
<tr>
<td id="pToShow3">Le paragraphe à afficher</td>
</tr>
<tr>
<td id="pToShow4"><p>Le paragraphe à afficher</p></td>
</tr>
<tr>
<td id="pToShow5">5 c'est le bon !</td>
</tr>
<tr>
<td id="pToShow6">Le paragraphe à afficher</td>
</tr>
<tr>
<td id="pToShow7">Le paragraphe à afficher</td>
</tr>
<tr>
<td id="pToShow8">Le paragraphe à afficher</td>
</tr>
<tr>
<td id="pToShow9">Le paragraphe à afficher</td>
</tr>
<tr>
<td id="pToShow10">Le paragraphe à afficher</td>
</tr>
</table>
</div>
<input type="button" value="Afficher le paragraphe"
onclick="showIt('pToShow5');">
</body>
</html> |