add support for automatically scrolling code highlights into view

This commit is contained in:
Hakim El Hattab
2020-03-12 17:08:20 +01:00
parent 5a5a5c9a6c
commit bff9bfb101
7 changed files with 254 additions and 50 deletions

View File

@ -102,7 +102,7 @@
<section data-auto-animate>
<h2 data-id="code-title">With animations</h2>
<pre data-id="code-animation"><code class="hljs" data-trim data-line-numbers="|4|4,8-11">
<pre data-id="code-animation"><code class="hljs" data-trim data-line-numbers="|4,8-11|17|22-24">
import React, { useState } from 'react';
function Example() {
@ -117,6 +117,19 @@
&lt;/div&gt;
);
}
function SecondExample() {
const [count, setCount] = useState(0);
return (
&lt;div&gt;
&lt;p&gt;You clicked {count} times&lt;/p&gt;
&lt;button onClick={() =&gt; setCount(count + 1)}&gt;
Click me
&lt;/button&gt;
&lt;/div&gt;
);
}
</code></pre>
</section>