« first day (3656 days earlier)      last day (1275 days later) » 

11:56 AM
Hi! any thoughts on this question, I have edited it. stackoverflow.com/questions/64137093/…
 
 
3 hours later…
2:57 PM
@RoshanMaddumage
 
@underscore Thanks
 
@RoshanMaddumage Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
!!> true && ""
 
@underscore "" Logged: `` Took: 0ms
 
3:14 PM
hi can anyone tell me how to add tooltip to an angular project?
i've been googling all day and I still can't make it work
 
!!magic
 
(∩ ͡° ͜ʖ ͡°)⊃━☆゚. * ・ 。 ᵀᴴᴱ ᴳᴬᴹᴱ
Invalid command! Did you mean: 007, 3, 666? Try help for a list of available commands.
 
!!007
 
<P extends {a: string, b: string[]}>function({a, ...b}: P){}
does this works for ...rest ?
 
3:20 PM
Hi everyone, I'm having a lot of issues just fixing a scroll or getting scroll to position itself to where a certain element is on the page
I have an embedded content that has it's own scroll on my page and when I expand the items, I just want the scroll position to remain the same but continue to load the new contents underneath
I'm having a lot of trouble with this
Any advice would be appreciated?
I'm using React
 
You can't do anything with React for this i guess
 
Or just JavaScript
is fine
I'm still not sure how to best approach this
 
When you change the height of the page, you sometimes need to adjust the scroll position to compensate.
 
Ohh I see
So if more items load on the page, then I have to adjust for that offset right
Like if I have 0-1000 y on the page, then I load items that make the page 0-1500, I have to readjust the scroll?
 
3:35 PM
if the target moves down (asin you added something above it) yes
 
yeah I do
I'll quickly mockup the page, so you see what I'm having trouble with
Just to give you an diea
 
which should be a pretty easy math problem
 
*idea
 
new section height + old position = new position
 
I'm having difficulty with it so much
If you figure out the math, I can code it lol
I think that's my issue, I'm struggling with the math
@KevinB Here's a mockup on what I'm dealing with.
I have a button here "Load All" That will load all the rest of the collection's elements (instead of first 5 elements) and the problem right now is it appends all the rest of the elements to that list and displays them but the cursor/scroll position remains on the "Load All" button and the position gets pushed down instead of remaining on the last element/last position
I need it to remain on the last element
and render all the rest of the contents down.
It's ok if I can no longer see the button as I will remain on the previous scrolled position
Does that make sense?
 
3:49 PM
I understand the problem
i'm just not willing to go much further than that
you need to adjust the scroll position based on the size of the content being added/removed
 
Ok
And just to confirm, going back to what you said
new section height + old position = new position
I'm confused with why it would plus the old position?
and new section height. I want to remain the same offset from the top of the page as the hieght from the top to where I want to be would remain the same
So I'm confused on why actually I would need to recalculate
 
depends on two things:
did the position of the target change, and did the current scroll position of the section change
if either changed, the position needs to be modified
 
the position of the target (the element I want to focus/remain on) did not change
the current scroll position changed but ideally (what I'm really striving for) is to prevent the scroll position to change
I want to remain in the same position
but have the new contents of the collection still load
Does that make sense?
 
yup
if neither change, then you shouldn't have an issue
if you have an issue, then one of them changed
 
yes I have an issue.
Because the new elements gets loaded onto the view, the focus/scroll positions remains on the button
But I want it to remain on the last element/last scroll, not the button
 
4:24 PM
Hi, beginner here. Has someone experiences with Jest and react-router-dom?
 
 
2 hours later…
6:49 PM
Anyone here used superfish before? If yes/no is it good or are there better alternatives
 
6:59 PM
sounds like a scam
 
what does
 
0
Q: Display date with text message based on week day and time

Lubo MasuraHave a great day. I have been looking for this answer everywhere but I have no clue how to solve this. Maybe I am just a step away from my goal. I need to display date with my text based on day and open hours. Demo: Monday: From 12am to 6pm - This product will be shipped on 19.10.2020 (gets today...

 
7:16 PM
Dont think it would be a scam if Northrop Grumman uses it
 
that... makes it even more likely
 
In what way
 
 
2 hours later…
9:32 PM
i have an array of objects that contain duplicates, i want to remove the duplicates but only the older ones (ones with lower index)
 
9:47 PM
basically i want to use something like this:
var family = [{ name: "Mike", age: 10 }, { name: "Matt", age: 13 }, { name: "Nancy", age: 15 }, { name: "Adam", age: 22 }, { name: "Jenny", age: 85 }, { name: "Nancy", age: 2 }, { name: "Carl", age: 40 }],
    unique = [...new Set(family.map(a => a))];

console.log(unique);
but i want Nancy to appear with the age of 2 and not the one with the age of 15
i want the older duplicate to be removed
 
10:10 PM
||> var family = [{ name: "Mike", age: 10 }, { name: "Matt", age: 13 }, { name: "Nancy", age: 15 }, { name: "Adam", age: 22 }, { name: "Jenny", age: 85 }, { name: "Nancy", age: 2 }, { name: "Carl", age: 40 }],
    unique = [...new Set(family.map(a => a))];

console.log(family.reverse().filter((person, index) => index !== family.reverse().findIndex(person2 =>person.name === person2)).reverse())
 
@JBis undefined Logged: [{"name":"Mike","age":10},{"name":"Nancy","age":2},{"name":"Nancy","age":15},{"name":"Adam","age":22},{"name":"Jenny","age":85},{"name":"Matt","age":13},{"name":"Carl","age":40}] Took: 1ms
 
well that didnt work
||> var family = [{ name: "Mike", age: 10 }, { name: "Matt", age: 13 }, { name: "Nancy", age: 15 }, { name: "Adam", age: 22 }, { name: "Jenny", age: 85 }, { name: "Nancy", age: 2 }, { name: "Carl", age: 40 }]

const reverseFam = family.reverse();

console.log(reverseFam.filter((person, index) => index === reverseFam.findIndex(person2 => person.name === person2.name)))
 
@JBis undefined Logged: [{"name":"Carl","age":40},{"name":"Nancy","age":2},{"name":"Jenny","age":85},{"name":"Adam","age":22},{"name":"Matt","age":13},{"name":"Mike","age":10}] Took: 0ms
 
@JoeSaad there we go
super inefficient but it works
 
11:00 PM
const family = [{ name: "Mike", age: 10 }, { name: "Matt", age: 13 }, { name: "Nancy", age: 15 }, { name: "Adam", age: 22 }, { name: "Jenny", age: 85 }, { name: "Nancy", age: 2 }, { name: "Carl", age: 40 }];

const sorted = family.sort((a, b) => a.age - b.age);

const names = new Set();
console.log(family.filter(member => {
    const exists = names.has(member.name);
    if (!exists) {
      names.add(member.name);
    }
    return !exists;
}));
 
@phenomnomnominal Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
 
🤷‍♂️
 

« first day (3656 days earlier)      last day (1275 days later) »