angularjs 水平滚动选中按钮高亮显示 swiper和回到顶部指令的实现ionic
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了angularjs 水平滚动选中按钮高亮显示 swiper和回到顶部指令的实现ionic,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2186字,纯文字阅读大概需要4分钟。
内容图文
首先安装 swiper npm install --save swiper 或者 bower install --save swiper
<link rel="stylesheet" href="../bower_components/swiper/dist/css/swiper.min.css" /> <script src="../bower_components/swiper/dist/js/swiper.jquery.min.js"></script>
指令文件代码
(function() { ‘ use strict ‘ ; angular .module( ‘ campus.core ‘ ) .directive( ‘ swiperSlide ‘ ,swiperSlide) .directive( ‘ goToTop ‘ ,goToTop); swiperSlide.$inject = [‘$timeout‘]; function swiperSlide($timeout) { return { restrict: "EA", link: function(scope, element, attrs) { $timeout(function(){ var swiper2 = new Swiper(‘.swiper-container2‘, { slidesPerView: ‘auto‘, freeMode: true }); },100); } }; } goToTop.$inject = [‘$ionicScrollDelegate‘,‘$timeout‘]; //ionic中返回顶部的方法 $ionicScrollDelegate function goToTop($ionicScrollDelegate,$timeout) { return { restrict: "EA", scope: { reload: "&" }, template: ‘<span id="goToTop" class="goToTop"></span>‘, link: function(scope, element, attrs) { element.bind(‘click‘,function(){ $timeout(function(){ var scroll = parseInt(document.getElementById(‘goToTop‘).offsetTop) - parseInt($ionicScrollDelegate.getScrollPosition().top); var scroll = scroll-document.getElementById(‘goToTop‘).offsetTop; $ionicScrollDelegate.resize(); $ionicScrollDelegate.scrollBy(0,scroll,true); //大于两页时显示分页 },100); }) } }; } })();
回到顶部的逻辑
回到顶部对应的对应html中的内容
<go-to-top></go-to-top>
回到顶部按钮css文件
.goToTop{width:4.17rem;height: 4.17rem;position: fixed;bottom:2.6rem;right: 1.25rem;z-index: 11;background: url(../assets/images/goToTop.png) no-repeat;background-size: contain;display: none;} .goToTop.none{display: none;}
左右滑动对应的html代码
<div class="index-tab zw-tab s15"> <ul class="swiper-wrapper"> <li class="swiper-slide" ng-repeat="items in vm.data" ng-click="vm.switchType(items.type,$index)"> <span ng-class="{‘active‘:$index==vm.typeOn}">{{items.typeName}}</span> </li> </ul> </div>
vm= this;
vm.typeOn = 0; //默认第一个高亮显示
vm.switchType =function(type,index){ vm.typeOn = index; vm.type = type; initList(type,0); //类型对应的数据请求 }
$ionicScrollDelegate
原文:http://www.cnblogs.com/kbnet/p/6919398.html
内容总结
以上是互联网集市为您收集整理的angularjs 水平滚动选中按钮高亮显示 swiper和回到顶部指令的实现ionic全部内容,希望文章能够帮你解决angularjs 水平滚动选中按钮高亮显示 swiper和回到顶部指令的实现ionic所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。