Skip to content

Commit

Permalink
fix swipe right/left
Browse files Browse the repository at this point in the history
  • Loading branch information
patricksptang committed May 19, 2024
1 parent 5981cd1 commit 2f2b863
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 39 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>com.tyndalehouse.step</groupId>
<artifactId>step-mvn</artifactId>
<version>24.5.1</version>
<version>24.5.2</version>
<packaging>pom</packaging>
<name>STEP :: Scripture Tools for Every pastor</name>

Expand Down
2 changes: 1 addition & 1 deletion step-assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>step-mvn</artifactId>
<groupId>com.tyndalehouse.step</groupId>
<version>24.5.1</version>
<version>24.5.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
Expand Down
2 changes: 1 addition & 1 deletion step-build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.tyndalehouse.step</groupId>
<artifactId>step-mvn</artifactId>
<version>24.5.1</version>
<version>24.5.2</version>
</parent>

<artifactId>step-build</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion step-core-data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>com.tyndalehouse.step</groupId>
<artifactId>step-mvn</artifactId>
<version>24.5.1</version>
<version>24.5.2</version>
</parent>

<artifactId>step-core-data</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion step-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.tyndalehouse.step</groupId>
<artifactId>step-mvn</artifactId>
<version>24.5.1</version>
<version>24.5.2</version>
</parent>

<groupId>com.tyndalehouse.step</groupId>
Expand Down
2 changes: 1 addition & 1 deletion step-packages/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.tyndalehouse.step</groupId>
<artifactId>step-mvn</artifactId>
<version>24.5.1</version>
<version>24.5.2</version>
</parent>

<groupId>com.tyndalehouse.step</groupId>
Expand Down
2 changes: 1 addition & 1 deletion step-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<parent>
<groupId>com.tyndalehouse.step</groupId>
<artifactId>step-mvn</artifactId>
<version>24.5.1</version>
<version>24.5.2</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion step-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.tyndalehouse.step</groupId>
<artifactId>step-mvn</artifactId>
<version>24.5.1</version>
<version>24.5.2</version>
</parent>

<groupId>com.tyndalehouse.step</groupId>
Expand Down
2 changes: 1 addition & 1 deletion step-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.tyndalehouse.step</groupId>
<artifactId>step-mvn</artifactId>
<version>24.5.1</version>
<version>24.5.2</version>
</parent>

<groupId>com.tyndalehouse.step</groupId>
Expand Down
2 changes: 1 addition & 1 deletion step-war-precompiled/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>step-mvn</artifactId>
<groupId>com.tyndalehouse.step</groupId>
<version>24.5.1</version>
<version>24.5.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion step-web-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.tyndalehouse.step</groupId>
<artifactId>step-mvn</artifactId>
<version>24.5.1</version>
<version>24.5.2</version>
</parent>

<groupId>com.tyndalehouse.step</groupId>
Expand Down
2 changes: 1 addition & 1 deletion step-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.tyndalehouse.step</groupId>
<artifactId>step-mvn</artifactId>
<version>24.5.1</version>
<version>24.5.2</version>
</parent>

<artifactId>step-web</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ var PassageDisplayView = DisplayView.extend({
newText = origText[0].trim() + ":" + newText;
}
$(refButton).text(newText);
step.util.setupGesture();
break;
}
}
Expand Down
12 changes: 6 additions & 6 deletions step-web/src/main/webapp/js/backbone/views/view_menu_passage.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ var PassageMenuView = Backbone.View.extend({
var swipeStatus = step.passages.findWhere({ passageId: 0}).get("isSwipeLeftRight");
if (swipeStatus == undefined)
swipeStatus = true;
var appleTouchDevices = ((ua.indexOf("iphone") > -1) || (ua.indexOf("ipad") > -1) || (ua.indexOf("macintosh") > -1)); // iPhone need the left and right buttons
if (step.touchDevice && swipeCount > 6 && swipeStatus && !appleTouchDevices)
// var appleTouchDevices = ((ua.indexOf("iphone") > -1) || (ua.indexOf("ipad") > -1) || (ua.indexOf("macintosh") > -1)); // iPhone need the left and right buttons
if (step.touchDevice && swipeCount > 6 && swipeStatus) // && !appleTouchDevices)
$(".nextPreviousChapterGroup").css("display", "none");
else {
$(".nextPreviousChapterGroup").css("display", "block");
Expand All @@ -204,7 +204,7 @@ var PassageMenuView = Backbone.View.extend({
// played, and hopefully the user knows what the arrows are for.
// iPhone need the left and right buttons. Swipe right / left does not work on iPhones when the chapter
// does not have clickable elements (e.g. strong words) and the chapter is long.
if (step.touchDevice && !appleTouchDevices) {
if (step.touchDevice) { // && !appleTouchDevices) {
var swipeIntro = step.util.localStorageGetItem("swipeIntro");
if (swipeIntro != 1) {
var stepUsage = step.util.localStorageGetItem("step.usageCount");
Expand Down Expand Up @@ -543,9 +543,9 @@ var PassageMenuView = Backbone.View.extend({
dropdown.append(li);
dropdown.append(_.template(this.fontButtons)())
.find(".largerFontSize").click(this.changeFontSizeInThisPanel);
var ua = navigator.userAgent.toLowerCase();
var appleTouchDevices = ((ua.indexOf("iphone") > -1) || (ua.indexOf("ipad") > -1) || (ua.indexOf("macintosh") > -1)); // iPhone need the left and right buttons
if (step.touchDevice && (step.util.activePassageId() == 0) && !appleTouchDevices) {
// var ua = navigator.userAgent.toLowerCase();
// var appleTouchDevices = ((ua.indexOf("iphone") > -1) || (ua.indexOf("ipad") > -1) || (ua.indexOf("macintosh") > -1)); // iPhone need the left and right buttons
if (step.touchDevice && (step.util.activePassageId() == 0)) { // } && !appleTouchDevices) {
var currentSwipeLRSetting = self.model.get("isSwipeLeftRight");
if (currentSwipeLRSetting == undefined) {
this.model.save({isSwipeLeftRight: true});
Expand Down
31 changes: 26 additions & 5 deletions step-web/src/main/webapp/js/step.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4417,20 +4417,41 @@ step.util = {
});
return (freqListElm);
},
handleGesture: function(touchEvent, touchstartX, touchstartY, touchstartTime) {
setupGesture: function() {
// var ua = navigator.userAgent.toLowerCase();
// var appleTouchDevices = ((ua.indexOf("iphone") > -1) || (ua.indexOf("ipad") > -1) || (ua.indexOf("macintosh") > -1)); // iPhone need the left and right buttons
var touchableElement;
if ((screen.height > 599) && (screen.width > 599)) {
step.touchWideDevice = true;
document.getElementById("resizeButton").style.display = "inline";
touchableElement = document.getElementById("columnHolder");
}
else
touchableElement = document.getElementsByTagName("body")[0];
touchableElement.addEventListener('touchstart', step.util.handleTouchStart, false);
touchableElement.addEventListener('touchend', step.util.handleTouchEnd, false);
},
handleTouchStart: function(touchEvent) {
step.touchstartX = touchEvent.changedTouches[0].screenX;
step.touchstartY = touchEvent.changedTouches[0].screenY;
step.touchstartTime = new Date().getTime();
},
handleTouchEnd: function(touchEvent) {
// only get teh swipe left/right from the first panel. In view_menu_passage.js, getting the passageId would bomb.
var status = step.passages.findWhere({ passageId: 0}).get("isSwipeLeftRight");
if ((status != undefined) && (!status))
if ( ((status != undefined) && (!status)) || (typeof touchEvent.changedTouches === "undefined") )
return;
var touchendX = touchEvent.changedTouches[0].screenX;
var touchendY = touchEvent.changedTouches[0].screenY;
var minDistance = 40;
var verticalTolerance = 35;
var touchDiffY = Math.abs(touchendY - touchstartY);
var touchDiffX = touchendX - touchstartX;
var touchDiffY = Math.abs(touchendY - step.touchstartY);
var touchDiffX = touchendX - step.touchstartX;
step.touchstartX = null;
step.touchstartY = null;
if (touchDiffY < verticalTolerance) {
if (Math.abs(touchDiffX) > minDistance) {
if (new Date().getTime() - touchstartTime > 400) return; // must be with 400 milliseconds
if (new Date().getTime() - step.touchstartTime > 400) return; // must be with 400 milliseconds
var activePassage = $(touchEvent.srcElement.closest(".passageContainer"));
if (touchDiffX < 0)
activePassage.find("a.nextChapter").click();
Expand Down
32 changes: 16 additions & 16 deletions step-web/src/main/webapp/start.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -471,22 +471,22 @@ userCountry = (userCountry == null) ? "UNKNOWN" : userCountry.toUpperCase();
if ((ua.indexOf("android") > -1) || (ua.indexOf("iphone") > -1) || (ua.indexOf("ipad") > -1) ||
((ua.indexOf("macintosh") > -1) && (navigator.maxTouchPoints > 1))) {
step.touchDevice = true;
var touchableElement;
if ((screen.height > 599) && (screen.width > 599)) {
step.touchWideDevice = true;
document.getElementById("resizeButton").style.display = "inline";
touchableElement = document.getElementById("columnHolder");
}
else
touchableElement = document.getElementsByTagName("body")[0];
touchableElement.addEventListener('touchstart', function (event) {
touchstartX = event.changedTouches[0].screenX;
touchstartY = event.changedTouches[0].screenY;
touchstartTime = new Date().getTime();
}, false);
touchableElement.addEventListener('touchend', function (event) {
step.util.handleGesture(event, touchstartX, touchstartY, touchstartTime);
}, false);
// var touchableElement;
// if ((screen.height > 599) && (screen.width > 599)) {
// step.touchWideDevice = true;
// document.getElementById("resizeButton").style.display = "inline";
// touchableElement = document.getElementById("columnHolder");
// }
// else
// touchableElement = document.getElementsByTagName("body")[0];
// touchableElement.addEventListener('touchstart', function (event) {
// touchstartX = event.changedTouches[0].screenX;
// touchstartY = event.changedTouches[0].screenY;
// touchstartTime = new Date().getTime();
// }, false);
// touchableElement.addEventListener('touchend', function (event) {
// step.util.handleGesture(event, touchstartX, touchstartY, touchstartTime);
// }, false);
}
</script>
Expand Down

0 comments on commit 2f2b863

Please sign in to comment.