Skip to content

Commit

Permalink
detect mouse click accross the whole app
Browse files Browse the repository at this point in the history
  • Loading branch information
poju3185 committed Mar 19, 2024
1 parent 16b9002 commit b6d9be7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions kolibri/core/assets/src/kolibri_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export default class KolibriApp extends KolibriModule {
return {};
}

handlePointerDown(event) {
if (event.pointerType === 'mouse' && localStorage.getItem('mouseUsed') !== 'true') {
localStorage.setItem('mouseUsed', 'true');
}
}

setupVue() {
// VueRouter instance needs to be defined to use vuex-router-sync
if (!router._vueRouter) {
Expand Down Expand Up @@ -105,6 +111,10 @@ export default class KolibriApp extends KolibriModule {
...this.stateSetters.map(setter => setter(this.store)),
]).then(() => {
this.startRootVue();
window.addEventListener('pointerdown', this.handlePointerDown.bind(this));
this.rootvue.$on('hook:beforeDestroy', () => {
window.removeEventListener('pointerdown', this.handlePointerDown.bind(this));
});
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
return this.windowBreakpoint < 3;
},
usesTouch() {
return isTouchDevice;
return isTouchDevice && localStorage.getItem('mouseUsed') !== 'true';
},
itemRenderData() {
return {
Expand Down

0 comments on commit b6d9be7

Please sign in to comment.