jty*_*ann 11
只是把它扔给Sencha Touch 2.0的人.上述解决方案不适用于Sencha Touch 2.0,但有一个非常简单的方法.
Ext.define('Ext.LockableCarousel', {
extend: 'Ext.Carousel',
id: 'WelcomeCarousel',
initialize: function () {
this.onDragOrig = this.onDrag;
this.onDrag = function (e) { if(!this.locked){this.onDragOrig(e);} }
},
locked: false,
lock: function () { this.locked = true; },
unlock: function () { this.locked = false; }
});
Run Code Online (Sandbox Code Playgroud)
这将完全像一个旋转木马,除了现在你可以调用.lock和.unlock.所以你可以这样做:
Ext.Viewport.add(Ext.create('Ext.LockableCarousel', {
id: 'LockableCarousel',
fullscreen: true,
hidden: false,
items: [
{
html : 'Item 1',
style: 'background-color: #5E99CC'
},
{
html : '<a href="#" onclick="Ext.getCmp(\'LockableCarousel\').lock();">Lock</a><br /><a href="#" onclick="Ext.getCmp(\'LockableCarousel\').unlock();">Unlock</a>',
style: 'background-color: #759E60'
}
]
}));
Run Code Online (Sandbox Code Playgroud)
尝试在 Carousel 中重写 afterRender 方法;(我删除了子方法上的拖动事件)
afterRender : function() {
Ext.Carousel.superclass.afterRender.call(this);
this.mon(this.body, {
direction : this.direction,
scope : this
});
this.el.addCls(this.baseCls + "-" + this.direction)
}
Run Code Online (Sandbox Code Playgroud)
完整代码;
this.car = new Ext.Carousel({
ui : 'light',
items: [
{
html: '<p>Carousels can be vertical and given a ui of "light" or "dark".</p>',
cls : 'card card1'
},
{
html: 'Card #2',
cls : 'card card2'
},
{
html: 'Card #3',
cls : 'card card3'
}],
afterRender : function() {
Ext.Carousel.superclass.afterRender.call(this);
this.mon(this.body, {
direction : this.direction,
scope : this
});
this.el.addCls(this.baseCls + "-" + this.direction)
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4151 次 |
| 最近记录: |