復制代碼 代碼如下:YAHOO.example.DDApp = function() { var dd; return { init " /> 黑丝一区二区三区,僵尸再翻生在线观看,91精品国产91综合久久蜜臀

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

學習YUI.Ext第五日--做拖放Darg&Drop

拖放某個元素Darg&Drop是windows(視窗)問世時的一個重要特征。現在我們要在瀏覽器里面實現,怎么做呢?先看看基本例子:

復制代碼 代碼如下:
YAHOO.example.DDApp = function() { 
    var dd; 
    return { 
        init2: function() { 

//   var dropzone =["dz"]; 
//   for(i in dropzone){ 
//           new YAHOO.util.DDTarget(dropzone[i]); 
//    }; 
   var  draggable =["dd_1","dd_2","dd_3"]; //數組存放DargDrop的ID 
    Draggable = function(id, sGroup) { 
    //建立DragDrop對象。這個必須由YAHOO.util.DragDrop的子類來調用 
    //Sets up the DragDrop object. Must be called in the constructor of any YAHOO.util.DragDrop subclass  
    this.init(id, sGroup); 
      } 
   Draggable.prototype = new YAHOO.util.DD(); //繼承父類 
   Draggable.prototype.startDrag = function(x, y) { 
          YAHOO.util.Dom.setStyle(this.getEl(), "opacity", 0.5); 
      } 
   Draggable.prototype.endDrag = function(e) { //拖放后返回原點 
    var draggable = this.getEl(); 
    YAHOO.util.Dom.setStyle(draggable, "opacity", 1.0); 
    draggable.style.left = "0px"; 
    draggable.style.top  = "0px"; 
   } 
   for(i in draggable){ 
     new Draggable(draggable[i]); 
   } 

        } 
    } 
} (); 
注意的地方:

1.這里用了一個數組先收集好所有要DD(Darg&Drop,下同)的元素,再用for遍歷new new YAHOO.util.DD()對象,“捆綁”成一類具有相同屬性的對象:Draggable。

2.遇到一個無法入手的問題:
用YUI做Dragdrop,如果你的系統開clearType ,移動之后字體會發毛,估計ie內部render的問題 。本來打算用DDProxy代替,但一用DDProxy就無法繼承下去。  

3.需手工加入xhtml的holder.  


ok這個例子暫告一段落,看看一些好玩的(演示): 


復制代碼 代碼如下:
var correct = { opt0:"ans1", opt1:"ans2", opt2:"ans0" }     // 正確答案 
var answer  = { opt0:"tmp0", opt1:"tmp1", opt2:"tmp2" }     // 解答 

//  主站蜘蛛池模板: 宁远县| 丁青县| 香河县| 城口县| 宁都县| 太谷县| 梅州市| 日照市| 新津县| 南康市| 青浦区| 化德县| 通辽市| 旬阳县| 绵阳市| 巨鹿县| 乌什县| 六盘水市| 察雅县| 苏州市| 金塔县| 南康市| 华坪县| 宁蒗| 沂南县| 博白县| 清河县| 河南省| 青岛市| 苍山县| 曲阜市| 桂平市| 和平县| 沂源县| 鄂托克前旗| 和静县| 双城市| 永清县| 沂水县| 普安县| 池州市|