« first day (4084 days earlier)      last day (1087 days later) » 

01:21
yo yo
i feel as if i've moved on from JS :(
i don't work in it anymore
 
13 hours later…
14:11
@JBis nonsense
 
1 hour later…
15:35
posted on December 21, 2021 by Nicholas C. Zakas

In part 11 of this series, I described how companies make decisions about spending their money and why they might (or might not) sponsor an open source project. If you haven’t yet read that post, I’d suggest going back to do so now before continuing. Everything in this post builds off the topics discussed in...

🚽
15:56
Can anyone please let me know why offsetTop - offsetHeight aren't calculated properly? I would like to add navigation on the top of the menu to navigate user to the FAQs section but it seems the FAQs title is cut into half when doing so. Any suggestion?
let ele = document.getElementById('faqs');
window.scrollTo(0, ele.nextElementSibling.offsetTop - document.getElementsByClassName('page-header')[0].offsetHeight)
You can just paste the script into the console to see the current behavior
!!MDN offsetHeight
is the result wrong, or is the location it is scrolling you to wrong
@KevinB If you would paste this twice then you could see the scrollTo works properly so yeah it's not properly scroll to the exact position
window.scrollTo(0, ele.nextElementSibling.offsetTop - document.getElementsByClassName('page-header')[0].offsetHeight)
sorry, i'm not visiting the site
my point is, this is a calculated value, you can take the things that add up to it and calculate it yourself, to see if it comes up with the scrollTo value you'd need to get where you wanted
at that point, you could figure out how much you are off and determine where it is coming from
16:04
The behavior is quite strange because of fixed navbar so when scrollTo is called from top of the page then it almost cuts the section title into half or when it's from any other section of the page, then it scroll properly into the view.
16:35
xhr.open("GET", "http://localhost:8003/Main.php?request=ready", false);
xhr.send();

// stop the engine while xhr isn't done
for(; xhr.readyState !== 4;)
*facepalm*
what's wrong with that
The false in the first line is the async flag.
i mean
both with false and true, the for loop would be pointless
Yep. Also, notice how it doesn't have a ; at the end? Well, it's actually looping the code that comes up next.
seems reasonable
so, effectively, what happens with that code is the xhr is sent, and when it's done, the for loop is reached. readyState should be 4 at that point, so the content of the for loop never runs
it'd "work", by some definitions of work
17:03
oh wow, it's been a while since I've read about readyState
I have a usecallback function in React that is getting stale state; can anyone help me figure out why?

https://codesandbox.io/s/sad-mclean-pmu3i?file=/src/App.js
@duhaime look at the eslint warnings
damn son
thank you
 
3 hours later…
20:16
I'm back for more. I have a typescript enum that looks like:
enum A {
  B,
  C,
}
interface B {
  yeet: boolean;
}

interface C {
  yeet: boolean;
}
But tsc is barking that property yeet does not exist on type A--what am I missing?
20:30
type A =
| B
| C

worked
20:43
Now how about this one:
if (index + 1 < indices.length) {
  setIndex(indices[index + 1]);
}
typescript barks Type 'undefined' is not assignable to type 'SetStateAction<number>'
how is indices defined
21:24
o/
Hows it goin Kevin
21:42
indices is the result of a function that returns an array with 0 or more integers, and index is always an int
 
1 hour later…
22:52
that error tells me typescript thinks indices[index + 1] can be undefined

« first day (4084 days earlier)      last day (1087 days later) »