jQuery拖拽插件gridster使用指南
gridster.js 是一個 jQuery 插件用來構(gòu)建直觀的可拖放的布局,支持多列布局,你還可以動態(tài)的添加和刪除表格中的元素。
1.gridster插件功能
實現(xiàn)類似于win8 磁貼拖拽的功能
2.gridster官方地址
在官方的網(wǎng)站上也有插件的幫助和實例,但是按照官方的說明,我在本地測試總是出現(xiàn)這樣那樣的問題,一是無法移動,二是在磁鐵的附近有一個黑點,可能是定位使用的。但是如果在網(wǎng)站中正常使用,應(yīng)該不會出現(xiàn)這樣的黑點。gridster插件的屬性和方法在官網(wǎng)上有詳細說明。
經(jīng)過測試了一下,最后終于解決了問題。效果顯示如下:

3.gridster使用方法
1.首先引用js文件
<script type="text/javascript" src=" jquery-1.7.2.min.js"></script> <script type="text/javascript" src=" jquery.gridster.js"></script> <link rel="stylesheet" type="text/css" href=" style.css" />
2.用到的css
<style type="text/css">
.handle {
border-bottom: 1px solid black;
}
.small img{
height:83px;
width:97px;
}
.gridster {
position:relative;
background-color:#CCC;
}
li {
background-color: white;
width: 150px;
height: 300px;
border: solid 2px black;
}
.gridster > * {
margin: 0 auto;
-webkit-transition: height .4s;
-moz-transition: height .4s;
-o-transition: height .4s;
-ms-transition: height .4s;
transition: height .4s;
}
.gridster .gs_w{
z-index: 2;
position: absolute;
}
.ready .gs_w:not(.preview-holder) {
-webkit-transition: opacity .3s, left .3s, top .3s;
-moz-transition: opacity .3s, left .3s, top .3s;
-o-transition: opacity .3s, left .3s, top .3s;
transition: opacity .3s, left .3s, top .3s;
}
.ready .gs_w:not(.preview-holder) {
-webkit-transition: opacity .3s, left .3s, top .3s, width .3s, height .3s;
-moz-transition: opacity .3s, left .3s, top .3s, width .3s, height .3s;
-o-transition: opacity .3s, left .3s, top .3s, width .3s, height .3s;
transition: opacity .3s, left .3s, top .3s, width .3s, height .3s;
}
.gridster .preview-holder {
z-index: 1;
position: absolute;
background-color: #fff;
border-color: #fff;
opacity: 0.3;
}
.gridster .player-revert {
z-index: 10!important;
-webkit-transition: left .3s, top .3s!important;
-moz-transition: left .3s, top .3s!important;
-o-transition: left .3s, top .3s!important;
transition: left .3s, top .3s!important;
}
.gridster .dragging {
z-index: 10!important;
-webkit-transition: all 0s !important;
-moz-transition: all 0s !important;
-o-transition: all 0s !important;
transition: all 0s !important;
}
p{
margin:10px;
}
3.使用的js代碼
$(function(){
$(".gridster ul").gridster({
widget_margins: [5, 5],
widget_base_dimensions: [100, 100],
draggable: {
handle: '.handle'
}
});
var gridster = $(".gridster ul").gridster().data('gridster');
});
4.使用的html
<div class="gridster">
<ul id="reszable">
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1"><div class="handle">1</div><div class="small"><img src="test.jpg" /></div></li>
<li data-row="2" data-col="1" data-sizex="1" data-sizey="1"><div class="handle">2</div></li>
<li data-row="3" data-col="1" data-sizex="1" data-sizey="1"><div class="handle">3</div></li>
<li data-row="1" data-col="2" data-sizex="2" data-sizey="1"><div class="handle">4</div></li>
<li data-row="2" data-col="2" data-sizex="2" data-sizey="2"><div class="handle">5</div><p>
Like no other javascript library, Parsley has a full support for #UX concerns and detailed options. Override almost every Parsley default behaviors to fit your exact needs.</p></li>
<li data-row="1" data-col="4" data-sizex="1" data-sizey="1"><div class="handle">6</div></li>
<li data-row="2" data-col="4" data-sizex="2" data-sizey="1"><div class="handle">7</div></li>
<li data-row="3" data-col="4" data-sizex="1" data-sizey="1"><div class="handle">8</div></li>
<li data-row="1" data-col="5" data-sizex="1" data-sizey="1"><div class="handle">9</div></li>
<li data-row="3" data-col="5" data-sizex="1" data-sizey="1"><div class="handle">10</div></li>
<li data-row="1" data-col="6" data-sizex="1" data-sizey="1"><div class="handle">11</div></li>
<li data-row="2" data-col="6" data-sizex="1" data-sizey="2"><div class="handle">12</div></li>
<li data-row="1" data-col="7" data-sizex="1" data-sizey="1"><div class="handle">13</div></li>
<li data-row="2" data-col="7" data-sizex="1" data-sizey="1"><div class="handle">14</div></li>
<li data-row="3" data-col="7" data-sizex="1" data-sizey="1"><div class="handle">15</div></li>
</ul>
</div>
4.gridster使用說明
gridster插件在chrome與firefox中使用正常,特效顯示頁正常。但是在ie8一下顯示正常,但是拖拽特效無法顯示。
現(xiàn)在你可以打開來看看這個拖動效果了,Oh,買尬的!也會你會發(fā)現(xiàn)很不流暢,這個或許是girdster的小bug或者說不完美的地方,如何改進,明天再講!
- JQuery UI的拖拽功能實現(xiàn)方法小結(jié)
- 簡單的jquery拖拽排序效果實現(xiàn)代碼
- jQuery拖拽div實現(xiàn)思路
- JQuery之拖拽插件實現(xiàn)代碼
- jquery實現(xiàn)簡單的拖拽效果實例兼容所有主流瀏覽器
- jQuery手機瀏覽器中拖拽動作的艱難性分析
- 基于jquery的一個拖拽到指定區(qū)域內(nèi)的效果
- jquery 可拖拽的窗體控件實現(xiàn)代碼
- Jquery拖拽并簡單保存的實現(xiàn)代碼
- 基于jquery實現(xiàn)的鼠標(biāo)拖拽元素復(fù)制并寫入效果
- jQuery 版元素拖拽原型代碼
- Jquery實現(xiàn)自定義窗口隨意的拖拽
- jQuery實現(xiàn)的簡單拖拽功能示例
相關(guān)文章
jQuery EasyUI API 中文文檔 - Parser 解析器
jQuery EasyUI API 中文文檔 - Parser 解析器,使用jQuery EasyUI的朋友可以參考下。2011-09-09
jquery mobile實現(xiàn)可折疊的導(dǎo)航按鈕
這篇文章主要為大家詳細介紹了jquery mobile實現(xiàn)可折疊的導(dǎo)航按鈕,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-03-03
jQuery實現(xiàn)表格奇偶行顯示不同背景色 就這么簡單
這篇文章主要為大家詳細介紹了jQuery實現(xiàn)表格奇偶行顯示不同背景色的方法,使表格更加美觀,便捷的查找同行數(shù)據(jù)更,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-03-03
jquery的ajax和getJson跨域獲取json數(shù)據(jù)的實現(xiàn)方法
本篇文章主要是對jquery的ajax和getJson跨域獲取json數(shù)據(jù)的實現(xiàn)方法進行了介紹,需要的朋友可以過來參考下,希望對大家有所幫助2014-02-02

