• Activity
  • Votes
  • Comments
  • New
  • All activity
  • Showing only topics in ~comp with the tag "development". Back to normal view / Search all groups
    1. Vibe coding is just the return of Excel/Access, with more danger

      I probably triggered some PTSD right there. Was just in a meeting at work, where we listed off everything that makes software development hard and slow. An excersize for the thread would be to...

      I probably triggered some PTSD right there.

      Was just in a meeting at work, where we listed off everything that makes software development hard and slow. An excersize for the thread would be to replicate that list. It turned out that Claude helps with like 1/5th or less of it....especially in a collaborative environment.

      So, the situation we're now encountering is that random business areas can vibe code out something, tell nobody, throw it in AWS, have it become a critical part of a business process that fails when they quit, and nobody even has access to look at what was made.

      It gives me comfort that in about 5 years there will be a new surge in demand for programmers to reign in all the rogue applications that need shutdown because of the immense risk to continual operation of a company, from data leaks to broken payroll.

      It'll be Y2K all over again.

      39 votes
    2. Any beginners advice or resources on developing a 2D RPG/Puzzle video game?

      Hey guys, I hope this is the right place to post. So my adhd hyperfixation has recently shifted towards an idea for a game and I want to indulge my ADHD by learning all I can about game...

      Hey guys, I hope this is the right place to post.

      So my adhd hyperfixation has recently shifted towards an idea for a game and I want to indulge my ADHD by learning all I can about game development to see if I can achieve this idea to the point that maybe I can put it in "Early Access" to fund even more resources on it.

      But I'm not sure where to start. I'm looking into Godot because it's free and open source and has a lot of community resources, but also wanted to see if anyone had any ideas here.

      I have some coding experience, a lot of technical experience and pick things up extremely quickly.

      The basic idea is that it's a 2D Sidescrolling RPG, but with Match-3 "Candy Crush"-esque mechanics for battles and fighting.

      Extra details If you've played "You Must Build A Boat" or "10000000", it's a LOT kind of like that, in fact those games kind of inspired me, but more refined with a lot more in depth RPG elements and it's a bit more forgiving focusing on keeping a "flow" going, since one of my biggest pet peeves is YMBAB's RNG being very unforgiving and you'll randomly just sit there staring at the board with no moves until you die.

      So the systems/mechanics I'd need to combine to work together are the following:

      • A Match-3 type board where you match tiles, make special tiles by combining 4 or more tiles, all the features of a typical match-3 type game, just tied to outcomes outside of the board-interface.
      • An RPG element, with character attributes, leveling, items, spells, weapons, gear, potions, etc. These elements effect what tiles are on the board during gameplay, effect the chances of certain tiles, and effect health, speed, mana, or grants special in-game abilities like "Precognition"(gives a hint for a move), or "Scroll of Revival"(You can continue without starting over), etc. Attributes also effect things like tile chances, so a higher strength will get you more combat/physical tiles, or a high intelligence will get you more magic tiles.
      • Visual Elements include an auto-running sidescrolling viewport while Dungeon Running. Character auto-runs until encountering enemies, running is not controlled by player. Match-3 board will be beneath that. Time between enemy encounters can be used to clean up the board and match unneccesary tiles, make special moves to line up for next battle, or to replenish health.
        • During Battles, it'd be an over-the-shoulder battle view, similar to Pokemon style battles. Character will have health, enemy will attack character at regular intervals, player will have to balance matching combat/weapon tiles to attack enemy, and matching health/mana potion tiles to replenish health or mana(if they have potions equipped). Enemy can cause environmental effects like poison(some tiles will be poisoned so you lose health if matching them), or being frozen with ice(You need to break tiles next to the ice tiles to break them), or confusion(switches the colors of tiles). Will be block/parry mechanics, occassionally for a few seconds before the enemy strikes, you're required to match a designated tile to either block or parry that attack.
        • In a saferoom it'd be like an isometric kind of "inside a building" format like in Pokemon, just more detailed. I'd like to have saferoom customization and the ability to upgrade your character or gear too.

      Anyways, I'd love any advice or resources. Or if you'd like to help out or discuss the game idea more I'm up for that too.

      16 votes
    3. Godot beginners: Here's how to fade in a 3D mesh

      I'm still a beginner at Godot. I've been playing with Godot and 3D scenes. It's great finally feeling comfortable enough to navigate the UI from watching the tutorials from Zenva/Humble Bundle....

      I'm still a beginner at Godot. I've been playing with Godot and 3D scenes. It's great finally feeling comfortable enough to navigate the UI from watching the tutorials from Zenva/Humble Bundle.

      Recently something that sounds straightforward took a long time for me to figure out: Fading in a 3D mesh. The solution is simple:

      @onready var mesh: MeshInstance3D = find_child("body-mesh")
      
      func _ready() -> void:
      	_set_material_alpha(0)
      	SomeSingleton.some_signal.connect(_fade_in)
      
      func _set_material_alpha(alpha: float) -> void:
      	var material: Material = mesh.get_active_material(0)
      	if material is StandardMaterial3D:
      		material.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA_DEPTH_PRE_PASS
      		material.depth_draw_mode = BaseMaterial3D.DEPTH_DRAW_ALWAYS
      		material.albedo_color.a = alpha
      
      func _fade_in() -> void:
      	var tween = create_tween()
      	tween.set_ease(Tween.EASE_IN)
      	tween.tween_method(_set_material_alpha, 0.0, 1.0, fade_in_duration_seconds)
      

      The key being setting the material properties and using its albedo color to update transparency. The depth draw mode is needed, otherwise the result is ugly with jagged pixels during the tween.

      Getting to the solution was the hard part. Searching forum posts I was led down some rabbit holes like using shaders—overkill for this situation. (There is a cool site though, for when I do end up needing custom shaders: https://godotshaders.com/.) Asking an LLM also didn't help much, probably because my prompt was wrong. I tried again just now and it gave me something closer to a correct solution, but missing some parts like the depth draw mode, which (by trial-and-error and reading the docs) I found is necessary for a good quality render, when using transparency.

      Another small pitfall I found was that trying to change the material.transparency caused stutter. I was trying to disable transparency when the mesh was at 100% alpha, since I figured opaque rendering is cheaper. However I speculate the engine recompiles the shader when I turn off transparency, which causes the stutter. So I don't modify the material.transparency beyond that initial setting.

      Also thought I'd mention, I'm using free placeholder art assets from https://kenney.nl/ - an amazing resource.

      Aside: Shaders

      During this I learned that adding shaders to an imported 3D model in Godot is somewhat convoluted:

      1. Import the .glb model
      2. Clone the auto-created scene to an inherited scene, because I'm not allowed to directly edit that auto-created scene
      3. Extract the material (UV colormap image) from the .glb by double-clicking it in the FileSystem tab
      4. Apply the extracted material to the mesh under Surface Material Override
      5. Add a "Next Pass" material, a ShaderMaterial, to that surface material override
      6. Create the shader script
      7. Pass in parameter values from the GDScript to the shader script using code like: shader_material.set_shader_parameter("color", Color(1.0, 1.0, 1.0, alpha))

      This didn't work so well for me though, because the shader I was using was changing the ALBEDO and turning things white. If I knew anything about 3D programming I'd probably find a way to update the existing color value at each pixel, instead of setting albedo white everywhere. The end result of the shader I was using was that the models were turning too white. So that was a dead end.

      Anyway mainly leaving this here as reference for posterity. Feel free to share a story or constructive feedback if there's anything.

      21 votes
    4. Anyone else using the Zed editor?

      A month ago I decided to take a look at Zed. It hasn't hit 1.0 yet so I wasn't sure if I'd like it. But I haven't opened any other code editors since the first launch. It's open source and seems...

      A month ago I decided to take a look at Zed. It hasn't hit 1.0 yet so I wasn't sure if I'd like it. But I haven't opened any other code editors since the first launch. It's open source and seems to be cross-licensed with multiple free software licenses.

      Beyond the nice GUI performance from their use of native code it's clear that my use of VSCode forks for the last few years has kept me held back. There are lots of little things I love about Zed like how you can edit code within the search results page. Or how you can use your own self-hosted LLM without the outrageous shenanigans required to do so with Cursor.

      22 votes
    5. Non-engineers AI coding & corporate compliance?

      Part of my role at work is in security policy & implementation. I can't figure this out so maybe someone will have some advice. With the advent of AI coding, people who don't know how to code now...

      Part of my role at work is in security policy & implementation. I can't figure this out so maybe someone will have some advice.

      With the advent of AI coding, people who don't know how to code now start to use the AI to automate their work. This isn't new - previously they might use already other low code tools like Excel, UIPath, n8n, etc. but it still require learning the tools to use it. Now, anyone can "vibe coding" and get an output, which is fine for engineers who understand how the output should work and can design how it should be tested (edge cases, etc.)

      I had a team come up with me that they managed to automate their work, which is good, but they did it with ChatGPT and the code works as they expected, but they doesn't fully understand how the code works and of course they're deploying this "to production" which means they're setting up an environment that supposed to be for internal tools, but use real customer data fed in from the production systems.

      If you're an engineer, usually this violates a lot of policies - you should get the code peer reviewed by people who know what it does (incl. business context), the QA should test the code and think about edge cases and the best ways to test it and sign it off, the code should be developed & tested in non-production environment with fake data.

      I can't think of a way non-engineers can do this - they cannot read code (and it get worse if you need two people in the same team to review each other) and if you're outsourcing it to AI, the AI company doesn't accept liability, nor you can retrain the AI from postmortems. The only way is to include lessons learned into the prompt, and I guess at some point it will become one long holy bible everyone has to paste into the limited context window. They are not trained to work on non-production data (if you ever try, usually they'll claim that the data doesn't match production - which I think because they aren't trained to design and test for edge cases). The only way to solve this directly is asking engineers to review them, but engineers aren't cheap and they're best doing something more important.

      So far I think the best way to approach this problem is to think of it like Excel - the formulas are always safe to use - they don't send data to the internet, they don't create malware, etc. The worst think they can do is probably destroy that file or hangs your PC. And people don't know how to write VBA so they never do it. Now you have people copy pasting VBA code that they don't understand. The new AI workspace has to be done by building technical guardrails that the AI are limited to. I think it has to be done in some low-code tools that people using AI has to use (like say n8n). For example, blocks that do computation can be used, blocks that send data to the intranet/internet or run arbitrary code requires approval before use. And engineers can build safe blocks that can be used, such as sending messages to Slack that can only be used to send to corporate workspace only.

      Does your work has adjusted policies for this AI epidemic? or other ideas that you wanted to share?

      23 votes
    6. Seeking advice as a Frontend web developer

      We have this big project at work...an "all hands on deck" kinda thing that has us rank-and-file frontend devs working alongside our manager more closely than I'm used to. And it was fine, because...

      We have this big project at work...an "all hands on deck" kinda thing that has us rank-and-file frontend devs working alongside our manager more closely than I'm used to. And it was fine, because I like the guy and he's been a decent manager. But this project is killing me.

      On multiple occasions now I've written code, had it pass code review (often with his approval after a round of changes/guidance), and then every few days we get these massive re-write PRs from him where he completely rewrites large chunks of what we've done. It's leaving me feeling a few different ways:

      1. Angry because how quickly your code gets replaced is a (imo, bullshit) metric used as a part of our annual reviews and promotion discussions
      2. Doubting myself because in my head a good developer doesn't have their code rewritten that quickly.
      3. Confused because features I thought I understood are constantly being rewritten leaving me wasting time trying to relearn how things work
      4. Wondering what the point of writing code is if it's just going to be thrown in the garbage later in the week?

      And like I'll be the first to admit I'm not the most proficient developer on our team. React and Typescript are relatively new concepts to me, despite a long career in web development. But I've been writing with it for about a year now and I had thought I was finally getting a good grasp on things. But now I'm wondering if I'm just an idiot? Is it imposter syndrome or have I actually somehow coasted through a 15 year career across various stacks and it's just now catching up to me?

      Or is this just the nature of massive projects like this? We had a half-baked product scope to begin with and its getting daily changes with entire chunks of it not very well thought out by our PM. I can see how it would make sense that the more senior developer might see the need to refactor things when things are constantly changing and we're left writing code based on assumptions and half-written requirements. I'm also getting are comments on my PRs that request changes, but mid-comment he's like "I'll just take care of this because it's blocking me".

      It's just really taking a toll on my mental health and how I feel about my job. I've been trying to find another job for a few months now, but I'm not having any luck. Job hunting sucks and when you're already demoralized as hell, it's hard to sell yourself to prospective employers.

      Could really use some insight from other experienced devs, please!

      12 votes
    7. Ideas for a side project I'm working on -- an RPG to help me curb my alcohol consumption

      Preface: I am familiar with Habitica. This idea would probably scratch a similar itch, but I'm also using this as an opportunity to sharpen my Rust skills. My idea came about when I was trying to...

      Preface: I am familiar with Habitica. This idea would probably scratch a similar itch, but I'm also using this as an opportunity to sharpen my Rust skills.

      My idea came about when I was trying to find out some new tactics to curb my alcohol consumption, which isn't quite out of control yet, but I don't want to tempt fate.

      I've also really liked the progression aspect of RPGs. What if I could gamify my quest to not drink alcohol and make it sort of a fun, unique RPG experience at the same time?

      In the broadest sense, it would go something like this:

      • You open the game up, ideally each day. You are instantly prompted: "Did you drink yesterday?" (and perhaps it will go back a few more days if you skipped).
      • For each day you answer "no", you are rewarded with some sort of tokens, credits, etc. -- currency to play the game. If you answer "yes", maybe you get penalized somehow.
      • Then, you pick up your journey, which is sort of a standard RPG experience -- fighting battles, buying gear, learning spells, leveling up, advancing through the world, you name it.
      • The game should get progressively more difficult, but should not have an ending, as "quitting alcohol" does not have an ending either. At the same time, it should scratch the RPG progression itch.

      The initial game concept I came up with is just one that I see as the quickest way to get this off the ground, which would be something CLI-based, where you are presented with a menu ("visit shop, enter arena, view equipment" etc.). You spend battle tokens to enter into arena battles, which reward experience points, money, and gear. You level up, work towards a build (there needs to be a way to respec because restarting isn't really an option), and progress through the arena.

      In total, you would probably spend less than 5 minutes every day playing the game, which is by design. It should be an every day habit. But, there should be enough entertainment value that, if I'm not getting those sweet battle tokens by not drinking, I'm missing out on experiencing the game (or, I could lie, which defeats the purpose of the app).

      So that's where I'm at right now. I'm really interested to hear your thoughts, ideas, critiques, etc. before I spend a free weekend building out a concept.

      Some questions in particular:

      • I was leaning toward just building this in CLI because it will be extremely simple. It could just be a matter of STDINs. However, I'm open to other Rust-based options. Is there a good Rust UI toolkit or web framework that is worth looking into that would make this a little more modern?
      • What about game features? What could make this a really fun experience, while also balancing the whole concept of being built around your life and your habits?

      In the end, this is a deeply personal project that would be built, first and foremost, for my specific needs. But that's not to say I couldn't build it with some scalability in mind. Rather than asking about alcohol, perhaps the "habits" can be customized, and so forth.

      Anyway, have a great weekend!

      23 votes
    8. UI/UX Design for web dev

      Does anyone have any good resources, books or otherwise, in regards do good design for web dev? I'm a self taught full stack dev who just can't really make things look "pretty". They are...

      Does anyone have any good resources, books or otherwise, in regards do good design for web dev? I'm a self taught full stack dev who just can't really make things look "pretty". They are functional, but..that's about it. I know CSS, but maybe I just don't have an eye for it?

      Any suggestions would be great, thanks.

      19 votes
    9. How do you organize your Linux packages?

      Hello everyone. I am planning to get back into Linux development after working with Mac only for almost a decade. On Mac, one of the most important lessons that I learned was to always use...

      Hello everyone.

      I am planning to get back into Linux development after working with Mac only for almost a decade. On Mac, one of the most important lessons that I learned was to always use Homebrew. Using various package managers (e.g. Homebrew, NPM, Yarn, Pip, etc.) creates situations in which you don't know how to uninstall or upgrade certain pieces of software. Also, it's hard to generate a complete overview.

      How do you Linux folks handle this?

      Bonus question: How do you manage your dotfiles securely? I use Bitwarden, and it's a bit clunky.

      If that helps, I want to try Mint and always use Oh My ZSH!.

      6 votes
    10. Game development career advice

      Hi, I'm curious if anyone in this group has achieved success in game development, whether that's carving out a career or earning any amount of income from it. I'm currently working as a software...

      Hi,

      I'm curious if anyone in this group has achieved success in game development, whether that's carving out a career or earning any amount of income from it.

      I'm currently working as a software developer, but my passion lies in game development. I'm all too aware that achieving any measure of success in this field is next to impossible. Hence, I'm reaching out here, hoping to gather insights and advice from those who have walked this path in the past, or those who are currently walking alongside/behind me.

      One of my specific questions is about the types of games I should focus on creating. Specifically, I've heard differing opinions on whether it's more advantageous to develop a series of small games with advertisements for mobile platforms or to invest in larger, premium games for platforms like Steam. Can anyone share their insights or experiences regarding this dilemma? Is there a clear advantage to one approach over the other?

      Currently I am using godot to make a larger scale game, but I am considering switching to defold and making smaller scale games with ads.

      I saw some folks here discuss making games for the playdate. How much should one consider targeting niche platforms like this? Some of the users I saw discuss this seem to have had good success.

      Some general questions: How did you break into game dev? What were you doing before? Do you see game dev as a viable career, only as a source of side income, or is it just a hobby?

      Any guidance or experiences you can share would be greatly appreciated.

      17 votes
    11. Show Tildes - Gametje

      Gametje Hi all been working on this project for a while in my spare time. I wanted to share it with this community to see what you all thought. What is it? It is a set of online games (currently...

      Gametje

      Hi all been working on this project for a while in my spare time. I wanted to share it with this community to see what you all thought.

      What is it?

      It is a set of online games (currently only 2) which can be played in person with a central screen (like a TV) or remotely via video chat with screen sharing. Essentially there is a host screen and then each player has their own player screen (laptop or phone etc). It is playable in 8 languages at the moment (feel free to request any others!) It also has an integrated ChatGPT player which can be turned on/off in game settings if you prefer to play without it. There are some game mechanics to identify a ChatGPT answer which can yield some funny reactions if you choose a human's answer! It has Chromecast support and works well on Amazon Fire sticks. Visually, it is still a little rough around the edges as frontend design isn't my forte but the core concept is there. I have been play testing it with friends but have not shared it publicly yet.

      Why is it called Gametje?

      I have been living in the Netherlands for some years and my original motivation for starting this project was to create a game that supported languages other than English. I wanted to incorporate something Dutch into the name. tje is one of the diminutive endings in Dutch. It is usually meant to soften a word or make it "smaller". So Gametje -> a little game.

      Where can I try it?

      https://gametje.com/

      You can either create an account (user/pass with email confirm) or try it out as a guest (navigate to either game, then choose continue as guest). Currently it is free to host a game. Happy to hear any feedback (both good and bad). Hopefully the host provider I am using to run the game will hold up.

      Thanks!

      17 votes
    12. Just got an Nvidia 4090 GPU, looking for local LLM + general generative AI software recommendations

      I was fortunate enough to grab a discounted 4090 while on my travels and just got everything installed. Already having a lot of fun pumping all my games to max settings, but I'm also interested in...

      I was fortunate enough to grab a discounted 4090 while on my travels and just got everything installed. Already having a lot of fun pumping all my games to max settings, but I'm also interested in running generative AI stuff locally to really take advantage of all that VRAM.

      Do you have any newbie-friendly Windows 11 software to recommend for getting started? Thanks!

      20 votes
    13. Newbie here looking for advice on how to get into Programming/CS by building a project

      Been lurking for a week on tildes now and I am really glad this place exists. The crow here is exactly what I have been missing on Reddit for a while now. Having said that, the whole Reddit...

      Been lurking for a week on tildes now and I am really glad this place exists. The crow here is exactly what I have been missing on Reddit for a while now.

      Having said that, the whole Reddit situation has some-what motivated me to get the balls rolling on an idea that I have had for a while and I am looking for advice on the same.

      I have often heard this phrase "Learn programming by building" but whenever I dive in to the resources, I fall flat due to the information overload and the general abstractness that the field has (I appreciate abstractness but here it demotivates me) and I have never found a proper resource that I could follow to actually build something instead of just blindly following tutorials and playing with them.

      So, my question is how do I translate "learn by building a project" into a practical framework.

      I know of 100 days of swift and I really like that approach however I don't think I want to start with swift or build an iOS app right now.

      24 votes
    14. Making infinite scrollable lists for web without a constantly expanding DOM

      A common theme in web development, and the crux of the so-called "Web 2.0" is scrolling through dynamic lists of content. Tildes is such an example: you can scroll through about 50 topics on the...

      A common theme in web development, and the crux of the so-called "Web 2.0" is scrolling through dynamic lists of content. Tildes is such an example: you can scroll through about 50 topics on the front page before you reach a "next" button if you want to keep looking.

      There's a certain beauty in the simplicity of the next/previous page. When done right it's fast, it's easy, and fits neatly into a server-side rendered model. However, it does cause that small bit of friction where you need to hit the next button to go forward -- taking you out of the "flow", so-to-speak. It's slick, but it could be slicker. Perhaps more importantly, it's an interesting problem to solve.

      A step up from the next/previous button is to load the next page of content when you reach the end of the list, inserting it below. If the load is pretty fast, this will hardly interrupt your flow at all! The ever-so-popular reddit enhancement suite does precisely that for reddit: instead of a next button, when you reach the bottom, the next page of items simply plops into place. If the loading isn't fast enough, perhaps instead of loading when they reach the last item, you might choose to load when they hit the fifth from last item, etc.

      To try to keep this post more concrete, and more helpful, here's how this type of pagination would work in practice, in typescript and using the Intersection Observer API but otherwise framework agnostic:

      /**
       * Allows the user to scroll forever through the given list by calling the given loadMore()
       * function whenever the bottom element (by default) becomes visible. This assumes that
       * loadMore is the only thing that modifies the list, and that the list is done being modified
       * once the promise returned from loadMore resolves
       *
       * @param list The element which contains the individual items
       * @param loadMore A function which can be called to insert more items into the list. Can return
       *   a rejected promise to indicate that there are no more items to load
       * @param triggerLoadAt The index of the child in the list which triggers the load. Negative numbers
       *   are interpreted as offsets from the end of the list. 
       */
      function handlePagination(list: Element, loadMore: () => Promise<void>, triggerLoadAt: number = -1) {
          manageIntersection();
          return;
      
          function handleIntersection(ele: Element, handler: () => void): () => void {
              let active = true;
              const observer = new IntersectionObserver((entries) => {
                  if (active && entries[0].isIntersecting) {
                      handler()
                  }
              }, { root: null, threshold: 0.5 });
              observer.observe(ele);
              return () => {
                  if (active) {
                      active = false;
                      observer.disconnect();
                  }
              }
          }
      
          function manageIntersection() {
              const index = triggerLoadAt < 0 ? list.children.length + triggerLoadAt : triggerLoadAt;
              if (index < 0 || index >= list.children.length) {
                  throw new Error(`index=${index} is not valid for a list of ${list.children.length} items`);
              }
      
              const child = list.children[index];
              const removeIntersectionHandler = handleIntersection(child, () => {
                  removeIntersectionHandler();
                  loadMore().then(() => {
                      manageIntersection();
                  }).catch((e) => {});
              });
          }
      }
      

      If you're sane, this probably suffices for you. However, there is still one problem: as you scroll,
      the number of elements on the DOM get longer and longer. This means they necessarily take up
      some amount of memory, and browsers probably have to do some amount of work to keep
      track of them. Thus, in theory, if you were to scroll long enough, the page would get slower and
      slower! How long "long enough" is would depend mostly on how complicated each item is: if each one
      is a unique 20k element svg, it'll get slow pretty quickly.

      The trick to avoid this, and to get a constant overhead, is that when adding new items below, remove the same number of items above! Of course, if the user scrolls back up they'll be expecting those items to be there, but no worries, the handlePagination from before works just as well for loading items before the first item.

      However, this simple change is where a key problem arises: inserting elements below doesn't cause any layout shift, but inserting an item above ought to--right?

      The answer is: it depends on the browser! Back in 2017 chrome realized that it's often convenient to be able to insert items into the dom above the viewport, and implemented scroll anchoring, which basically ensures that if you insert an item 50px tall above the viewport, then scroll 50px down so that there's no visual layout shift. Firefox followed suite in 2019, and edge got support in 2020. But alas, safari both on mac and ios does not support scroll anchoring (though they expressed interest in it since 2017)

      Now, there's two responses to this:

      • Surely Safari support is coming soon, they've posted on that bug as recently as April! Just use simpler pagination for now
      • Pshhhh, just implement scroll anchoring ourself!

      Of course, I've gone and done #2, and it almost perfectly works. Here's the idea:

      • Right before loadMore, find the first item in the list which is inside the viewport. This is the item whose position we don't want to move. Use getBoundingClientRect to find it's top position.
      • Perform the DOM manipulation as desired
      • Use getBoundingClientRect again to find the new top of that item.
      • Insert (or remove) the appropriate amount of blank space at the top of the list to offset the change in client rect (note that if there's scroll anchoring support in the browser this should always be zero, which means this effectively works as progressive enhancement)

      Now, the function to do this is a tad too long for this post. I implemented it in React, however, and combined it with some stronger preloading object (we don't need all the items we've fetched from the API on the DOM, so we can use before, onTheDom, after lists to avoid getting a bunch of api requests just from scrolling down and up within the same small number of items).

      What's interesting is that it still works perfectly on chrome even with scroll-anchoring disabled (via overflow-anchor: none), but on Safari there is still, sometimes, 1 frame where it renders the wrong scroll position before immediately adjusting. Because I implemented it in react, however, my current hypothesis is I have a mistake somewhere which causes the javascript to yield to the renderer before all the manipulations are done, and it only shows up on Safari because of the generally higher framerates there

      If it's interesting to people, I could extract the infinite list component outside of this project: I certainly like it, and in my case I do expect people to want to quickly scroll through hundreds to thousands of items, so the lighter DOM feels worth it (though perhaps it wouldn't if I had known, when starting, how painful getting it to work on Safari would be!).

      What do you think of this type of "true" infinite scrolling for web? Good thing, neutral thing, bad thing? Would you use it, if the component were available? Would you remove it, if you saw someone doing this? Are there other questions about how this was accomplished? Is this an appropriate post for Tildes?

      11 votes