Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_size = 4
indent_style = space
end_of_line = crlf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
19 changes: 19 additions & 0 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Publish to NPM
on: [workflow_dispatch]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- name: Publish package on NPM 📦
run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
dist/
.idea/
/node_modules

.yarn/install-state.gz

.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Anton Zolotov (@j2only)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
53 changes: 38 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,49 @@
# v-disable-swipe-back
# @j2only/ionic-disable-swipe-back

## Getting Started
## Important Notice

You can install `v-disable-swipe-back` using npm.
**@j2only/ionic-disable-swipe-back is not compatible with Ionic Vue 8.x**

```
npm install v-disable-swipe-back
```
**Reason**: Starting from Ionic Vue 8, the internal gesture system and routing mechanisms have been significantly refactored. The createGesture API is no longer exposed in @ionic/vue and custom gestures can no longer interact with or override the swipe-back navigation gesture. As a result, this package no longer works as intended.

Then in main.ts of your ionic vue project
**Why there is no workaround**: Ionic Vue 8 does not provide any official public API for disabling the swipe-back gesture on specific pages or globally. All gesture controls are now managed internally by the framework. Any attempts to disable swipe-back require hacking internal, undocumented properties, which are unstable and may break at any time. Therefore, at this time, there is no reliable or officially supported way to disable the swipe-back gesture in Ionic Vue 8.

```typescript
import App from './App.vue';
**Recommendation**: If you rely on disabling swipe-back, please do not upgrade to Ionic Vue 8, or consider switching to Ionic Angular, where this functionality is still officially supported.

---

import {DisableSwipeBackDirective} from 'v-disable-swipe-back';
![npm publish](https://github.com/j2only/ionic-disable-swipe-back/actions/workflows/npm.yml/badge.svg) [![npm](https://img.shields.io/npm/v/@j2only/ionic-disable-swipe-back.svg)](https://www.npmjs.com/package/@j2only/ionic-disable-swipe-back) ![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/%40j2only/ionic-disable-swipe-back) ![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/j2only/ionic-disable-swipe-back) [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](https://www.typescriptlang.org/) [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/j2only/ionic-disable-swipe-back/issues) ![GitHub](https://img.shields.io/github/license/j2only/ionic-disable-swipe-back)

const app = createApp(App)
.directive('disable-swipe-back', DisableSwipeBackDirective);
## Installation

Install this component via package manager:

```bash
yarn add @j2only/ionic-disable-swipe-back
```

## Usage

Import the component in your app. Example of the main.ts file in your ionic vue project:

```typescript
<script setup lang="ts">
import App from "./App.vue" import {DisableSwipeBackDirective} from
"@j2only/ionic-disable-swipe-back" const app = createApp(App)
.directive("disable-swipe-back", DisableSwipeBackDirective)
app.mount("#app")
</script>
```

In vue template include directive in ion-page

```vue
<ion-page v-disable-swipe-back>
...
</ion-page>
<template>
<ion-page v-disable-swipe-back> ... </ion-page>
</template>
```

## Licensing

MIT License
Forked from [@Sitronik/v-disable-swipe-back](https://github.com/Sitronik/v-disable-swipe-back), Sitronik, [MIT License](LICENSE)
3 changes: 3 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export declare const DisableSwipeBackDirective: Directive & {
beforeMount(el: HTMLElement): void;
};
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const {createGesture} = require('@ionic/vue');
import { createGesture } from "@ionic/vue";

export const DisableSwipeBackDirective = {
beforeMount(el) {
const gesture = createGesture({
el,
threshold: 0,
gestureName: 'goback-swipe',
gesturePriority: 40.5,
onMove: () => console.log()
});
gesture.enable(true);
}
beforeMount(el) {
const gesture = createGesture({
el,
threshold: 0,
gestureName: 'goback-swipe',
gesturePriority: 40.5,
onMove: () => console.log()
});
gesture.enable(true);
}
};
53 changes: 30 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
{
"name": "v-disable-swipe-back",
"version": "1.0.3",
"description": "This vue 3 directive for ionic framework, disables switching the previous route if the user makes a swipe on device iOS",
"main": "index.js",
"repository": "https://github.com/Sitronik/v-disable-swipe-back.git",
"author": "Sitronik <[email protected]>",
"license": "MIT",
"scripts": {},
"files": [
"index.js"
],
"dependencies": {},
"devDependencies": {},
"keywords": [
"vue 3",
"directive",
"ionic",
"disable swipe back"
],
"bugs": {
"url": "https://github.com/Sitronik/v-disable-swipe-back/issues"
}
}
"name": "@j2only/ionic-disable-swipe-back",
"version": "1.0.8",
"description": "Vue 3 directive for Ionic framework, disables switching to previous route if the user makes a swipe on iOS devices",
"author": "Anton Zolotov <[email protected]>",
"files": [
"index.js",
"index.d.ts"
],
"main": "index.js",
"types": "index.d.ts",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/j2only/ionic-disable-swipe-back.git"
},
"bugs": {
"url": "https://github.com/j2only/ionic-disable-swipe-back/issues"
},
"keywords": [
"vue 3",
"directive",
"ionic",
"swipe",
"disable swipe",
"disable swipe back",
"j2only",
"import"
],
"packageManager": "[email protected]"
}
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!

__metadata:
version: 8
cacheKey: 10c0

"@j2only/ionic-disable-swipe-back@workspace:.":
version: 0.0.0-use.local
resolution: "@j2only/ionic-disable-swipe-back@workspace:."
languageName: unknown
linkType: soft