离子范围不能点击ios

ionic range cannot click on ios(离子范围不能点击ios)
本文介绍了离子范围不能点击ios的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am using ionic "range" input in a cross platform project. For android and PC browser, if I click on the area away from the slider node, the slider node will jump to the point I click and the value will be updated.

But for IOS, when I click the area away from the slider node, no value change is happening. And this also make my slider difficult to click, I need to click very accurate right on the slider node, else the slider will not slide. Any idea?

解决方案

I believe I have found a solution for this. Add on-tap() to your element like so:

    <div class="range">
        <input type="range" on-tap="onTap($event)" ng-model="barProgress" min="0" max="100">
    </div>

Then add this in your controller (or feel free to make a directive out of it)

    $scope.onTap = function(e) {
      if(ionic.Platform.isIOS()) {
        $scope.barProgress = (e.target.max / e.target.offsetWidth)*(e.gesture.touches[0].screenX - e.target.offsetLeft);
      }
    };

Essentially what you are doing is calculating the position of the tap relative to the screen, and then adjusting the value to work with the slider, to get the actual input value that it would have been. Then you update the model.

EDIT: This will only work with click/tap event. To make it more smooth and natural, we need to enable swipe/dragging on slider tracks too. Very simple fix will allow devs to do this. Just add on-drag="onTap($event)" so that your html look like this.

<div class="range">
    <input type="range" on-tap="onTap($event)" on-drag="onTap($event)" ng-model="barProgress" min="0" max="100">
</div>

这篇关于离子范围不能点击ios的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)