starting hammer gestures
This commit is contained in:
@@ -942,6 +942,10 @@ select {
|
||||
max-width: 1536px;
|
||||
}
|
||||
}
|
||||
.static {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.fixed {
|
||||
position: fixed;
|
||||
}
|
||||
|
@@ -34,6 +34,88 @@ class CollapsePanel {
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/modules/HammerGestures.js":
|
||||
/*!***************************************!*\
|
||||
!*** ./src/modules/HammerGestures.js ***!
|
||||
\***************************************/
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var _PageTransitions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PageTransitions */ "./src/modules/PageTransitions.js");
|
||||
|
||||
class HammerGestures {
|
||||
constructor() {
|
||||
this.history = [];
|
||||
this.init();
|
||||
}
|
||||
init() {
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
var element = document.getElementById('content-container');
|
||||
|
||||
// Create a Hammer instance
|
||||
var hammer = new Hammer(element);
|
||||
hammer.get('swipe').set({
|
||||
direction: Hammer.DIRECTION_ALL
|
||||
});
|
||||
var pageTransition = new _PageTransitions__WEBPACK_IMPORTED_MODULE_0__["default"]();
|
||||
|
||||
// Add a swipe event listener for swipe left
|
||||
hammer.on('swipeleft', ev => {
|
||||
this.currentUrl = window.location.href;
|
||||
this.goForward(this.currentUrl);
|
||||
console.log(ev.type);
|
||||
});
|
||||
|
||||
// Add a swipe event listener for swipe right
|
||||
hammer.on('swiperight', ev => {
|
||||
this.currentUrl = window.location.href;
|
||||
this.goBack(this.currentUrl);
|
||||
console.log(ev.type);
|
||||
pageTransition.animatePageTransition(() => {
|
||||
pageTransition.loadContent(document.referrer, 'content-container');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
goForward(currentUrl) {
|
||||
if (this.history.length > 0) {
|
||||
const nextUrl = this.history[this.history.length - 1];
|
||||
if (HammerGestures.isSameDomain(currentUrl, nextUrl)) {
|
||||
console.log(`Going forward to ${nextUrl}`);
|
||||
this.history.pop();
|
||||
} else {
|
||||
console.log('Cannot go forward. Different domain.');
|
||||
}
|
||||
} else {
|
||||
console.log('Cannot go forward. History is empty.');
|
||||
}
|
||||
}
|
||||
goBack(currentUrl) {
|
||||
if (this.history.length > 0) {
|
||||
const previousUrl = this.history.pop();
|
||||
if (HammerGestures.isSameDomain(currentUrl, previousUrl)) {
|
||||
console.log(`Going back to ${previousUrl}`);
|
||||
} else {
|
||||
console.log('Cannot go back. Different domain.');
|
||||
this.history.push(previousUrl); // Re-add the popped URL
|
||||
}
|
||||
} else {
|
||||
console.log('Cannot go back. History is empty.');
|
||||
}
|
||||
}
|
||||
static isSameDomain(url1, url2) {
|
||||
const domain1 = new URL(url1).hostname;
|
||||
const domain2 = new URL(url2).hostname;
|
||||
return domain1 === domain2;
|
||||
}
|
||||
}
|
||||
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (HammerGestures);
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./src/modules/NavControl.js":
|
||||
/*!***********************************!*\
|
||||
!*** ./src/modules/NavControl.js ***!
|
||||
@@ -171,7 +253,14 @@ class PageTransitions {
|
||||
const elementId = 'content-container';
|
||||
|
||||
// Clear the search form
|
||||
form.reset(); // Reset the form to clear input values
|
||||
var inputs = form.getElementsByTagName('input');
|
||||
Array.from(inputs).forEach(function (input) {
|
||||
// Reset the input value
|
||||
input.value = '';
|
||||
|
||||
// Unfocus the input
|
||||
input.blur();
|
||||
});
|
||||
|
||||
// Update content, push state, and remove transition class
|
||||
this.updateContent(data, elementId);
|
||||
@@ -225,8 +314,6 @@ class PageTransitions {
|
||||
console.error(`Element with ID '${elementId}' not found in the fetched data`);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to check if a link is external
|
||||
isExternalLink(link) {
|
||||
const currentDomain = window.location.hostname;
|
||||
const linkDomain = link.hostname;
|
||||
@@ -388,6 +475,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _modules_CollapsePanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./modules/CollapsePanel */ "./src/modules/CollapsePanel.js");
|
||||
/* harmony import */ var _modules_SplashScreen__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./modules/SplashScreen */ "./src/modules/SplashScreen.js");
|
||||
/* harmony import */ var _modules_PageTransitions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./modules/PageTransitions */ "./src/modules/PageTransitions.js");
|
||||
/* harmony import */ var _modules_HammerGestures__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./modules/HammerGestures */ "./src/modules/HammerGestures.js");
|
||||
// Our modules / classes
|
||||
// Import modules e.g import MobileMenu from "./modules/MobileMenu"
|
||||
|
||||
@@ -396,6 +484,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
|
||||
|
||||
|
||||
|
||||
// Instantiate a new object using our modules/classes
|
||||
// e.g var mobileMenu = new MobileMenu()
|
||||
|
||||
@@ -404,6 +493,7 @@ const navControl = new _modules_NavControl__WEBPACK_IMPORTED_MODULE_1__["default
|
||||
const collapsePanel = new _modules_CollapsePanel__WEBPACK_IMPORTED_MODULE_2__["default"]();
|
||||
const splashScreen = new _modules_SplashScreen__WEBPACK_IMPORTED_MODULE_3__["default"]();
|
||||
const pageTransitions = new _modules_PageTransitions__WEBPACK_IMPORTED_MODULE_4__["default"]();
|
||||
const hammerGestures = new _modules_HammerGestures__WEBPACK_IMPORTED_MODULE_5__["default"]();
|
||||
})();
|
||||
|
||||
/******/ })()
|
||||
|
File diff suppressed because one or more lines are too long
@@ -5,12 +5,7 @@
|
||||
<meta charset="<?php bloginfo('charset'); ?>" />
|
||||
<meta content="width=device-width, initial-scale=1, viewport-fit=cover, maximum-scale=1, user-scalable=no, shrink-to-fit=no" name="viewport" />
|
||||
<link href="<?php echo get_template_directory_uri(); ?>/assets/images/logos/nan_bear_head.svg" rel="icon" type="image/png" />
|
||||
<?php
|
||||
// Start or resume the session
|
||||
session_start();
|
||||
wp_head();
|
||||
|
||||
?>
|
||||
<?php wp_head(); ?>
|
||||
</head>
|
||||
|
||||
<body class="h-screen overflow-hidden bg-blue-500" <?php body_class(); ?>>
|
||||
|
@@ -11,6 +11,9 @@ function themeStarter_enqueue()
|
||||
wp_register_script('themeStarter-app', get_parent_theme_file_uri('/assets/js/index.js'), [], $theme_version, true);
|
||||
wp_enqueue_script('themeStarter-app');
|
||||
|
||||
wp_register_script('hammer-js', 'https://hammerjs.github.io/dist/hammer.js', [], '2.0.8', true);
|
||||
wp_enqueue_script('hammer-js');
|
||||
|
||||
|
||||
/* Register and Enqueue Styles */
|
||||
|
||||
|
Reference in New Issue
Block a user