Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sencha touch 禁用在旋转木马中拖动_Sencha Touch - Fatal编程技术网

Sencha touch 禁用在旋转木马中拖动

Sencha touch 禁用在旋转木马中拖动,sencha-touch,Sencha Touch,是否可以禁用使用拖动在转盘面板之间交换? 我想使用just indicator。尝试在Carousel中覆盖afterRender方法;(我删除了childs方法上的拖动事件) 整个代码 this.car = new Ext.Carousel({ ui : 'light', items: [ { html: '<p>Carou

是否可以禁用使用拖动在转盘面板之间交换?
我想使用just indicator。

尝试在Carousel中覆盖afterRender方法;(我删除了childs方法上的拖动事件)

整个代码

 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)
                        }
        });
this.car=新的外部传送带({
ui:“轻”,
项目:[
{
html:“旋转木马可以是垂直的,并提供一个“亮”或“暗”的用户界面。”,
cls:“卡卡1”
},
{
html:“卡片#2”,
cls:“信用卡2”
},
{
html:“卡片#3”,
cls:“信用卡3”
}],
afterRender:function(){
Ext.Carousel.superclass.afterRender.call(this);
this.mon(this.body{
方向:这个方向,
范围:本
});
this.el.addCls(this.baseCls+“-”+this.direction)
}
});

只是为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; }
});
这将完全像一个旋转木马,除了现在你可以在上面调用.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'
        }
     ]
}));
Ext.Viewport.add(Ext.create('Ext.LockableCarousel'),{
id:“可锁定旋转木马”,
全屏:对,
隐藏:假,
项目:[
{
html:“项目1”,
样式:“背景色:#5E99CC”
},
{
html:“
”, 样式:“背景色:#759E60” } ] }));
谢谢,它很有效。但我不知道它是怎么回事:)你能解释一下吗?当然。这个想法很简单。我们必须禁用拖动,在这种情况下,可以删除拖动侦听器。在sencha-touch.js的afterRender方法中添加了拖动侦听器。我们重写了afterRender方法,因此sencha touch的afterRender方法不会运行,新方法会运行,并且我们的方法不会添加拖动侦听器。我希望这个描述是清楚的。:)谢谢你的代码示例。它甚至禁用了指示器,所以我只需要暂时锁定旋转木马就可以了。非常简单。我将“locked”变量移动到config对象中,以便在添加自定义旋转木马时设置默认锁定状态。这将访问锁定的变量更改为:This.getLocked();
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'
        }
     ]
}));