Commit 6dbfab71 authored by akiraohgaki's avatar akiraohgaki

Try smooth scroll

parent f9ae22c1
......@@ -116,7 +116,9 @@ export default class WebviewComponent extends BaseComponent {
this._webview.openDevTools();
}
//this._webviewElement.send('ipc-message');
//this._webview.send('ipc-message');
this._webview.send('smooth-scroll');
});
this._webview.addEventListener('new-window', (event) => {
......@@ -133,7 +135,7 @@ export default class WebviewComponent extends BaseComponent {
}
});
//this._webviewElement.addEventListener('ipc-message', (event) => {});
//this._webview.addEventListener('ipc-message', (event) => {});
this.contentRoot.appendChild(this._webview);
}
......
/*
const {ipcRenderer} = require('electron');
ipcRenderer.on('smooth-scroll', () => {
let scrollLeft = document.scrollingElement.scrollLeft;
let scrollTop = document.scrollingElement.scrollTop;
let previousScrollLeft = 0;
let previousScrollTop = 0;
let intervalId = null;
document.scrollingElement.addEventListener('wheel', (event) => {
event.preventDefault();
scrollLeft += event.deltaX;
scrollTop += event.deltaY;
if (intervalId === null) {
intervalId = setInterval(() => {
if (scrollLeft === previousScrollLeft && scrollTop === previousScrollTop) {
window.clearInterval(intervalId);
scrollLeft = document.scrollingElement.scrollLeft;
scrollTop = document.scrollingElement.scrollTop;
previousScrollLeft = 0;
previousScrollTop = 0;
intervalId = null;
}
else {
document.scrollingElement.scrollTo({
left: scrollLeft,
top: scrollTop,
behavior: 'smooth'
});
previousScrollLeft = scrollLeft;
previousScrollTop = scrollTop;
}
}, 100);
}
});
});
/*
ipcRenderer.on('user-profile', () => {
const profileMenu = document.querySelector('[rel="profile-menu"]');
if (profileMenu) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment