简体   繁体   English

离子可滚动标签

[英]Ionic scrollable tabs

Hello I was wondering before I made something my self if ionic has something like scrollable tabs . 你好,我想知道在我做自己的事情之前,如果离子具有类似滚动标签的东西。 I was looking and seen it in the fitrpg app which was made with ionic but I didn't know if it was custom or not. 我正在使用离子制作的fitrpg应用程序中查看并看到它,但我不知道它是否是自定义的。 I'm going to use it for a list like in fitrpg and would have several sections to sort the list differently like top rated, newest, etc. I also saw ionics slide box and thought I could implement it with that if I made a fancy header my self. 我将把它用于像fitrpg这样的列表,并且有几个部分可以对列表进行不同的排序,例如最高评级,最新等等。我还看到了离子滑动盒,并且我认为如果我做了一个幻想,我可以实现它标题我的自我。 But I figured I'd find out if someone made a package for this or has any advice that would be useful if I have to do it myself. 但是我想我会发现有人为此制作了一个包裹,或者如果我必须自己做的话,有任何建议是有用的。 Also here is a picture from fitrpg of what im trying to achieve. 这里还有一张来自fitrpg的图片,展示了我想要实现的目标。 I need tabs like All Active and Completed where you can swipe between them. 我需要像所有活动和已完成的标签,您可以在它们之间滑动。

在此输入图像描述

It is must have feature and al-ready requested in community. 它必须具备功能,并在社区中提出要求。 I am also waiting for scrollable tabs and seems its under consideration !. 我也在等待可滚动的标签,似乎正在考虑之中! May be it will be available in future upcoming release. 可能会在未来即将发布的版本中提供。 See Github issue and Trello . Github问题Trello

I have used html and css in order to make those tabs scrolllable. 我使用了html和css来使这些选项卡可滚动。 I would like to mention that the scrollable tabs feature is not available. 我想提一下,滚动选项卡功能不可用。 However the solution below which I figured out works wonders for me. 然而,我想出的解决方案对我来说很有意义。

You can go on configuring the tabs array with unlimited data in it. 您可以继续配置tabs数组,其中包含无限数据。

NOTE: you will not be able to scroll on browser during development, but as soon as you install the app it will work on swipes ... works also in ionic view 注意:在开发过程中,您将无法在浏览器上滚动,但只要您安装应用程序,它就可以在滑动中工作...也可以在离子视图中工作

HTML code for the section: 该部分的HTML代码:

<ion-header-bar class="bar bar-header row" align-title="center">
               <!-- here goes your header code -->
</ion-header>
<ion-nav-view>
    <ion-content>
              <!-- here ur templates will be injected -->
    </ion-content>   
</ion-nav-view>

<ion-footer-bar>
   <div class="auFooter">
              <div class="auFooterItem" ng-repeat="tab in tabs" id="tab{{tab.id}}" ng-class="{'IAmActive':tab.id===activeTabId}" ui-sref="{{tab.url}}" ng-click="change_tab({{tab.id}})">
                   <p>
                            <img src="{{tab.imageurl}}">
                    </p>
                    <p>
                       {{tab.title}}
                    </p>
              </div>
          </div>

</ion-footer-bar>

CSS FOR THE SAME NOTE: I am using SASS for my css structure: 相同的CSS注意:我使用SASS作为我的CSS结构:

.pad0{
    padding: 0 !important;
}
.padTop0{
    padding-top: 0 !important;
}
.padBottom0{
    padding-bottom: 0 !important;
}
.padLeft0{
    padding-left: 0 !important;
}
.padRight0{
    padding-right: 0 !important;
}



ion-footer-bar{
    @extend .pad0;
    .auFooter{
        height: inherit;
        background-color: #000F22;
        padding: 0;
        width: 100%;
        display: -webkit-box;
        display: -moz-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        flex-flow:row;
        position:absolute;
        left: 0;
        overflow-x: scroll;
        .IAmActive{
                background-color: #E68C00 !important;
        }
        .auFooterItem{
           padding: 10px;
           cursor: pointer;
           color:white;
           overflow: auto;
           font-size:22px;
           background-color: #000F22;//crimson;
           border:1px solid #000710;
           flex:1;
           -webkit-flex:1;
           text-align:center;
           min-width:200px;
            p{
                margin-bottom: 0px;
                font-size: 16px;
                img{
                    height: 34px;
                }
            }
        }
        &::-webkit-scrollbar{
            display: none;
        }
    }

}

.bar{
        height: 60px;   
}
.bar-footer{
        height: 90px;
}

Javascript for changing the tab : 用于更改标签的Javascript:

$scope.activeTabId='tab1';
$scope.change_tab=function(tabid){

            $('#tab1').removeClass("IAmActive");
             if($scope.activeTabId!==tabid){
                $scope.activeTabId=tabid;
             }

}


 $scope.initTabs=function(){
                $('#tab1').addClass("IAmActive");
  }

 setTimeout($scope.initTabs,500);

sample json for tabs 示例json为标签

$scope.tabs = [
                    {
                        "id":1,
                         "title" : 'Gallery',
                         "iconoff":'ion-ios-photos',
                         "iconon":'ion-ios-photos',
                         "url":'home',
                         "tabname":"tab-dash",
                         "imageurl":"img/icons/gallery.png"
                    },
                    {
                        "id":2,
                         "title" : 'Customer Enquiry Form',
                         "iconoff":'ion-android-contact',
                         "iconon":'ion-android-contact',
                         "url":'cenquiry',
                         "tabname":'tab-chats',
                         "imageurl":"img/icons/customer_enquiry.png"
                    },
                    {
                        "id":3,
                         "title" : 'Top 5',
                         "iconoff":'ion-android-star-half',
                         "iconon":'ion-android-star-half',
                         "url":'top5',
                         "tabname":'tab-top5',
                         "imageurl":"img/icons/top-5.png"
                    }
];

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

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