javascript - 模态中的 Div 并不总是在 iOS 上触发滚动事件
问题描述
我在应用程序的 Vue 组件中有以下层次结构和样式:
<template lang="pug">
my-modal-component.modal-container
template(v-slot:content)
swiper.swiper(
:options="swiperOptions"
ref="feedback-swiper"
@slideChangeTransitionEnd="onTransitionEnd"
@slideNextTransitionEnd="onSlideNextTransitionEnd"
@slidePrevTransitionEnd="onSlidePrevTransitionEnd")
swiper-slide.page-container(ref="modal" @scroll.native="handleScroll")
.content-root(:class="transitioning ? 'disable-interaction' : ''")
div
.main-text Main Text
pill-selector
.additional-details-container
.main-text Main Text
textarea.additionalDetails
.char-count number of cur chars
.contact-me
input.input(type="checkbox" v-model="contactMe")
label.label(@click="toggleContactMe")pls help
.swiper-pagination.pagination(slot="pagination")
.swiper-button-prev.prev-slide(slot="button-prev" @click="goToPreviousSlide()")
.swiper-button-next.next-slide(slot="button-next" @click="goToNextSlide()")
.button-container
my-button.main-button SUBMIT
</template>
.modal-container {
color: color(brown);
.button-container {
padding-bottom: 30px;
.main-button {
visibility: hidden;
width: 100%;
}
.hidden {
visibility: hidden;
}
}
.page-container {
-webkit-overflow-scrolling: touch;
overflow-y: auto;
.content-root {
display: flex;
flex-direction: column;
height: 1000px;
}
}
}
该函数每次在具有所有浏览器和 Android 设备的所有桌面操作系统上handleScroll
捕获事件。@scroll.native
但是,在所有 iOS 设备上,该@scroll.native
事件只是有时会触发。这导致滚动并不总是有效。
我努力了:
- 用不同的方法锁定它后面的组件和body
-webkit-overflow-scrolling
从应用程序中删除所有其他实例- 实施https://github.com/willmcpo/body-scroll-lock
- 各种层次结构 + css 更改组合,涉及
overflow-y
和-webkit-overflow-scrolling
解决方案
事实证明,这只能在 iOS 模拟器中重现。在真正的 iOS 设备中,这个问题并不存在。这是我遇到的第一个例子,模拟器的行为与实际设备不同。
推荐阅读
- google-apps-script - 用 3 天后的日期名称制作一张纸
- azure-data-explorer - 在 kusto 表上使用物化视图
- c++ - 在 Xcode 中使用 C++ 中的 .wav 文件
- vba - 转换为文本仅匹配短语第 2 列和第 5 列 Word VBA
- arrays - 当我运行代码时,这段代码有什么问题,它没有给出所需的输出
- aws-api-gateway - 如何创建 REST api 并将其部署在云中?
- r - 如果年份是 x 或 y,则每隔一行跳过一次,否则,只需转到管道中的下一行代码
- javascript - 需要一个函数,该函数使用 lodash 从数组中的两个嵌套对象中解析出数据,并将其作为道具传递给反应组件
- sql - “不喜欢的地方”不排除所有
- vba - 如何与 Excel 建立一个可以同时打开多个用户的数据库连接?