-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
139 lines (118 loc) · 3.54 KB
/
index.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + TS</title>
<style>
* {
margin: 0;
padding: 0;
}
ul {
margin-left: 1rem;;
}
body {
background-color: #1f1f1f;
color: whitesmoke;
font-family: sans-serif;
max-width: 80ch;
margin-inline: auto;
}
header {
display: flex;
flex-direction: column;
background-color: wheat;
color: black;
padding: 0.5rem;
}
hr {
margin-block: 1rem;
}
main {
display: flex;
flex-direction: column;
justify-content: center;
}
article {
margin-block: 1rem;
margin-left: 1rem;
padding-left: 1rem;
border-left: 2px solid gray;
}
h1 {
display: inline;
font-style: italic;
}
</style>
</head>
<body>
<header>
<h1 mq-speed-x="0.1" mq-tiled>markii.js </h1>
<p>a marquee replacement for the new year</p>
</header>
<hr />
<main data-nohover>
<article data-nohover>
<h2>introduction</h2>
<p><b>markii.js</b> is a JavaScript library (for modern browsers) that replicates/imitates (and aims to enhance
upon) the now deprecated
<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/marquee" rel="external"><marquee></a>
element.
</p>
</article>
<article mq-speed-x="0.001">
<h2>usage / demonstration</h2>
<p>when markii.js is on your site, any elements with the <code>mq-speed-x</code> or <code>mq-speed-y</code> attributes (which should be values between -1.0 and 1.0) will automatically become marquee elements.</p>
</article>
<article data-nohover>
<h2>play around</h2>
<button id="hover-btn">Click me to enable 'marquee on hover' mode</button>
<br/>
<input id="fill-btn" type="checkbox"/>
<label>Fill?</label>
</article>
<article>
<h2>caveats</h2>
<ul>
<li>Unfortunately, this library currently only works on the most recent versions of Chromium-based browsers. This is distressing as a Firefox user (and someone who cares about iOS marketshare). I will be implementing alternative rendering methods in the future.</li>
</ul>
</article>
</main>
<hr />
<footer data-nohover>
<p>by webcrawls</p>
</footer>
<script type="module">
import { Markii } from '/src/main.ts'
// init markii
const markii = new Markii()
// state
let enabled = false
let currentElement = null
let speedX = 0.01
// grab the button
const disabledText = "Click me to enable 'marquee on hover' mode"
const enabledText = "Click me to disable 'marquee on hover' mode"
const btn = document.querySelector("#hover-btn")
const updateText = () => btn.innerHTML = enabled ? enabledText : disabledText
btn.addEventListener('click', event => {
enabled = !enabled
updateText()
})
document.addEventListener("mouseover", event => {
if (!enabled || currentElement) return
let target = event.target
if (target === document.body || target.hasAttribute("data-nohover")) return;
if (currentElement) {
currentElement.removeAttribute("mq-speed-x")
}
currentElement = target
currentElement.setAttribute("mq-speed-x", "" + speedX)
if (document.querySelector("#fill-btn").value) {
// currentElement.setAttribute("data-marquee-fill", "true")
}
})
</script>
</body>
</html>