Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #79 from readium/develop
Browse files Browse the repository at this point in the history
1.0.6
  • Loading branch information
aferditamuriqi authored Dec 9, 2018
2 parents 37c1b28 + de36714 commit 678d44c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
30 changes: 20 additions & 10 deletions R2Streamer/scripts/touchHandling.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var startX = 0;
var startY = 0;
var maxScreenX = 0;
var maxScreenY = 0;
var touchStartTime = null;

window.addEventListener("load", function(){ // on page load
// Get screen X and Y sizes.
Expand Down Expand Up @@ -47,13 +48,22 @@ var handleTouchStart = function(event) {

startX = touch.screenX % maxScreenX;
startY = touch.screenY % maxScreenY;

touchStartTime = Date.now();
};

// When a touch ends, check if any action has to be made, and contact native code.
var handleTouchEnd = function(event) {
if(!singleTouchGesture) {
return;
}

if(touchStartTime != null && Date.now() - touchStartTime > 500) {
touchStartTime = null;
return;
}
touchStartTime = null;

//https://stackoverflow.com/questions/4878484/difference-between-tagname-and-nodename
if (event.target.nodeName == "input") {return}

Expand All @@ -65,17 +75,17 @@ var handleTouchEnd = function(event) {

// Tap to turn.
if(touchDistance < 0.01) {
//var position = Math.abs(touch.clientX % maxScreenX) / maxScreenX;
var position;

if (maxScreenX == window.innerWidth) {
// No scroll and default zoom
position = touch.clientX / document.body.clientWidth
} else {
// FXL
position = touch.screenX / document.body.clientWidth
}
var position = touch.clientX / window.innerWidth;

// if (maxScreenX == window.innerWidth) {
// // No scroll and default zoom
// position = touch.clientX / window.innerWidth;
// } else {
// // FXL
// // Looks like this is the ratio in document space instead of screen space
// // position = touch.screenX / document.body.clientWidth;
// }

if (position <= 0.2) {
// TAP left.
console.log("LeftTapped");
Expand Down
10 changes: 6 additions & 4 deletions R2Streamer/scripts/utils-old.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ var scrollLeft = function(dir) {
} else {
var oldOffset = window.scrollX;
document.body.scrollLeft = newEdge;
if (oldOffset != newEdge) {
var diff = Math.abs(newEdge-oldOffset)/window.innerWidth;
// In some case the scrollX cannot reach the position respecting to innerWidth
if (diff > 0.01) {
return 0;
} else {
return "edge";
}
}
}

};

var scrollRight = function(dir) {
Expand All @@ -95,14 +96,15 @@ var scrollRight = function(dir) {
} else {
var oldOffset = window.scrollX;
document.body.scrollLeft = newEdge;
if (oldOffset != newEdge) {
var diff = Math.abs(newEdge-oldOffset)/window.innerWidth;
// In some case the scrollX cannot reach the position respecting to innerWidth
if (diff > 0.01) {
return 0;
} else {
return "edge";
}
}
}

};

// Snap the offset to the screen width (page width).
Expand Down
10 changes: 6 additions & 4 deletions R2Streamer/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ var scrollLeft = function(dir) {
} else {
var oldOffset = window.scrollX;
document.body.scrollLeft = newEdge;
if (oldOffset != newEdge) {
var diff = Math.abs(newEdge-oldOffset)/window.innerWidth;
// In some case the scrollX cannot reach the position respecting to innerWidth
if (diff > 0.01) {
return 0;
} else {
return "edge";
}
}
}

};

var scrollRight = function(dir) {
Expand All @@ -95,14 +96,15 @@ var scrollRight = function(dir) {
} else {
var oldOffset = window.scrollX;
document.body.scrollLeft = newEdge;
if (oldOffset != newEdge) {
var diff = Math.abs(newEdge-oldOffset)/window.innerWidth;
// In some case the scrollX cannot reach the position respecting to innerWidth
if (diff > 0.01) {
return 0;
} else {
return "edge";
}
}
}

};

// Snap the offset to the screen width (page width).
Expand Down
1 change: 1 addition & 0 deletions Sources/fetcher/ContentFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ let cjkHorizontalPreset: [ReadiumCSSName: Bool] = [
.letterSpacing: false]

let cjkVerticalPreset: [ReadiumCSSName: Bool] = [
.scroll: true,
.columnCount: false,
.textAlignment: false,
.hyphens: false,
Expand Down

0 comments on commit 678d44c

Please sign in to comment.