mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-24 23:37:57 +01:00
Fix LCP error:Does not use passive listeners to improve scrolling performance
This commit is contained in:
parent
e13ec8bc30
commit
1eee80658c
15
libraries/jquery.touchevent.js
Normal file
15
libraries/jquery.touchevent.js
Normal file
@ -0,0 +1,15 @@
|
||||
// Passive event listeners
|
||||
function regiterTouchHandler(jQuery) {
|
||||
|
||||
jQuery.event.special.touchstart = {
|
||||
setup: function (_, ns, handle) {
|
||||
this.addEventListener("touchstart", handle, { passive: true });
|
||||
}
|
||||
};
|
||||
jQuery.event.special.touchmove = {
|
||||
setup: function (_, ns, handle) {
|
||||
this.addEventListener("touchmove", handle, { passive: true });
|
||||
}
|
||||
};
|
||||
}
|
||||
export default regiterTouchHandler;
|
@ -17,6 +17,12 @@
|
||||
*/
|
||||
import { $assert } from '@wisemapping/core-js';
|
||||
import { Point } from '@wisemapping/web2d';
|
||||
// https://stackoverflow.com/questions/60357083/does-not-use-passive-listeners-to-improve-scrolling-performance-lighthouse-repo
|
||||
// https://web.dev/uses-passive-event-listeners/?utm_source=lighthouse&utm_medium=lr
|
||||
// eslint-disable-next-line import/extensions
|
||||
import regiterTouchHandler from '../../../../libraries/jquery.touchevent';
|
||||
|
||||
regiterTouchHandler($);
|
||||
|
||||
class ScreenManager {
|
||||
private _divContainer: JQuery;
|
||||
@ -63,8 +69,11 @@ class ScreenManager {
|
||||
}
|
||||
|
||||
addEvent(eventType: string, listener) {
|
||||
if (eventType === 'click') this._clickEvents.push(listener);
|
||||
else this._divContainer.bind(eventType, listener);
|
||||
if (eventType === 'click') {
|
||||
this._clickEvents.push(listener);
|
||||
} else {
|
||||
this._divContainer.bind(eventType, listener);
|
||||
}
|
||||
}
|
||||
|
||||
removeEvent(event: string, listener) {
|
||||
|
Loading…
Reference in New Issue
Block a user