-
Notifications
You must be signed in to change notification settings - Fork 0
/
mathjax_pop-out.html
95 lines (90 loc) · 2.89 KB
/
mathjax_pop-out.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MathJax Pop-Out Window</title>
<!-- MathJax Configuration -->
<script type="text/javascript">
window.MathJax = {
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']],
displayMath: [['$$', '$$'], ['\\[', '\\]']]
},
svg: { fontCache: 'global' },
startup: {
ready() {
MathJax.startup.defaultReady();
console.log('MathJax is ready, version', MathJax.version);
}
}
};
</script>
<script src="resources/MathJax/es5/tex-mml-svg.js"></script>
<style>
body, html {
height: 100%;
width: 100%;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}
#scale-slider {
width: 300px;
position: absolute;
top: 20px;
left: 50%;
transform: translateX(-50%);
}
#math-wrapper {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
#math-content {
display: flex;
justify-content: center;
align-items: center;
transition: transform 0.3s ease;
transform-origin: center;
}
</style>
</head>
<body>
<input type="range" id="scale-slider" min="1.0" max="3.0" step="0.1" value="1">
<div id="math-wrapper">
<div id="math-content">
<p>result: $$E = mc^2$$</p>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const slider = document.getElementById('scale-slider');
const mathContent = document.getElementById('math-content');
slider.addEventListener('input', function() {
const scaleValue = slider.value;
mathContent.style.transform = `scale(${scaleValue})`;
console.log(`Scale set to: ${scaleValue}`);
});
slider.addEventListener('mouseup', function() {
centerContent(mathContent);
});
window.addEventListener('resize', function() {
centerContent(mathContent);
});
// Initial centering
centerContent(mathContent);
function centerContent(content) {
content.style.position = 'absolute';
content.style.left = '50%';
content.style.top = '50%';
content.style.transform = `translate(-50%, -50%) scale(${slider.value})`;
}
});
</script>
</body>
</html>