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 #63 from readium/develop
Browse files Browse the repository at this point in the history
V1.0.3
  • Loading branch information
aferditamuriqi authored Jun 27, 2018
2 parents 98b171f + dfc99ec commit 2f18991
Show file tree
Hide file tree
Showing 26 changed files with 4,544 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cache:
before_install:
- brew update
- brew outdated carthage || brew upgrade carthage
- carthage bootstrap --verbose --no-use-binaries --platform iOS --cache-builds
- carthage update --verbose --no-use-binaries --platform iOS --cache-builds

script:
- xcodebuild clean build -project r2-streamer-swift.xcodeproj -scheme r2-streamer-swift -destination "platform=iOS Simulator,name=iPhone 8,OS=11.3" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO -quiet
2 changes: 1 addition & 1 deletion R2Streamer/DataExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension Data {
let read = input.read(buffer, maxLength: bufferSize)
self.append(buffer, count: read)
}
buffer.deallocate(capacity: bufferSize)
buffer.deallocate()

input.close()
}
Expand Down
4 changes: 2 additions & 2 deletions R2Streamer/StringExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ extension String {
}

func insert(string: String, at index: String.Index) -> String {
let prefix = substring(to: index)
let suffix = substring(from: index)
let prefix = self[..<index] //substring(to: index)
let suffix = self[index...] //substring(from: index)

return prefix + string + suffix
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var handleTouchEnd = function(event) {

// // Tap to turn.
if(touchDistance < 0.01) {
var position = (touch.screenX % maxScreenX) / maxScreenX;
var position = Math.abs(touch.clientX % maxScreenX) / maxScreenX;
if (position <= 0.2) {
// TAP left.
console.log("LeftTapped");
Expand Down
60 changes: 40 additions & 20 deletions R2Streamer/utils-old.js → R2Streamer/scripts/utils-old.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,40 +34,60 @@ var scrollToId = function(id) {
};

// Position must be in the range [0 - 1], 0-100%.
var scrollToPosition = function(position) {
var scrollToPosition = function(position, dir) {
console.log("ScrollToPosition");
if ((position < 0) || (position > 1)) {
console.log("InvalidPosition");
return;
}
var offset = document.getElementsByTagName("body")[0].scrollWidth * position;

console.log("ScrollToOffset", offset);
document.body.scrollLeft = snapOffset(offset);
var offset = 0.0;
if (dir == 'rtl') {
offset = (-document.body.scrollWidth + maxScreenX) * (1.0-position);
} else {
offset = document.body.scrollWidth * position;
}
console.log(offset);
document.body.scrollLeft = offset;
};

var scrollLeft = function() {
var offset = window.scrollX - maxScreenX;

if (offset >= 0) {
document.body.scrollLeft = offset;
var scrollLeft = function(dir) {
var scrollWidth = document.body.scrollWidth;
var newOffset = window.scrollX - maxScreenX;
var edge = -scrollWidth + maxScreenX;
var newEdge = (dir == "rtl")? edge:0;

if (newOffset > newEdge) {
document.body.scrollLeft = newOffset
return 0;
} else {
document.body.scrollLeft = 0;
return "edge"; // Need to previousDocument.
var oldOffset = window.scrollX;
document.body.scrollLeft = newEdge;
if (oldOffset != newEdge) {
return 0;
} else {
return "edge";
}
}
};

var scrollRight = function() {
var offset = window.scrollX + maxScreenX;
var scrollWidth = document.getElementsByTagName("body")[0].scrollWidth;

if (offset < scrollWidth) {
document.body.scrollLeft = offset;
var scrollRight = function(dir) {

var scrollWidth = document.body.scrollWidth;
var newOffset = window.scrollX + maxScreenX;
var edge = scrollWidth - maxScreenX;
var newEdge = (dir == "rtl")? 0:edge

if (newOffset < newEdge) {
document.body.scrollLeft = newOffset
return 0;
} else {
document.body.scrollLeft = scrollWidth;
return "edge"; // Need to nextDocument.
var oldOffset = window.scrollX;
document.body.scrollLeft = newEdge;
if (oldOffset != newEdge) {
return 0;
} else {
return "edge";
}
}
};

Expand Down
60 changes: 40 additions & 20 deletions R2Streamer/utils.js → R2Streamer/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,40 +34,60 @@ var scrollToId = function(id) {
};

// Position must be in the range [0 - 1], 0-100%.
var scrollToPosition = function(position) {
var scrollToPosition = function(position, dir) {
console.log("ScrollToPosition");
if ((position < 0) || (position > 1)) {
console.log("InvalidPosition");
return;
}
var offset = document.getElementsByTagName("body")[0].scrollWidth * position;

console.log("ScrollToOffset", offset);
document.body.scrollLeft = snapOffset(offset);
var offset = 0.0;
if (dir == 'rtl') {
offset = (-document.body.scrollWidth + maxScreenX) * (1.0-position);
} else {
offset = document.body.scrollWidth * position;
}
console.log(offset);
document.body.scrollLeft = offset;
};

var scrollLeft = function() {
var offset = window.scrollX - maxScreenX;

if (offset >= 0) {
document.body.scrollLeft = offset;
var scrollLeft = function(dir) {
var scrollWidth = document.body.scrollWidth;
var newOffset = window.scrollX - maxScreenX;
var edge = -scrollWidth + maxScreenX;
var newEdge = (dir == "rtl")? edge:0;

if (newOffset > newEdge) {
document.body.scrollLeft = newOffset
return 0;
} else {
document.body.scrollLeft = 0;
return "edge"; // Need to previousDocument.
var oldOffset = window.scrollX;
document.body.scrollLeft = newEdge;
if (oldOffset != newEdge) {
return 0;
} else {
return "edge";
}
}
};

var scrollRight = function() {
var offset = window.scrollX + maxScreenX;
var scrollWidth = document.getElementsByTagName("body")[0].scrollWidth;

if (offset < scrollWidth) {
document.body.scrollLeft = offset;
var scrollRight = function(dir) {

var scrollWidth = document.body.scrollWidth;
var newOffset = window.scrollX + maxScreenX;
var edge = scrollWidth - maxScreenX;
var newEdge = (dir == "rtl")? 0:edge

if (newOffset < newEdge) {
document.body.scrollLeft = newOffset
return 0;
} else {
document.body.scrollLeft = scrollWidth;
return "edge"; // Need to nextDocument.
var oldOffset = window.scrollX;
document.body.scrollLeft = newEdge;
if (oldOffset != newEdge) {
return 0;
} else {
return "edge";
}
}
};

Expand Down
Loading

0 comments on commit 2f18991

Please sign in to comment.