"МедиаВики:Common.js"-ны өөр хувилбарууд
No edit summary |
No edit summary Tag: Manual revert |
||
(15 дундын хувилбарууд 2 хэрэглэгчид харагдахгүй) | |||
1-р мөр: | 1-р мөр: | ||
function abs(l) { | function abs(l) { | ||
return l > 0 ? l : l * -1; | |||
} | } | ||
function checkOverflow(el) { | |||
var isOverflowing = el.clientWidth < el.scrollWidth; | |||
return isOverflowing; | |||
} | |||
var readyStateCheckInterval = setInterval(function() { | var readyStateCheckInterval = setInterval(function() { | ||
if (document.readyState === "complete") { | if (document.readyState === "complete") { | ||
clearInterval(readyStateCheckInterval); | clearInterval(readyStateCheckInterval); | ||
try { | try { | ||
var scroll = function(q) { | |||
try { | |||
return function (event){event.preventDefault(); | q.style.overflowX = "auto"; | ||
} catch (e) {} | |||
return function(event) { | |||
if (abs(event.deltaY) > abs(event.deltaX)) { | |||
event.preventDefault(); | |||
var m = 0; | |||
var l = event.deltaY >= 0 ? 1 : -1; | |||
var s = setInterval(function() { | |||
q.scrollLeft += l; | |||
m += 1; | |||
}; | if (m >= abs(event.deltaY)) { | ||
clearInterval(s); | |||
} | |||
}, 2); | |||
} | |||
}; | |||
} catch(e) { | }; | ||
try { | |||
} | var a1 = document.querySelector(".mw-content-ltr"); | ||
if (checkOverflow(a1)) { | |||
a1.addEventListener('wheel', scroll(a1)); | |||
} | |||
var a10 = document.querySelectorAll(".mw-body-content p"); | |||
for (var z = 0; z < a10.length; z++) { | |||
if (checkOverflow(a10[z])) { | |||
a10[z].addEventListener('wheel', scroll(a10[z], true)); | |||
} | |||
} | |||
} catch (e) { | |||
console.log(e); | |||
} | |||
} catch (e) { | |||
console.log("Failed to register horizontal scroll due to: " + e); | |||
} | |||
} | } | ||
}, 10); | }, 10); |
21:17, 17 Аравдугаар сар 2020-ий байдлаарх одоогийн засвар
function abs(l) { return l > 0 ? l : l * -1; } function checkOverflow(el) { var isOverflowing = el.clientWidth < el.scrollWidth; return isOverflowing; } var readyStateCheckInterval = setInterval(function() { if (document.readyState === "complete") { clearInterval(readyStateCheckInterval); try { var scroll = function(q) { try { q.style.overflowX = "auto"; } catch (e) {} return function(event) { if (abs(event.deltaY) > abs(event.deltaX)) { event.preventDefault(); var m = 0; var l = event.deltaY >= 0 ? 1 : -1; var s = setInterval(function() { q.scrollLeft += l; m += 1; if (m >= abs(event.deltaY)) { clearInterval(s); } }, 2); } }; }; try { var a1 = document.querySelector(".mw-content-ltr"); if (checkOverflow(a1)) { a1.addEventListener('wheel', scroll(a1)); } var a10 = document.querySelectorAll(".mw-body-content p"); for (var z = 0; z < a10.length; z++) { if (checkOverflow(a10[z])) { a10[z].addEventListener('wheel', scroll(a10[z], true)); } } } catch (e) { console.log(e); } } catch (e) { console.log("Failed to register horizontal scroll due to: " + e); } } }, 10);