延迟 Select/Deselect Scroller 中的图像

Delay in Select/Deselect the image in Scroller

问题陈述:

我正在使用 ng-cordova 插件 从 Angularjs 创建 IOS App,对于我的项目我我正在使用 水平滚动条(如滑动),每当我尝试 select/Deselect 图像时,它的响应是 delay.I 使用 $watch() 来观察变化我的 $scope object.I 无法确定问题出在哪里,无论是在 my css 中还是在 my controller 中.请任何人帮助我解决问题。

标记:

<div class="wrapper no-copy">
<div class="internal" ng-repeat="pf in printlist"><img class="" ng-click="pf.selectFile = !pf.selectFile ;showCustom($event,pf)" ng-src="{{pf.imagePath}}"><div class="no-copy filedetail"><div style="color:black;margin-left:7px;" class=" no-copy internal font-filedetail">{{pf.filename.substring(0,8)}}..</br>Pages: {{pf.totalPages}}</br>{{pf.releaseCode}}</div><div class="internal filedetailbar"><img style="height:70px;" src="images/beacon/line_icon.png"></div></div>
</div>
</div>

CSS:

.wrapper {
  width: 100%;
  white-space: nowrap;
  overflow-y: hidden;
  overflow-x: scroll;
  -webkit-overflow-scrolling: touch;
  padding: 1rem;
  background-color: white;
  // Toggle this depending upon whether you want to see the scrollbar
  &::-webkit-scrollbar {
    display: none;
  }
}

.internal {
  display: inline;
}

控制器:

$scope.showCustom = function (event, detail) {
            console.log('detail')
            console.log(detail)
            /*$mdDialog.show({
             locals: {name: detail},
             clickOutsideToClose: true,
             scope: $scope,
             preserveScope: true,
             templateUrl: 'ibprintProcessList/filedetail.html',
             controller: function DialogController($scope, $mdDialog, name) {*/

            $scope.del = detail;
            console.log($scope.del.color)
            console.log('*************')
            console.log($scope.del)
            if (!$scope.del.color) {
                $scope.color = false
            }
            if ($scope.del.selectFile) {
                $scope.filestatus = 'selected '
                $scope.disabled = false
                $scope.isFileSelect = $scope.isFileSelect + 1
                $scope.selectfileextension = $scope.del.filename.split('.')
                console.log('???????????????')
                console.log($scope.selectfileextension[1])
                if (($scope.selectfileextension[1] == 'pdf') || ($scope.selectfileextension[1] == 'rtf')) {
                    $scope.del.imagePath = "./images/beacon/pdf_icon_select.png"
                }
                else if (($scope.selectfileextension[1] == 'doc') || ($scope.selectfileextension[1] == 'docx')) {
                    $scope.del.imagePath = "./images/beacon/word_icon_select.png"
                }
                else if (($scope.selectfileextension[1] == 'xls') || ($scope.selectfileextension[1] == 'xlsx')) {
                    $scope.del.imagePath = "./images/beacon/xls_icon_select.png"
                }
                else if (($scope.selectfileextension[1] == 'ppt') || ($scope.selectfileextension[1] == 'pptx')) {
                    $scope.del.imagePath = "./images/beacon/pp_icon_select.png"
                }
                else if (($scope.selectfileextension[1] == 'png') || ($scope.selectfileextension[1] == 'jpg') || ($scope.selectfileextension[1] == 'jpeg') || ($scope.selectfileextension[1] == 'bmp') || ($scope.selectfileextension[1] == 'gif') || ($scope.selectfileextension[1] == 'tiff') || ($scope.selectfileextension[1] == 'tif')) {
                    $scope.del.imagePath = "./images/beacon/image_icon_select.png"
                }
            }
            else {
                $scope.disabled = true
                $scope.isFileSelect = $scope.isFileSelect - 1
                $scope.filestatus = 'unselected '
                $scope.selectfileextension = $scope.del.filename.split('.')
                if (($scope.selectfileextension[1] == 'pdf') || ($scope.selectfileextension[1] == 'rtf')) {
                    $scope.del.imagePath = "./images/beacon/pdf_icon.png"
                }
                else if (($scope.selectfileextension[1] == 'doc') || ($scope.selectfileextension[1] == 'docx')) {
                    $scope.del.imagePathh = "./images/beacon/word_icon.png"
                }
                else if (($scope.selectfileextension[1] == 'xls') || ($scope.selectfileextension[1] == 'xlsx')) {
                    $scope.del.imagePath = "./images/beacon/xls_icon.png"
                }
                else if (($scope.selectfileextension[1] == 'ppt') || ($scope.selectfileextension[1] == 'pptx')) {
                    $scope.del.imagePath = "./images/beacon/pp_icon.png"
                }
                else if(($scope.selectfileextension[1] == 'png') || ($scope.selectfileextension[1] == 'jpg') || ($scope.selectfileextension[1] == 'jpeg') || ($scope.selectfileextension[1] == 'bmp') || ($scope.selectfileextension[1] == 'gif') || ($scope.selectfileextension[1] == 'tiff') || ($scope.selectfileextension[1] == 'tif')){
                    $scope.del.imagePath = "./images/beacon/image_icon.png"
                }
            }

            /*$scope.closeDialog = function () {
             $mdDialog.hide();
             //$scope.printNow()
             }*/
            $scope.del.$digest()
            $scope.printlist.$digest()
            console.log('Watch function starts')
       // $scope.$watch($scope.del, $scope.showCustom);
        $scope.$watchGroup(['$scope.del', '$scope.printlist'],$scope.showCustom,true)
        console.log('Watch function ends')
        }

当用户Select/Deselect触发$scope.showCustom(event,pf) pf 对象被传递给控制器​​并将 pf 对象分配给 $scope.del object

当用户 Select/Deselect $scope.del.imagepath 持有图片并更改图片来源

参考图像:Screen Shot

我尝试了 $watch() 和 $watchGroup() 函数,它在 Select/Deselect

上出现延迟

只需使用一个使用溢出样式的简单水平滚动条,它将在您的移动应用程序上用作 SWIPE。

-webkit-overflow-scrolling: touch;
 &::-webkit-scrollbar {
    display: none;
  }

删除了上面的 CSS,因为您要从 Web 移植到移动应用程序。 -webkit-overflow-scrolling 适用于浏览器。有时它 may/maynot 在您将网络应用程序转换为移动应用程序时起作用。

而是添加以下 CSS:

overflow-y: hidden;
overflow-x: scroll;
width: 500px;         // you can change the width size depends on you
white-space: nowrap;