標籤:jquery ui 拖動(draggable) - 延遲開始
定義和用法
通過 delay 選項設定延遲開始拖拽的毫秒數。通過 distance 選項設定游標被按下且拖拽指定像素後才允許拖拽
樣本
<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><title>jQuery UI 拖動(Draggable) - 延遲開始</title><link rel="stylesheet" href="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/jquery-ui.min.css"><style>#draggable1,#draggable2{width: 120px;height: 120px;padding: 0.5em;float: left;margin: 0 10px 10px 0;}</style></head><body><div id="draggable1" class="ui-widget-content"> <p>只有把我拖拽了 100 像素後,拖拽才開始</p></div><div id="draggable2" class="ui-widget-content"> <p>不管 distance 是多少,您都必須拖拽並等待 1000ms 後拖拽才開始</p></div><script src="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/external/jquery/jquery.js" type="text/javascript" ></script><script src="js/jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script><script>//100表示像素$("#draggable1").draggable({distance:100});//1000表示1000豪秒,也就是1秒$("#draggable2").draggable({delay:1000});</script></body></html>
輸出
650) this.width=650;" src="https://s4.51cto.com/wyfs02/M01/8D/A9/wKiom1ilQNXSualuAAA380g6puE145.png-wh_500x0-wm_3-wmp_4-s_3991046957.png" title="QQ20170216140327.png" alt="wKiom1ilQNXSualuAAA380g6puE145.png-wh_50" />
本文出自 “素顏” 部落格,請務必保留此出處http://suyanzhu.blog.51cto.com/8050189/1898441
jQuery UI 拖動(Draggable) - 延遲開始