Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace alert in canvas_api_tutorial #34629

Merged
merged 4 commits into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,8 @@ function draw() {
ctx.lineWidth = 10;

// check input
if (document.getElementById("miterLimit").value.match(/\d+(\.\d+)?/)) {
if (document.getElementById("miterLimit").checkValidity()) {
ctx.miterLimit = parseFloat(document.getElementById("miterLimit").value);
} else {
alert("Value must be a positive number");
}

// Draw lines
Expand All @@ -419,11 +417,9 @@ function draw() {
<td>
Change the <code>miterLimit</code> by entering a new value below and
clicking the redraw button.<br /><br />
<form onsubmit="return draw();">
<label for="miterLimit">Miter limit</label>
<input type="number" size="3" id="miterLimit" />
<input type="submit" value="Redraw" />
</form>
<label for="miterLimit">Miter limit</label>
<input type="number" id="miterLimit" size="3" min="1" />
<input type="submit" id="redraw" value="Redraw" />
</td>
</tr>
</table>
Expand All @@ -434,6 +430,9 @@ document.getElementById("miterLimit").value = document
.getElementById("canvas")
.getContext("2d").miterLimit;
draw();

const redraw = document.getElementById("redraw");
redraw.addEventListener("click", draw);
```

{{EmbedLiveSample("A_demo_of_the_miterLimit_property", "", "180")}}
Expand Down