I have a navbar which needs to change colour on scroll. This functionality was originally built with js, however now it has a 'Login' button which is built in elm to perform other functionality.
I used a port and subscription to change the colour of the elm login button using the original js. The colour change works however sometimes there is a lag between the login button and the rest of the navbar changing colour and so the button momentarily disappears. Sometimes however the colour change is seamless.
I tried switching the order in which the js function and the subscription was sent to see if it would make a difference, but it didn't. I understand the fact that elm is asynchronous will impact the order in which it/the js displays but I'm not sure how I can make it smooth in this situation.
Does anyone know how I can remove this lag?
Here is the js ports code:
window.onscroll = function() {
if (this.scrollY <= 20) {
if (!isTop) {
isTop = true;
setTransparentNav(); // this is a simple CSS class change fn
app.ports.colorChanges.send(isTop); // this is the UI which is lagging
}
} else {
if (isTop) {
isTop = false;
setBlackNav();
app.ports.colorChanges.send(isTop);
}
}
};
This is the port in the Elm:
port colorChanges : (Bool -> msg) -> Sub msg
The message it sends is a simple Bool which when True dictates which classes are used.
Prelog: I have implemented Google maps and Geolocation as a independent widgets, Now the user have the ability to add the widget as much as he wants in a page he is owns. I am using $.getScript(URl, ...
Prelog: I have implemented Google maps and Geolocation as a independent widgets, Now the user have the ability to add the widget as much as he wants in a page he is owns. I am using $.getScript(URl, ...
I have Table (Employees) A: +----+---------+ | ID | NAME | +----+---------+ | 1 | ROBERT | | 2 | JAMES | | 3 | RICHARD | | 4 | KANYE | | 5 | DYLAN | | 6 | JOHN | | 7 | JEAN | | ...
I have Table (Employees) A: +----+---------+ | ID | NAME | +----+---------+ | 1 | ROBERT | | 2 | JAMES | | 3 | RICHARD | | 4 | KANYE | | 5 | DYLAN | | 6 | JOHN | | 7 | JEAN | | ...
I have the following path: /s/STRINGINEED/abcdef/ How should I structure my regex to match STRINGINEED as a result? /s/ is a fixed path, so I would like to get any string between /s/ and the ...
I have the following path: /s/STRINGINEED/abcdef/ How should I structure my regex to match STRINGINEED as a result? /s/ is a fixed path, so I would like to get any string between /s/ and the ...
I want to call two functions passes via props on click. Note that both of them need arguments of their own. After a bit of searching on Stack Overflow, I found this solution: onclick={()=>{ f1(); ...
I want to call two functions passes via props on click. Note that both of them need arguments of their own. After a bit of searching on Stack Overflow, I found this solution: onclick={()=>{ f1(); ...