Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48983

Override swipe back threshold

$
0
0

I need to override the createSwipeBackGesture.canStart method to allow swiping back from anywhere on the screen instead of just the edge https://github.com/ionic-team/ionic-framework/blob/be2205e5a2b2f8778bd1f7b4ea5cae0bf96f9ef3/core/src/utils/gesture/swipe-back.ts#L13

I don’t know if it’s possible to extend the code and override that specific method, so I am replacing the entire file at build time to remove the detail.startX condition.

If anyone has a better solution that doesn’t involve overriding the original file that’d be great!

I used the file-replace-loader npm package and the following code in vue.config.js in the root of the project:

const { resolve } = require('path')

module.exports = {
	chainWebpack: (config) => {
		config.module
			.rule('replace-file-swipe-back-gesture')
			.test(/swipe-back\.js$/)
			.use('file-replace-loader')
			.loader('file-replace-loader')
			.options({
				condition: 'if-replacement-exists',
				replacement: resolve('./ionic-core-overrides/swipe-back.js'),
				async: true,
			})
			.end()
	},
}

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48983

Trending Articles