Acme.BookStore.HttpApi.Host/node_modules/sweetalert2/src/utils/iosFix.js
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/* istanbul ignore file */
import * as dom from './dom/index.js'
import { swalClasses } from '../utils/classes.js'
// Fix iOS scrolling http://stackoverflow.com/q/39626302
export const iOSfix = () => {
const iOS = (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)
if (iOS && !dom.hasClass(document.body, swalClasses.iosfix)) {
const offset = document.body.scrollTop
document.body.style.top = `${offset * -1}px`
dom.addClass(document.body, swalClasses.iosfix)
lockBodyScroll()
addBottomPaddingForTallPopups() // #1948
}
}
const addBottomPaddingForTallPopups = () => {
const safari = !navigator.userAgent.match(/(CriOS|FxiOS|EdgiOS|YaBrowser|UCBrowser)/i)
if (safari) {
const bottomPanelHeight = 44
if (dom.getPopup().scrollHeight > window.innerHeight - bottomPanelHeight) {
dom.getContainer().style.paddingBottom = `${bottomPanelHeight}px`
}
}
}
const lockBodyScroll = () => { // #1246
const container = dom.getContainer()
let preventTouchMove
container.ontouchstart = (e) => {
preventTouchMove = shouldPreventTouchMove(e)
}
container.ontouchmove = (e) => {
if (preventTouchMove) {
e.preventDefault()
e.stopPropagation()
}
}
}
const shouldPreventTouchMove = (event) => {
const target = event.target
const container = dom.getContainer()
if (isStylys(event) || isZoom(event)) {
return false
}
if (target === container) {
return true
}
if (
!dom.isScrollable(container) &&
target.tagName !== 'INPUT' && // #1603
target.tagName !== 'TEXTAREA' && // #2266
!(
dom.isScrollable(dom.getHtmlContainer()) && // #1944
dom.getHtmlContainer().contains(target)
)
) {
return true
后面还有 20 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
