-
Notifications
You must be signed in to change notification settings - Fork 10
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 #42 from gardaholm/collapsable-filter
Collapsable Advanced Filter + Setter Name / Improved Navigation
- Loading branch information
Showing
5 changed files
with
126 additions
and
16 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
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,70 @@ | ||
document.addEventListener("DOMContentLoaded", function () { | ||
let startX; | ||
let endX; | ||
const threshold = 150; // Minimum distance of swipe | ||
|
||
// Function to simulate button click and add button hover | ||
function simulateClick(elementId) { | ||
const element = document.getElementById(elementId); | ||
if (element) { | ||
element.click(); | ||
addHoverEffect(elementId); | ||
setTimeout(function () { | ||
removeHoverEffect(elementId); | ||
}, 200); | ||
} | ||
} | ||
|
||
function addHoverEffect(elementId) { | ||
const element = document.getElementById(elementId); | ||
if (element) { | ||
element.classList.add("simulated-button-click"); | ||
} | ||
} | ||
|
||
function removeHoverEffect(elementId) { | ||
const element = document.getElementById(elementId); | ||
if (element) { | ||
element.classList.remove("simulated-button-click"); | ||
} | ||
} | ||
|
||
document.addEventListener( | ||
"touchstart", | ||
function (e) { | ||
startX = e.changedTouches[0].screenX; | ||
}, | ||
false | ||
); | ||
|
||
document.addEventListener( | ||
"touchend", | ||
function (e) { | ||
endX = e.changedTouches[0].screenX; | ||
|
||
// Check if swipe is right to left (next) | ||
if (startX > endX + threshold) { | ||
simulateClick("button-next"); | ||
} | ||
// Check if swipe is left to right (previous) | ||
else if (startX < endX - threshold) { | ||
simulateClick("button-prev"); | ||
} | ||
}, | ||
false | ||
); | ||
|
||
// Arrow keys detection | ||
document.addEventListener( | ||
"keydown", | ||
function (e) { | ||
if (e.key === "ArrowLeft") { | ||
simulateClick("button-prev"); | ||
} | ||
if (e.key === "ArrowRight") { | ||
simulateClick("button-next"); | ||
} | ||
}, | ||
false | ||
); | ||
}); |
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