-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix wrong getTouches at TouchMouseEventInput (#213)
* fix: fix getTouches at TouchMouseEventInput * chore: add manual test * test: add eventInput unit test
- Loading branch information
Showing
6 changed files
with
211 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>egjs-axes</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1 user-scalable=no"> | ||
<style> | ||
#area { | ||
display: flex; | ||
justify-content: center; | ||
position:relative; | ||
width:100%; height:200px; | ||
-webkit-perspective: 300px; | ||
-moz-perspective: 300px; | ||
-ms-perspective: 300px; | ||
-o-perspective: 300px; | ||
perspective: 300px; | ||
background: #f5f5f5; | ||
border-radius: 4px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
#box { | ||
position:absolute; | ||
left:50%; top:50%; | ||
-webkit-transform-style: preserve-3d; | ||
-moz-transform-style: preserve-3d; | ||
-ms-transform-style: preserve-3d; | ||
-o-transform-style: preserve-3d; | ||
transform-style: preserve-3d; | ||
} | ||
|
||
.face { | ||
position:absolute; | ||
width:100px; height:100px; | ||
color: hsla(0,0%,20%,1); | ||
text-shadow: hsla(0,0%,40%,.5) 0 -1px 0, hsla(0,0%,100%,.6) 0 2px 1px; | ||
text-align: center; | ||
font-size:2.5em; font-weight:bold; | ||
text-align:center; line-height:2.5; | ||
-webkit-backface-visibility:hidden; | ||
-moz-backface-visibility:hidden; | ||
-ms-backface-visibility:hidden; | ||
-o-backface-visibility:hidden; | ||
backface-visibility:hidden; | ||
-webkit-border-radius:4px; | ||
-moz-border-radius:4px; | ||
-ms-border-radius:4px; | ||
-o-border-radius:4px; | ||
border-radius:4px; | ||
background: | ||
repeating-radial-gradient( | ||
line at 0 0, | ||
#eee, | ||
#ccc 50px | ||
); | ||
} | ||
|
||
.metal-linear { | ||
width: 100px; | ||
height: 100px; | ||
-webkit-border-radius:4px; | ||
-moz-border-radius:4px; | ||
-ms-border-radius:4px; | ||
-o-border-radius:4px; | ||
border-radius:4px; | ||
background-image: -webkit-repeating-linear-gradient(left, hsla(0,0%,100%,0) 0%, hsla(0,0%,100%,0) 6%, hsla(0,0%,100%, .1) 7.5%), | ||
-webkit-repeating-linear-gradient(left, hsla(0,0%, 0%,0) 0%, hsla(0,0%, 0%,0) 4%, hsla(0,0%, 0%,.03) 4.5%), | ||
-webkit-repeating-linear-gradient(left, hsla(0,0%,100%,0) 0%, hsla(0,0%,100%,0) 1.2%, hsla(0,0%,100%,.15) 2.2%), | ||
linear-gradient(180deg, hsl(0,0%,78%) 0%, | ||
hsl(0,0%,90%) 47%, | ||
hsl(0,0%,78%) 53%, | ||
hsl(0,0%,70%)100%); | ||
} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
<div> | ||
<p>You can rotate the cube using two axes.</p> | ||
<div id="area"> | ||
<div id="test"> | ||
<div id="box"> | ||
<div class="face metal-linear" style="-webkit-transform:rotateX(0deg) rotateY(0deg) translate3d(-50px,-50px,50px);">1</div> | ||
<div class="face metal-linear" style="-webkit-transform:rotateY(-90deg) translate3d(0px,-50px,100px);">2</div> | ||
<div class="face metal-linear" style="-webkit-transform:rotateY(90deg) translate3d(0px,-50px,0px);">3</div> | ||
<div class="face metal-linear" style="-webkit-transform:rotateX(90deg) translate3d(-50px,0px,100px);">4</div> | ||
<div class="face metal-linear" style="-webkit-transform:rotateY(180deg) translate3d(50px,-50px,50px);">5</div> | ||
<div class="face metal-linear" style="-webkit-transform:rotateX(-90deg) translate3d(-50px,0px,0px);">6</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<script src="../../dist/axes.pkgd.js"></script> | ||
<script src="js/cube.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const box = document.getElementById("box"); | ||
|
||
// 1. Initialize eg.Axes | ||
const axes = new eg.Axes({ | ||
rotateX: { | ||
range: [0, 360], | ||
circular: true | ||
}, | ||
rotateY: { | ||
range: [0, 360], | ||
circular: true | ||
} | ||
}, { | ||
deceleration: 0.0024 | ||
}); | ||
|
||
// 2. attach event handler | ||
axes.on("change", ({pos}) => { | ||
box.style[eg.Axes.TRANSFORM] = | ||
`rotateY(${pos.rotateX}deg) rotateX(${pos.rotateY}deg)`; | ||
}); | ||
|
||
// 3. Initialize a inputType and connect it | ||
axes.connect("rotateX rotateY", new eg.Axes.PanInput("#area")).connect("rotateX rotateY", new eg.Axes.MoveKeyInput("#area", {scale: [10, -10]})); | ||
|
||
// 4. move to position | ||
axes.setTo({ | ||
"rotateX": 40, | ||
"rotateY": 315 | ||
}, 100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters