简体   繁体   English

如何在Sencha Touch中将自定义容器添加到轮播中?

[英]How to add custom container to carousel in Sencha Touch?

How could we add some custom container to the Sencha Touch carousel and avoid it to became a new item that creates second page in carousel? 我们如何才能向Sencha Touch轮播中添加一些自定义容器,并避免使其成为在轮播中创建第二页的新商品?

In other words, how to add container to carousel just before it's scrollable items? 换句话说,如何在可滚动项目之前将容器添加到轮播中?

When I'm trying to add container into carousel's dom via innerHTML I'm losing the listeners defined for container. 当我尝试通过innerHTML将容器添加到轮播的dom时,我丢失了为容器定义的侦听器。

Any thoughts? 有什么想法吗?

Thanks. 谢谢。

Your question isn't very clear, it would be good for you to post some code that you have tried already. 您的问题不是很清楚,最好张贴一些您已经尝试过的代码。 If I am understanding you correctly you can add parent items easily by extending the object hierarchy, for example: 如果我理解正确,则可以通过扩展对象层次结构轻松添加父项,例如:

If you have this: 如果您有这个:

Ext.create("Ext.panel.Panel", {
    xtype: "panel",
    title: "Main Window",
    items: [{
        // carousel code here
    }]
});

You can always add another layer in the middle if you need to: 如果需要,您总是可以在中间添加另一层:

Ext.create("Ext.panel.Panel", {
    xtype: "panel",
    title: "Main Window",
    items: [{
        xtype: "panel",
        title: "My Carousel",
        items: [{
             // carousel code here
        }]
    }]
});

This possibly does not answer your question clearly as the question isn't very clear, if you can update your question with more information and some code to better explain what your trying to achieve, I will update the answer with additional information. 由于问题不是很清楚,这可能无法清楚地回答您的问题,如果您可以使用更多信息和一些代码来更新您的问题,以便更好地解释您要达到的目标,那么我将使用其他信息来更新答案。

if you would like to add components above a carousel view for example a button you have to position it. 如果要在转盘视图上方添加组件,例如按钮,则必须将其放置。 Doing this makes the carousel treat it differently and is not used as a card in the carousel. 这样做会使旋转木马与众不同,并且不会在旋转木马中用作卡。

Altering the example here http://docs-origin.sencha.com/touch/2.4/2.4.1-apidocs/#!/api/Ext.carousel.Carousel to add a button that is always visible is shown in the code below. 下面的代码显示了在此处更改示例http://docs-origin.sencha.com/touch/2.4/2.4.1-apidocs/#!/api/Ext.carousel.Carousel来添加始终可见的按钮的情况。

Ext.create('Ext.Carousel', {
fullscreen: true,

defaults: {
    styleHtmlContent: true
},

items: [
    {
        xtype: 'button',
        text: 'A Button',
        top: 10,
        left: 10
    },
    {
        html : 'Item 1',
        style: 'background-color: #5E99CC'
    },
    {
        html : 'Item 2',
        style: 'background-color: #759E60'
    },
    {
        html : 'Item 3'
    }
]
});

Notice that the button has top and left configs set. 请注意,该按钮已设置了顶部和左侧配置。 This is the key to this behaviour. 这是此行为的关键。

I made a sencha fiddle to help explain. 我做了一个小提琴来帮助解释。

Good luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM