jQuery UI Sortable scrollSpeed选项
jQuery UI是一种基于网络的技术,由各种GUI部件、视觉效果和主题组成。这些功能可以通过jQuery,JavaScript库来实现。jQuery UI是为网页建立UI界面的最佳工具。它也可以用来构建高度互动的网络应用程序,或者可以用来轻松添加小工具。
在这篇文章中,我们将学习jQuery UI Sortable scrollSpeed选项,它指定了一旦鼠标指针进入滚动灵敏度范围内,窗口应该滚动的速度。它是数字类型的,其默认值是20。
语法:
用具有特定数字值的scrollSpeed选项初始化sortable,该选项可以给定为。
$( "Selector" ).sortable({ scrollSpeed: 40 });
- 设置scrollSpeed选项。
$( "Selector" ).sortable( "option", "scrollSpeed", 40 );
- 获得scrollSpeed选项。
var scrollSpeed = $( "Selector" ).sortable( "option", "scrollSpeed" );
CDN链接:添加你的项目所需的jQuery Mobile脚本。
<link rel=”stylesheet” href=”https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css”>
<script src= “https://code.jquery.com/jquery-1.12.4.js”></script>
<script src= “https://code.jquery.com/ui/1.12.1/jquery-ui.js”></script>
例子。下面的例子说明了jquery UI Sortable scrollSpeed选项,我们将scrollSpeed选项改为40,启动事件将触发显示当前scrollSpeed选项。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href=
"https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src=
"https://code.jquery.com/jquery-1.12.4.js">
</script>
<script src=
"https://code.jquery.com/ui/1.12.1/jquery-ui.js">
</script>
<title>jQuery UI Sortable scrollSpeed option</title>
<style>
#sortableList {
list-style-type: none;
}
.geeks {
margin: 10px;
background: lightgreen;
padding: 10px;
border: 1px solid green;
font-size: 25px;
}
</style>
<script>
(function() {
('#sortableList').sortable({
start: function(event, ui) {
("#sortedList").html(("#sortedList").html()
+ "Start event triggered when scrollSpeed is "
+ $("#sortableList").sortable("option", "scrollSpeed")
+ "<br>");
},
scrollSpeed: 40
});
});
</script>
</head>
<body>
<center>
<h1 style="color: green;">
GeeksforGeeks
</h1>
<h2>jQuery UI Sortable scrollSpeed option</h2>
<ul id="sortableList">
<li id="Tutorials" class="geeks">
1.Free Tutorials
</li>
<li id="Articles" class="geeks">
2.Millions of articles
</li>
<li id="Webinars" class="geeks">
3.Webinars by Industry Experts
</li>
<li id="Courses" class="geeks">
4.Live, Online and Classroom Courses
</li>
</ul>
<h2>
<span id='sortedList'></span>
</h2>
</center>
</body>
</html>
输出:
jQuery UI Sortable scrollSpeed选项