Skip to content

Commit

Permalink
Enable swiping next / previous images, fixes #27
Browse files Browse the repository at this point in the history
  • Loading branch information
walokra committed Nov 15, 2021
1 parent f6e1bcd commit 6bb6419
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 46 deletions.
53 changes: 30 additions & 23 deletions qml/pages/ImageComponent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -103,31 +103,38 @@ Component {
internal.clickPlay();
}

onPressAndHold: {
imageColumn.height = (imageColumn.height < drawerContextMenu.height) ? drawerContextMenu.height : imageColumn.height;
drawer.open = true;
}
MouseArea {
property int start_x;
property int start_y;

onPressed: {
start_x = mouseX;
start_y = mouseY;
}
anchors.fill: parent;

// onPressAndHold: {
// image.height = (image.height < drawerContextMenu.height) ? drawerContextMenu.height : image.height;
// drawer.open = true;
// }

onPressed: {
start_x = mouseX;
start_y = mouseY;
}

onPositionChanged: {
if (!isSlideshow && pinchArea.curScale == 1.0) {
var x_diff = mouseX - start_x;
var y_diff = mouseY - start_y;

var abs_x_diff = Math.abs(x_diff);
var abs_y_diff = Math.abs(y_diff);

if (abs_x_diff !== abs_y_diff) {
if (abs_x_diff > abs_y_diff) {
if (abs_x_diff > 50) {
if (x_diff > 0) {
if (prevEnabled) { galleryNavigation.previous(); }
} else if (x_diff < 0) {
galleryNavigation.next();
onPositionChanged: {
if (!isSlideshow && pinchArea.curScale == 1.0) {
var x_diff = mouseX - start_x;
var y_diff = mouseY - start_y;

var abs_x_diff = Math.abs(x_diff);
var abs_y_diff = Math.abs(y_diff);

if (abs_x_diff !== abs_y_diff) {
if (abs_x_diff > abs_y_diff) {
if (abs_x_diff > 50) {
if (x_diff > 0) {
if (prevEnabled) { galleryNavigation.previous(); }
} else if (x_diff < 0) {
galleryNavigation.next();
}
}
}
}
Expand Down
50 changes: 27 additions & 23 deletions qml/pages/VideoComponent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ Component {
height: Math.max(vHeight * (Screen.width / vWidth), 3*loadingVideoIndicator.height);
width: Screen.width;

property int start_x;
property int start_y;

Connections {
target: galleryContentPage;
onGgpStatusChanged: {
Expand Down Expand Up @@ -84,30 +81,37 @@ Component {
internal.clickPlay();
}

// onPressAndHold: {
// imageColumn.height = (imageColumn.height < drawerContextMenu.height) ? drawerContextMenu.height : imageColumn.height;
// drawer.open = true;
// }
MouseArea {
property int start_x;
property int start_y;

onPressed: {
start_x = mouseX;
start_y = mouseY;
}
anchors.fill: parent;

onPositionChanged: {
var x_diff = mouseX - start_x;
var y_diff = mouseY - start_y;
// onPressAndHold: {
// video.height = (video.height < drawerContextMenu.height) ? drawerContextMenu.height : video.height;
// drawer.open = true;
// }

var abs_x_diff = Math.abs(x_diff);
var abs_y_diff = Math.abs(y_diff);
onPressed: {
start_x = mouseX;
start_y = mouseY;
}

if (abs_x_diff !== abs_y_diff) {
if (abs_x_diff > abs_y_diff) {
if (abs_x_diff > 50) {
if (x_diff > 0) {
if (prevEnabled) { galleryNavigation.previous(); }
} else if (x_diff < 0) {
galleryNavigation.next();
onPositionChanged: {
var x_diff = mouseX - start_x;
var y_diff = mouseY - start_y;

var abs_x_diff = Math.abs(x_diff);
var abs_y_diff = Math.abs(y_diff);

if (abs_x_diff != abs_y_diff) {
if (abs_x_diff > abs_y_diff) {
if (abs_x_diff > 50) {
if (x_diff > 0) {
if (prevEnabled) { galleryNavigation.previous(); }
} else if (x_diff < 0) {
galleryNavigation.next();
}
}
}
}
Expand Down

0 comments on commit 6bb6419

Please sign in to comment.