mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-06-24 06:08:43 +02:00
Fix ereader padding and swiping
This commit is contained in:
parent
39fbb0902e
commit
bf62b82037
8 changed files with 80 additions and 74 deletions
|
@ -1,9 +1,12 @@
|
|||
import Vue from 'vue'
|
||||
import vClickOutside from 'v-click-outside'
|
||||
import { App } from '@capacitor/app'
|
||||
import { Dialog } from '@capacitor/dialog'
|
||||
import { StatusBar, Style } from '@capacitor/status-bar';
|
||||
import { formatDistance, format, addDays, isDate } from 'date-fns'
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { Capacitor } from '@capacitor/core'
|
||||
|
||||
Vue.directive('click-outside', vClickOutside.directive)
|
||||
|
||||
if (Capacitor.getPlatform() != 'web') {
|
||||
const setStatusBarStyleDark = async () => {
|
||||
|
@ -150,43 +153,6 @@ Vue.prototype.$sanitizeFilename = (input, colonReplacement = ' - ') => {
|
|||
return sanitized
|
||||
}
|
||||
|
||||
function isClickedOutsideEl(clickEvent, elToCheckOutside, ignoreSelectors = [], ignoreElems = []) {
|
||||
const isDOMElement = (element) => {
|
||||
return element instanceof Element || element instanceof HTMLDocument
|
||||
}
|
||||
|
||||
const clickedEl = clickEvent.srcElement
|
||||
const didClickOnIgnoredEl = ignoreElems.filter((el) => el).some((element) => element.contains(clickedEl) || element.isEqualNode(clickedEl))
|
||||
const didClickOnIgnoredSelector = ignoreSelectors.length ? ignoreSelectors.map((selector) => clickedEl.closest(selector)).reduce((curr, accumulator) => curr && accumulator, true) : false
|
||||
|
||||
if (isDOMElement(elToCheckOutside) && !elToCheckOutside.contains(clickedEl) && !didClickOnIgnoredEl && !didClickOnIgnoredSelector) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
Vue.directive('click-outside', {
|
||||
bind: function (el, binding, vnode) {
|
||||
let vm = vnode.context;
|
||||
let callback = binding.value;
|
||||
if (typeof callback !== 'function') {
|
||||
console.error('Invalid callback', binding)
|
||||
return
|
||||
}
|
||||
el['__click_outside__'] = (ev) => {
|
||||
if (isClickedOutsideEl(ev, el)) {
|
||||
callback.call(vm, ev)
|
||||
}
|
||||
}
|
||||
document.addEventListener('click', el['__click_outside__'], false)
|
||||
},
|
||||
unbind: function (el, binding, vnode) {
|
||||
document.removeEventListener('click', el['__click_outside__'], false)
|
||||
delete el['__click_outside__']
|
||||
}
|
||||
})
|
||||
|
||||
function xmlToJson(xml) {
|
||||
const json = {};
|
||||
for (const res of xml.matchAll(/(?:<(\w*)(?:\s[^>]*)*>)((?:(?!<\1).)*)(?:<\/\1>)|<(\w*)(?:\s*)*\/>/gm)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue