Skip to content

Commit 6690ce5

Browse files
committed
feat: improve scroll/touch performance
1 parent e5e0033 commit 6690ce5

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

js/admin.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@
760760
// Load existing media
761761
csk.ajax.request(url, {
762762
type: "GET",
763-
beforeSend: function () {
763+
beforeSend: function() {
764764
$browser.empty().html('<div class="text-center py-5 text-muted">'+csk.i18n.default.loading+'</div>');
765765

766766
$insert.prop('disabled', true);
@@ -916,7 +916,11 @@
916916
});
917917
}, 0));
918918

919-
csk.ui.delegate('click', '[data-media-browse]', function () {
919+
/**
920+
* Media browser access.
921+
* @since 3.12.0
922+
*/
923+
csk.ui.delegate('click', '[data-media-browse]', function() {
920924
const el = this;
921925

922926
csk.media.browse({
@@ -928,6 +932,26 @@
928932
});
929933
});
930934

935+
/**
936+
* Improves scroll/touch performance automatically.
937+
* @since 3.12.0
938+
*/
939+
document.addEventListener("DOMContentLoaded", function() {
940+
try {
941+
let opts = Object.defineProperty({}, 'passive', {
942+
get: function () {
943+
window.__passiveSupported = true;
944+
}
945+
});
946+
window.addEventListener('test', null, opts);
947+
} catch (e) {}
948+
949+
if (window.__passiveSupported) {
950+
document.addEventListener('touchstart', function(){}, { passive: true });
951+
document.addEventListener('wheel', function(){}, { passive: true });
952+
}
953+
});
954+
931955
// Things to do when the page is ready!
932956
$(document).ready(function() {
933957
/**

0 commit comments

Comments
 (0)