Skip to content

Commit

Permalink
Fixed sprite dragging (see template)
Browse files Browse the repository at this point in the history
  • Loading branch information
SheepTester committed Aug 10, 2021
1 parent 321be68 commit de4c45e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion index.bundle.min.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ <h2 id="updates">Update history</h2>
See the code and previous versions on
<a href="https://github.com/SheepTester/htmlifier/">Github</a>.
</p>
<h3>
2021-08-09 (<a
href="https://github.com/SheepTester/htmlifier/releases/download/v1.0.1/htmlifier-offline.html"
>download</a
>)
</h3>
<ul>
<li>Fixed sprite dragging.</li>
</ul>
<h3>
2021-08-08 (<a
href="https://github.com/SheepTester/htmlifier/releases/download/v1.0.0/htmlifier-offline.html"
Expand Down
2 changes: 1 addition & 1 deletion node/index.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sheeptester/htmlifier",
"version": "1.0.0",
"version": "1.0.1",
"description": "Packages a Scratch project in an HTML file with no optimisations.",
"type": "module",
"main": "index.min.js",
Expand Down
6 changes: 3 additions & 3 deletions src/template/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,11 +558,11 @@ window.init = async ({ width, height, ...options }) => {
canvasWidth: rect.width,
canvasHeight: rect.height
})
return mousePosition
return { mousePosition, rect }
}
function handleMouseMove (event) {
if (postIfPointerLocked(event)) return
const mousePosition = postMouse(event)
const { mousePosition, rect } = postMouse(event)
if (mouseDown && !isDragging) {
const distanceFromMouseDown = Math.hypot(
mousePosition.x - mouseDownPosition.x,
Expand Down Expand Up @@ -594,7 +594,7 @@ window.init = async ({ width, height, ...options }) => {
isDown: true
})
if (postIfPointerLocked(event, true)) return
mouseDownPosition = postMouse(event, true)
mouseDownPosition = postMouse(event, true).mousePosition
mouseDownTimeoutId = setTimeout(handleStartDrag, 400)
event.preventDefault()
if (!document.body.classList.contains('asking')) {
Expand Down

0 comments on commit de4c45e

Please sign in to comment.