#How do I export functions as electron modules?
38 messages · Page 1 of 1 (latest)
Like this?
function startDrag(e) {
isDragging = true;
initialX = e.screenX;
initialY = e.screenY;
}
// Exporter la fonction startDrag
export { startDrag };
Like this
Okk so then I did this:
import { startDrag } from './startDrag.js';
document.getElementById('custom-titlebar').addEventListener('mousedown', (e) => {
startDrag(e);
});
But still nothing
Errors?
No, I don't have any error messages, but I do have the usual drag behavior.
I have to go I'll answer later
Yes, I'm sorry to have kept you waiting. I'm on my git repo and I'm sending you the entire code.
This code :
https://github.com/Rayan-El-Manssouri/Adobe-Phtoshop-2023/blob/main/src/js/appFunction.js
You cant say what supposed to be?
If you enable node integration you can use require
This ?
mainWindow = new BrowserWindow({
width: width,
height: height,
frame: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
webviewTag: true,
},
icon: 'src/assets/logo.png',
});
This
This is already the case, in fact the drag function allows me to create my own custom title bar.
Except that I have 400 lines of javascript code in disarray so I want to create different little module to lighten all that except that as I showed you when I'm in a file appart it does not work properly for example my ipc.send does not work when another end does not work.
I use this :
document.getElementById('custom-titlebar').addEventListener('mousedown', (e) => {
startDrag(e);
});
This way, I can create a custom title bar by moving the window.
Why do you think it doesnt work?
Because when I'm in an appart file I can't move the window or click on my buttons.
Show me devtools console
Replace it to require again
What ?
.js in the end
./js/