2012-01-30 75 views
1

enter image description here我想切换按钮上的图像上下滑动。当我点击下面的扩展器按钮 应该减少。切换和动画在sencha触摸

在jquery中,我使用了一些这样的事情来达到预期的效果。

$(function() { 
    $("#legendExpand").toggle(function() { 
     $("#legend").animate({'top': "370px"}); 
     $("div#legendExpand").html('<img src="img/expander-up.png" width="27" height="27"/>');   
    }, function() { 
     $("#legend").animate({'top': "285px"}); 
     $("div#legendExpand").html('<img src="img/expander-down.png" width="27" height="27"/>'); 
    }); 
}); 

我不确定如何使用sencha touch来实现它。

我能够检测到如下所示的点击事件。

var legend = new Ext.Panel({ 
     id: 'legendPanel', 
     html: '<div id="legend"><div id="legendExpand" class="legendExpand"><img class="expanderImage" src="resources/images/expander-down.png" width="27" height="27"/></div><div class="clear"></div><div id="layerOne"><div class="section">Availability:</div><div class="section" id="key"><div id="colorKey" class="dropUp"><div class="top"><div class="colorLink">Standard Colors</div><div class="clear"></div><div class="divider"></div><div class="colorLink">High Contrast</div><div class="clear"></div><div class="divider"></div><div class="colorLink">Color Blind (Red/Green)</div><div class="clear"></div><div class="divider"></div><div class="colorLink">Color Blind (Blue/Yellow)</div><div class="clear"></div><div class="divider"></div></div><!-- END top --><div class="bottom"><div class="standardColors"><img src="resources/images/standardColors.png" width="129" height="29" /></div><div class="clear"></div></div><!-- END bottom --></div><!-- END colorKey --><!--<div id="changeColorsLink"><a href="#"><strong>Change Colors</strong></a></div> END changeColorsLink --></div><!-- END section --><div class="clear"></div><div class="dotted"></div><div id="layerTwo"><ul class="legend"><li>Key:</li><li><img src="resources/images/legend_P.png" width="22" height="34" /></li><li>Parking<br />Facilities</li><li><img src="resources/images/legend_PR.png" width="33" height="34"/></li><li>Park &amp; Ride<br />Facility</li><li><img src="resources/images/legend_SP.png" width="27" height="34" /></li><li>Street<br />Parking</li></ul></div><div class="clear"></div></div><!-- END layerOne --></div>', 
     listeners: { 
      'afterrender': function() { 
       Ext.getCmp('legendPanel').getEl().on('click', function (e, t) { 
        e.stopEvent(); 


      }, null, { delegate: 'img.expanderImage' }); 
     } 
    } 
    }); 

回答

0

尝试:

this.hide(); this.destroy(); this.doLayout();

上面将隐藏图例组件。然后,您可以使用正确的扩展器映像更新html(您需要在doLayout之前执行此操作,因为这会强制重绘)。

您也可以参考legendPanel作为this,而不是使用Ext.getCmp()。