延迟选择/取消选择滚动器中的图像

Delay in Select/Deselect the image in Scroller

本文关键字:选择 图像 滚动 取消 延迟      更新时间:2023-09-26

问题声明:

我正在使用ng cordova插件从Angularjs创建IOS应用程序,对于我的项目,我使用水平滚动条(如Swipe(。每当我试图选择/取消选择图像时,它的响应都会延迟。我使用$watch((来监视$scope对象的更改。无论是在我的css中,还是在我的控制器,我都无法确定问题产生的位置。请任何人帮助我解决问题。

标记:

<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')
        }

当用户选择/取消选择$scope.showCustom(事件,pf(时,触发pf对象被传递给控制器,并将pf对象分配给$scope.del对象

当用户选择/取消选择$scope.del.imagepath保存图像并更改图像源时

参考:屏幕截图

我同时尝试了$watch((和$watchGroup((函数,它在Select/Deselect 上出现延迟

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

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

删除了上面的CSS,因为你正在从网络移植到移动应用程序-webkit溢出滚动适用于浏览器。有时,当你将你的网络应用程序转换为移动应用程序时,它可能不起作用。

相反,添加以下CSS:

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