Skip to content

Commit

Permalink
fix: released outside will be considered inside
Browse files Browse the repository at this point in the history
fixes #109
  • Loading branch information
yoannmoinet committed Aug 24, 2019
1 parent da736be commit 9a8a7b4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
28 changes: 28 additions & 0 deletions example/iframe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
body, html {
background: #333;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
iframe {
background: white;
width: 80%;
height: 80%;
margin-top: 10%;
margin-left: 10%;
}
</style>
</head>
<body>
<iframe src="./codepen-demo.html" frameborder="0"></iframe>
</body>
</html>
7 changes: 7 additions & 0 deletions src/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,13 @@ Collection.prototype.processOnMove = function (evt) {
var identifier = self.manager.getIdentifier(evt);
var nipple = self.nipples.get(identifier);

// If we're moving without pressing
// it's that we went out the active zone
if (!u.isPressed(evt)) {
this.processOnEnd(evt);
return;
}

if (!nipple) {
// This is here just for safety.
// It shouldn't happen.
Expand Down
7 changes: 7 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ export const degrees = (a) => {
return a * (180 / Math.PI);
};

export const isPressed = (evt) => {
if (isNaN(evt.buttons)) {
return evt.pressure !== 0;
}
return evt.buttons !== 0;
};

export const bindEvt = (el, arg, handler) => {
const types = arg.split(/[ ,]+/g);
let type;
Expand Down

0 comments on commit 9a8a7b4

Please sign in to comment.