我,而我尝试要结合得到了一个问题touchstart,并mousedown在1种功能。我已经使用a标签作为函数的目标元素,当我触摸或单击标签时可以直接转到链接。
问题是当我touch在a标签中间时,链接没有响应。它仅click在元素或触摸a标签边缘时起作用,并且输出触发mousedown。
在移动模式下,请尽可能多地单击a标签的边缘,如上图中的灰色点所示。我创建了一个CodePen示例,以更好地查看,测试和理解。
我该如何解决这个问题?
class Slider {
constructor($el, paragraph) {
this.$el = $el;
this.paragraph = paragraph;
}
start(e) {
e.preventDefault();
var type = e.type;
if (type === 'touchstart' || type === 'mousedown') this.paragraph.text(this.paragraph.text() + ' ' + type);
return false;
}
apply() {
this.$el.bind('touchstart mousedown', (e) => this.start(e));
}
}
const setSlider = new Slider($('#anchor'), $('.textbox'), {passive: false}); …Run Code Online (Sandbox Code Playgroud)我正在制作自己的插件,通过@include在 SCSS 中编写单行来自动进行多个媒体查询。
所以当我输入 时@include medias($bp-values, width);,输出应该是这样的:
@media all and (min-width: 564px) {
width: 200px;
}
@media all and (min-width: 768px) {
width: 300px;
}
@media all and (min-width: 992px) {
width: 400px;
}
@media all and (min-width: 1200px) {
width: 500px;
}
Run Code Online (Sandbox Code Playgroud)
这是代码:
$breakpoints: (
564,
768,
992,
1200
);
$bp-values: (
width: (
200px, 300px, 400px, 500px
),
font-size: (
20px, 30px, 40px, 50px
)
);
@function gridnum($m, $v) {
@return map-get($m, $v);
} …Run Code Online (Sandbox Code Playgroud) 我试图在JS中对innerWidthand 进行求和constant numbers,但是浏览器一直仅附加这些数字,而不进行计算。
奇怪的是给负值工作正常。仅当我尝试将数字加到时,浏览器才会计算innerWidth。
有什么办法可以解决这个问题?
Slider.prototype.sizeReseting = function(event) {
this.frame.style.height = (window.innerWidth - '300') + 'px';
this.frame.style.width = (window.innerWidth - '300') + 'px';
this.film.style.height = (window.innerWidth - '400') + 'px';
this.film.style.width = (window.innerWidth + '100') + 'px';
}
Run Code Online (Sandbox Code Playgroud) css ×2
javascript ×2
arrays ×1
dictionary ×1
each ×1
events ×1
html ×1
jquery ×1
media ×1
sass ×1