This repository has been archived by the owner on Jul 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from readium/develop
1.1.5
- Loading branch information
Showing
72 changed files
with
12,070 additions
and
1,150 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @aferditamuriqi |
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 was deleted.
Oops, something went wrong.
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,27 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>DiViNa Player</title> | ||
<style type="text/css"> | ||
body, html { | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
overflow: hidden; | ||
background-color: rgb(0, 0, 0); | ||
} | ||
</style> | ||
<script type="text/javascript" src="./divinaTouchHandling.js"></script> | ||
<script type="text/javascript" src="./divinaPlayer.js"></script> | ||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
var player = null | ||
window.onload = function() { | ||
const Player = window.divinaPlayer | ||
player = new Player(window.document.body) | ||
} | ||
</script> | ||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
r2-navigator/src/main/assets/divina/divinaTouchHandling.js
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,65 @@ | ||
var singleTouchGesture = false; | ||
var startX = 0; | ||
var startY = 0; | ||
var availWidth = window.screen.availWidth; | ||
var availHeight = window.screen.availHeight; | ||
|
||
|
||
window.addEventListener("load", function(){ // on page load | ||
// Get screen X and Y sizes. | ||
// Events listeners for the touches. | ||
window.document.addEventListener("touchstart", handleTouchStart, false); | ||
window.document.addEventListener("touchend", handleTouchEnd, false); | ||
// When device orientation changes, screen X and Y sizes are recalculated. | ||
}, false); | ||
|
||
|
||
|
||
// When a touch is detected records its starting coordinates and if it's a singleTouchGesture. | ||
var handleTouchStart = function(event) { | ||
if (event.target.nodeName.toUpperCase() === 'A') { | ||
console.log("Touched a link."); | ||
// singleTouchGesture = false; | ||
return; | ||
} | ||
console.log("Touch sent to native code."); | ||
singleTouchGesture = event.touches.length == 1; | ||
|
||
var touch = event.changedTouches[0]; | ||
|
||
startX = touch.screenX % availWidth; | ||
startY = touch.screenY % availHeight; | ||
|
||
}; | ||
|
||
// When a touch ends, check if any action has to be made, and contact native code. | ||
var handleTouchEnd = function(event) { | ||
if(!singleTouchGesture) { | ||
return; | ||
} | ||
|
||
var touch = event.changedTouches[0]; | ||
|
||
var relativeDistanceX = Math.abs(((touch.screenX % availWidth) - startX) / availWidth); | ||
var relativeDistanceY = Math.abs(((touch.screenY % availHeight) - startY) / availHeight); | ||
var touchDistance = Math.max(relativeDistanceX, relativeDistanceY); | ||
|
||
var scrollWidth = document.scrollWidth; | ||
var screenWidth = availWidth; | ||
var tapAreaWidth = availWidth * 0.2; | ||
|
||
if(touchDistance < 0.01) { | ||
var position = (touch.screenX % availWidth) / availWidth; | ||
if (position <= 0.2) { | ||
console.log("LeftTapped"); | ||
} else if(position >= 0.8) { | ||
console.log("RightTapped"); | ||
} else { | ||
console.log("CenterTapped"); | ||
Android.centerTapped(); | ||
} | ||
event.stopPropagation(); | ||
event.preventDefault(); | ||
return; | ||
} | ||
}; |
Oops, something went wrong.