Tôi có màn hình thỏa thuận người dùng. Về cơ bản, chế độ xem HTML có khung nội tuyến và nút. Tôi muốn bật nút khi người dùng cuộn xuống dưới cùng. Tính năng này hoạt động với tất cả các trình duyệt dành cho máy tính để bàn, IE, Chrome, Safari nhưng không hoạt động trên safari di động hoặc chrome trên thiết bị ios. Dường như sự kiện 'di chuyển' không được đính kèm đúng cách. Bạn có thấy một cái gì đó ở đây mà sẽ làm cho công việc đó?Chỉ thị AngularJS cho chế độ xem thỏa thuận người dùng, phát hiện nút bật, không hoạt động trên safari di động
(function() {
angular.module('myapp').directive('textAgreement', function($timeout, ActivityLogService) {
return {
restrict: 'A',
scope: {
onscrollCallback: '&onscrollCallback',
onloadCallback: '&onloadCallback'
},
compile: function(tElement) {
return function(scope, element) {
/** Called on load **/
var appliedCheck = function(event) {
try {
if (typeof scope.onloadCallback !== undefined) {
if (typeof scope.onloadCallback == 'function') {
scope.onloadCallback();
scope.$apply();
}
}
var elm = element[0].contentWindow.document.body;
var newwin = element[0].contentWindow;
if (elm) {
$(newwin).scroll(function() {
var checkBottom = (elm.scrollTop+600) >= elm.scrollHeight;
console.log('###$$$ +++++ ' + elm.scrollTop + ' ' + elm.scrollHeight);
if (checkBottom) {
scope.bottom = true;
if (typeof scope.onscrollCallback !== undefined) {
if (typeof scope.onscrollCallback == 'function') {
scope.onscrollCallback();
scope.$apply();
}
}
}
});
}
} catch(e) {
console.log(e);
}
};
element.bind('load', appliedCheck);
};
}
};
});
})();
<iframe text-agreement onload-callback="disableLoading()" onscroll-callback="enableAgree()" id="agreeFrame" src="{{ ::trustSrcAgreementUri }}" style="border:0" width="100%" height="100%"></iframe>
Và để thực sự giải quyết vấn đề này, bạn có thể thử với sự kiện "chạm vào" thay vì cuộn. –