demo20230512/Browser_Local/js/Directive/CustomScroll.js
2023-05-12 10:20:28 +08:00

51 lines
2.2 KiB
JavaScript

/*
Logic Solution
WeeeCarbonFootprint
Template Directive
*/
angular.module('View.Directive')
.directive('customScroll', function () {
return {
restrict: 'A',
controller: function ($scope) {
var mousewheelevt = (/Firefox/i.test(navigator.userAgent)) ? "DOMMouseScroll" : "mousewheel";
if (document.attachEvent) //if IE (and Opera depending on user setting)
document.attachEvent("on" + mousewheelevt, function (e) {
alert('A Mouse wheel movement detected!')
})
else if (document.addEventListener) //WC3 browsers
document.addEventListener(mousewheelevt, function (e) {
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var s;
(s = ua.match(/rv:([\d.]+)/)) ? Sys.ie = s[1] :
(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
(s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
(s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
(s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
if (Sys.ie) {
console.log('IE: ' + Sys.ie);
console.log(e.wheelDelta);
}
if (Sys.firefox) {
console.log('Firefox: ' + Sys.firefox);
console.log(e.detail);
}
if (Sys.chrome) {
console.log('Chrome: ' + Sys.chrome);
console.log(e);
}
if (Sys.opera) {
console.log('Opera: ' + Sys.opera);
console.log(e.wheelDelta);
}
if (Sys.safari) {
console.log('Safari: ' + Sys.safari);
console.log(e.wheelDelta);
}
}, false)
}
}
})