/
example-basic.html
executable file
·74 lines (65 loc) · 2.92 KB
/
example-basic.html
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>text-zoom-resize example #1 - 3 Dev Adam</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/3-dev-adam-poster.css">
</head>
<body>
<div class="demo">
<div class="image">
<picture>
<source media="(max-width: 570px)" srcset="images/3-dev-adam-poster.jpg" />
<source media="(min-width: 571px)" srcset="images/3-dev-adam-poster-widescreen.jpg" />
<img
src="images/3-dev-adam-poster-widescreen.jpg"
alt="Photo from the movie '3 Dev Adam': Turkish Captain America is trying to save Julie from the Evil Turkish Spiderman."
/>
</picture>
</div>
<div class="text">
<div class="text-top text-label">
Text Zoom - Simple example
</div>
<div class="text-bottom text-label">
3 Dev Adam is a 1973 Turkish cult superhero film in which
Captain America and El Santo have to defeat evil crime lord Spider-Man.
</div>
</div>
</div>
<div class="demo-explanation">
<p><strong id="resize-factor"></strong></p>
<p>If you zoom the text in this demo over 113%, you will see
this text reposition itself to ensure it doesn't obscure important
parts of this photo. For more information about this demo, please read
<a href="https://www.useragentman.com/blog/2019/04/07/how-to-style-resized-text-and-quickly-fix-wcag-1-4-4-issues/">
the blog post about the text-zoom-event js library</a>.
</p>
</div>
<script src="dist/textZoomEvent-es4.js"></script>
<script>
const body = document.body;
const resizeFactorEl = document.getElementById('resize-factor');
function setCssTextZoomFactor() {
const resizeFactor = textZoomEvent.resizeFactor();
if (resizeFactor > 1.13) {
body.classList.add('text-zoom-113');
} else {
body.classList.remove('text-zoom-113');
}
// show resize factor on the screen
resizeFactorEl.innerHTML = 'This page has text zoomed to ' + resizeFactor * 100 + '% of the original font size.';
//window.alert(resizeFactor);
}
// It is better if you give this the value of
// parseFloat(getComputedStyle(document.documentElement).fontSize
// when the doc is not zoomed.
textZoomEvent.init(16);
setCssTextZoomFactor();
document.addEventListener('textzoom', setCssTextZoomFactor);
</script>
</body>
</html>