Skip to content

Commit 8334c7e

Browse files
authored
Merge pull request #445 from BeAPI/feat/disable-animation
feat (theme): added url parameter to disable animations
2 parents 903afee + 20c80fe commit 8334c7e

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

header.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
<script type="text/javascript">
88
//<![CDATA[
99
(function(){
10-
function replaceHtmlClass(regexp, str) {
11-
var h = document.documentElement;
12-
h.className = h.className.replace(regexp, str);
13-
}
14-
15-
replaceHtmlClass(/no-js/, 'js');
16-
17-
if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
18-
replaceHtmlClass(/no-js-animation/, 'js-animation');
19-
}
10+
const html = document.documentElement;
11+
html.className = html.className.replace(/no-js/, 'js');
12+
<?php
13+
if ( ! isset( $_GET['js_animation'] ) || $_GET['js_animation'] !== 'false' ) :
14+
?>
15+
if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
16+
html.className = html.className.replace(/no-js-animation/, 'js-animation');
17+
}
18+
<?php
19+
endif;
20+
?>
2021
})();
2122
//]]>
2223
</script>

0 commit comments

Comments
 (0)