ionic-scroll,页面难以上下滑动的解决方案

在混合app开发中,使用Ionic的指令创建水平滑动画廊功能。然而,当页面包含多个此类控件时,页面上下滑动变得困难。原因是输入框或会捕获滑动事件。为解决此问题,可以不使用,而是通过监听touchmove和touchstart事件,自定义左右滑动行为,实现顺畅的页面滚动。
摘要由CSDN通过智能技术生成

混合app开发使用ionic框架的<ion-scroll>指令能够方便地实现水平滚动和垂直滑动。比如我们想实现一个能够水平滑动的画廊,可以使用下面这段代码。

[html]  view plain   copy
  1. <html>  
  2.   <head>  
  3.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />   
  4.     <script src="jquery-1.11.1.min.js"></script>  
  5.     <script src="./1.1.1-release/js/ionic.bundle.js"></script>  
  6.     <link rel="stylesheet" type="text/css" href="./1.1.1-release/css/ionic.css" />  
  7.     <style>  
  8.     /*nowrap不让img换行*/  
  9.     .picturesholder{  
  10.         background-color:#fff;  
  11.         margin:20px;  
  12.         width:400px;  
  13.         height:80px;  
  14.         overflow: hidden;  
  15.         white-space: nowrap;  
  16.     }  
  17.       
  18.     /**图片占满画廊*/  
  19.     .picturesholder img{  
  20.         width:100px;  
  21.         height:81px;  
  22.     }  
  23.     </style>  
  24.   
  25.     <script>  
  26.     var testModule = angular.module('testApp', ['ionic']);  
  27.     testModule.controller('MyController', function($scope, $ionicScrollDelegate) {  
  28.         $scope.pictures=["imgs/1.png","imgs/2.png","imgs/3.png","imgs/4.png","imgs/5.png","imgs/6.png","imgs/7.png","imgs/8.png"];  
  29.     });  
  30.       
  31.     $(function(){  
  32.         angular.bootstrap($("#body"), ["testApp"]);   
  33.     })  
  34.     </script>  
  35. </head>  
  36.   
  37. <body id="body" ng-controller="MyController">  
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值