任何方式申请“WebKit的溢出滚动:触摸”内嵌的JavaScript?(Any way to ap

2019-06-25 19:25发布

一直没能得到在DOM通过jQuery或本地JavaScript这个属性出现。 jQuery的似乎并不支持它,我无法找到一个本地名称/语法的作品。 任何帮助?

Answer 1:

正确的语法是

el.style.WebkitOverflowScrolling = 'touch'; // capital W

这是怎么回事(几乎)像CSS通常的命名约定JS像边框顶部成为borderTop,......只是WebKit的东西得到了capical第一个字母。



Answer 2:

使用JavaScript,您需要更换仪表板-具有以下大写字母,例如:

var el = document.getElementById('element id');
el.style.webkitOverflowScrolling = 'touch';


Answer 3:

当使用在JavaScript中的样式属性,大写字母下面划线,所以-webkit-溢出滚动变得WebkitOverflowScrolling并确保同时设置溢出滚动。

这里试试: http://jsbin.com/civaha

你可以告诉这是因为反弹的触摸滚动。

资源:

<!doctype html>
<meta name=viewport content="initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
<title>set touch scrolling in JavaScript - robocat</title>

<script>
function makeScrollable(event) {
    var style = event.target.style;
    style.overflow = 'scroll';
    style.WebkitOverflowScrolling = 'touch'; 
    style.backgroundColor = 'lightyellow';
}
</script>

<body style="margin:0;overflow:hidden;">

<h3>The div below can't scroll until you tap it and it turns yellow, then it can scroll horizontally. . . . </h3>

<div onclick="makeScrollable(event)" style="background-color:lightblue;white-space:nowrap;padding:30px 0;font-size:150%;width:100%;overflow:hidden;">
        Shu' thi gob where there's muck there's brass a pint 'o mild. Be reet will 'e 'eckerslike by 'eck chuffin' nora that's champion. What's that when it's at ooam god's own county. Tha knows nay lad. What's that when it's at ooam. T'foot o' our stairs ah'll box thi ears sup wi' 'im tha daft apeth ah'll gi' thi summat to rooer abaht. Th'art nesh thee ne'ermind. Eeh. How much ah'll gi' thi summat to rooer abaht where's tha bin ne'ermind. How much gerritetten nobbut a lad. Face like a slapped arse bobbar cack-handed. God's own county wacken thi sen up dahn t'coil oil by 'eck dahn t'coil oil th'art nesh thee. A pint 'o mild. T'foot o' our stairs tell thi summat for nowt mardy bum where there's muck there's brass. Chuffin' nora. Sup wi' 'im sup wi' 'im nah then. Dahn t'coil oil tha what will 'e 'eckerslike ah'll learn thi. A pint 'o mild chuffin' nora tha daft apeth shurrup michael palin. Ah'll gi' thi summat to rooer abaht tha what nah then tha knows. Dahn t'coil oil breadcake where's tha bin eeh. Breadcake how much. Bobbar be reet soft southern pansy. Is that thine. God's own county shu' thi gob mardy bum a pint 'o mild. Soft southern pansy breadcake a pint 'o mild.
</div>


文章来源: Any way to apply 'webkit-overflow-scrolling: touch' inline with javascript?