亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

ionic實(shí)現(xiàn)帶字的toggle滑動(dòng)組件

 更新時(shí)間:2016年08月27日 16:14:04   作者:lishihong108  
這篇文章主要為大家詳細(xì)介紹了ionic實(shí)現(xiàn)帶字的toggle滑動(dòng)組件,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

前言

由于項(xiàng)目中需要帶字的toggle滑動(dòng)組件,而ionic提供的是這樣的:

這里寫(xiě)圖片描述

實(shí)際項(xiàng)目中需要這樣子的:

這里寫(xiě)圖片描述

在網(wǎng)上找了下其他的實(shí)現(xiàn),感覺(jué)沒(méi)得類(lèi)似的,也沒(méi)發(fā)現(xiàn)合適的,于是自己試著定義了一個(gè)湊合著用。先上效果圖

這里寫(xiě)圖片描述 

看效果圖邊緣有模糊鋸齒現(xiàn)象,可能是由于像素的影響,在android和ios手機(jī)上表現(xiàn)非常流暢。

實(shí)現(xiàn)代碼

其實(shí)實(shí)現(xiàn)起來(lái)也很簡(jiǎn)單,主要是算好滑塊的位置,滑動(dòng)用的是css的transform.
css用到的類(lèi)如下:

.switch_search{
  position:relative;display:flex;width:120px;height:28px;
  margin-top:8px;border:solid 1px #fff;border-radius:16px;
}
.switch_search_tab{
  flex:1;height:28px;width:60px;
  line-height:28px;color:#203C4B;z-index:12;
}
.white_search_tab{
  color:#fff;
}
.switch_bg{
  background:#fff;border-radius:16px;position:absolute;
  top:-1px;left:-1px;height:28px;width:60px;
}
.search_right{
  transition: -webkit-transform,transform 0.6s ease; 
  -webkit-transform: translate3d(60px, 0, 0);
  -moz-transform: translate3d(60px, 0, 0); 
  transform:translate3d(60px, 0, 0);
}
.search_left{
  transition: -webkit-transform,transform 0.6s ease; 
  -webkit-transform: translate3d(0px, 0, 0);
  -moz-transform: translate3d(0px, 0, 0); 
  transform:translate3d(0px, 0, 0);
}

 頁(yè)面上html代碼:

<div class="switch_search">
  <div class="switch_search_tab" on-swipe-right="activeSlideSearch(1)" ng-click="activeSlideSearch(0)" ng-class="(slideIndexSearch==0 ||slideIndexSearch==-1) ? '' : 'white_search_tab'">
    月
  </div>
  <div class="switch_search_tab" on-swipe-left="activeSlideSearch(0)" ng-click="activeSlideSearch(1)" ng-class="(slideIndexSearch==1) ? '' : 'white_search_tab'">
    日
  </div>
  <div class="switch_bg" ng-class="(slideIndexSearch==0 ||slideIndexSearch==-1) ? 'search_left' :'search_right'"></div>
</div>

對(duì)應(yīng)的Controller js代碼如下:

$scope.slideIndexSearch=-1; 
$scope.activeSlideSearch = function(index) {
  $scope.slideIndexSearch=index;
};

如此,便可實(shí)現(xiàn)簡(jiǎn)單的帶字的滑動(dòng)的toggle組件。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論