- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我的应用通过滑动来显示列表上的隐藏操作,用户可以在其中决定删除列表中的元素。
它使用 HammerJS 来处理滑动事件,并使用 SweetAlert2 来确认操作。
问题是当 SweetAlert 弹出窗口被关闭时。一旦用户单击取消并关闭模式,所有按钮就会突然可见。整个文档向左移动。
我创建了一个 JSFiddle复制它。
重现步骤:
我也把下面代码的内容贴出来供引用:
HTML:
<div ng-app="app" ng-controller="mainCtrl" class="wrapper">
<div class="items" swipe>
<div ng-repeat="item in items" class="item">
<div>
<div class="item-wrapper">
<div class="logo">
<img src="http://2.bp.blogspot.com/-Y2XrnrXJmXs/Uf5Y_bfr4jI/AAAAAAAAALk/ydouC9lEmDE/s1600/Logogap+Logobb.jpg" />
</div>
<div class="info">
<div class="title">
{{item.title}}
</div>
<div class="description">
{{item.description}}
</div>
</div>
</div>
<div class="offset-action">
<button ng-click="delete()">
X
</button>
</div>
</div>
</div>
</div>
</div>
CSS:
body {
overflow: hidden;
}
.wrapper {
border: 1px solid grey;
min-width: 350px;
max-width: 800px;
}
.items {
overflow: hidden;
position: relative;
}
.item {
padding: 10px 15px;
position: relative;
transition: transform 250ms ease-in-out;
}
.item.show-actions {
transform: translateX(-70px);
}
.item-wrapper {
align-items: center;
display: flex;
}
.logo {
width: 80px;
}
.logo img {
margin: auto;
width: 80px;
height: auto;
}
.offset-action {
align-items: center;
background: #B11A1F;
display: flex;
position: absolute;
top: 0;
bottom: 0;
text-align: center;
right: -70px;
width: 70px;
}
button {
background: transparent;
border: none;
color: white;
width: 100%;
height: 100%;
}
Javascript:
angular.module('app', [])
.controller('mainCtrl', function($scope) {
$scope.items = [
{title: 'Lorem Ipsum', description: 'Consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.'},
{title: 'Lorem Ipsum', description: 'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'},
{title: 'Lorem Ipsum', description: 'Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.'},
{title: 'Lorem Ipsum', description: 'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'}
];
$scope.delete = function() {
swal({
title: 'Lorem Ipsum',
text: 'Dolor sit amet?',
type: 'error',
showCancelButton: true
}).then(function(action) {
if (action.value) {
console.log('success');
} else {
swal.noop;
}
})
}
})
.directive('swipe', function() {
return function(scope) {
scope.$watch('items', function() {
var $items = $('.item');
var show_action = 'show-actions';
function hideActions() {
$items.removeClass(show_action);
}
$items.each(function() {
var $item = $(this);
$item.hammer().on('swipeleft', function() {
var $this = $(this);
$items.removeClass(show_action);
if (!$this.hasClass(show_action)) {
$this.addClass(show_action);
}
});
$item.hammer().on('tap', hideActions);
});
});
};
});
最佳答案
SweetAlert CSS 样式与您的 CSS 样式之间存在冲突,导致此问题。
一个简单的修复方法是将此 CSS 添加到 CSS 文件的末尾:
.offset-action {
display: none;
}
.show-actions .offset-action {
display: flex;
}
https://jsfiddle.net/saeedahmadi/1L7zc25b/
此外,Razvan 的回答将通过在关闭模式后摆脱焦点来完成这项工作:
https://stackoverflow.com/a/52028143/5939933
“在 delete() 方法的顶部添加 document.activeElement.blur();”
关于javascript - 模态关闭时的溢出问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52001313/
是否有更快的算法来计算 (n! modulo m)。在每个乘法步骤都比减少更快。并且有没有比左右二元法更快的算法来计算 (a^p modulo m)。 这是我的代码:n!模数m ans=1 for(i
我有非常简单的代码循环遍历数组中的元素并检查是否index % 2 == 0。如果是这样,它应该改变颜色。 var e = document.getElementById("list").childN
让我简短一点。我正在计算 alert((Math.pow(7,35))%71) 但它给了我 61,而结果必须是 70。怎么了? 最佳答案 正如其他人之前提到的关于使用 Math.pow(7,35) 的
我试图弄清楚如何在汇编中计算模 10,所以我在 gcc 中编译了以下 c 代码,看看它想出了什么。 unsigned int i=999; unsigned int j=i%10; 令我惊讶的是我得到
例如使用以下输入: int num = -100 int divisor = 10 => -100 mod 10 = 0 (Edge-case: negative numbers as inpu
这个问题在这里已经有了答案: Random float number generation (14 个答案) 关闭 9 年前。 在 C++ 中,我希望得到一个随机 float 。据我所知,典型的随机
我试图找到潜在阶乘素数的除数(n!+-1 形式的数),因为我最近购买了 Skylake-X 工作站,我认为我可以使用 AVX512 指令提高一些速度。 算法简单,主要步骤是对同一个除数重复取模。主要是
我有一个保存角度(以度为单位)的变量,该角度可以是正值也可以是负值。我现在需要确保该数字仅在 0 到 360 之间。该数字是 double 。 执行此操作的好算法是什么?简单地执行角度 % 360 是
我有一个 UInt8 数组,我想计算 CheckSum8 模 256。如果字节总和小于 255,checkSum 函数返回正确的值。 例如 let bytes1 : [UInt8] = [1, 0xa
使用海湾合作委员会: printf("%i \n", -1 % (int)4); printf("%u \n", -1 % (unsigned int)4); 输出: -1 3 我可以跨平台依赖这种行
我无法理解代码中几行的含义。我最近开始学习 C++,并阅读了 Bjarne Stroustrup 的“编程:使用 C++ 的原理和实践”。第四章有个问题让我很困惑,所以我在网上搜索了一个解决方案以供引
我试图解决一个涉及大阶乘模质数的问题,并在另一个人的解决方案中发现了以下算法: long long factMod (long long n, long long p) { long long
我正在尝试计算 𝐹𝑛 模 𝑚,其中 𝑛 可能非常大:高达 10^18,𝐹𝑛 是第 n 个斐波那契数这是我的代码,它适用于小数字,但对于大数字,它会抛出 OutOfMemoryError 或
我有两个以 16 为模的循环整数,因此它们的值介于 0 和 15 之间。 我需要比较两个数字以确定 n_1 是否大于 n_0 n_1 > n_0 很明显,这个没有准确定义,所以我定义n_1如果小于前面
我一直在尝试使用 Java 处理一些更大的值,但遇到了一些我不理解的问题。出于某种原因,Java 似乎喜欢给我垃圾数据(尽管,我更可能告诉它给我垃圾数据) 这是一个片段,为清楚起见进行了编辑:
好吧,我今天做了一个小函数,它应该会生成一个随机字符串。 std::string randString(size_t length) { std::string randStr; fo
Ruby 的负数取模规则不明确。在 IRB 中: -7 % 3 == 2 应该是1!为什么? 最佳答案 因为 -7/3 在 Ruby 的整数除法语义下是 -3。 3*-3 是 -9,所以会留下 2
这个问题在这里已经有了答案: Calculating pow(a,b) mod n (14 个答案) 关闭 6 年前。 在 Javascript 中是否有获取大数模数的技巧。我用 modulo(7,
此代码使用公式 (a^x) % 101 检查值 a 是否唯一映射到值 1 到 100 local function f(a) found = {} bijective = true
在《Core Java Volume1》一书中有一条警告: CAUTION: The right-hand side argument of the shift operators is reduce
我是一名优秀的程序员,十分优秀!