question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

adding and removing elements

See original GitHub issue

What is the best way to add/remove elements dynamically? Consider a program like GNU Screen, where you want to dynamically add and remove sub-windows.

Is there any way to add a new element, except by calling destroy and then creating a new Split object? It would seem this could cause minor flicker or jumps.

I can see at least 3 useful add “modes” for adding an element at position i:

  1. Initialize the sizes to all elements have the same size. That cause non-neighbor elements to “jump” so you probably wouldn’t want that.
  2. Split the “current” (either i or i-1) element into 2 equal halves.
  3. Split the neighboring elements i-1 and i into thirds.

To delete an element there is collapse, but that doesn’t seem to be what we’re looping for.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
PerBothnercommented, Apr 12, 2017

My ideal would be a general package for managing panes, that would support:

  1. Create or remove panes using functions (which might be bound to keyboard events). This could use Split.js.
  2. Re-arrange panes around by dragging. (The dragabilly package could be used.) (Bonus points if a pane can be dragged from one top-level window to another, but that has extra challenges.)
  3. Optional tabs, and being able to re-order tabs or convert them to/from panes. (The chrome-tabs package makes use of dragabilly.) An advantage of supporting tabs is that tabs provide a natural “handle” for dragging panes.

Toolkits that I’ve used that support all of these include the Atom editor and the NetBeans IDE. It would be great to be able to do it with portable JavaScript.

I’ve been thinking about how to add these features to DomTerm, though for now I’m seeing whether I can get Atom to do what I want. That has its own challenges.

0reactions
lezhnev74commented, Jun 29, 2017

I like the simplicity of this library, I believe it has big potential. Do you plan to extend API with mentioned add()/remove() commands or similar? My +1 for this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

adding and deleting elements - WebPlatform.org
Adding and Deleting Elements ; createElement(), Used to create an element ; removeChild(), Remove the selected element or child node. ; appendChild(), Add...
Read more >
How to add or delete HTML Elements through JavaScript
To add an HTML element in your JavaScript program, you can use the appendChild() and insertBefore() method, whereas, for deleting any specific HTML...
Read more >
Adding and Removing HTML Elements
In the last course section we learned two ways to add and remove content from our webpages: Use inline styles to show and...
Read more >
How to add and remove elements from DOM in JavaScript?
Removing an element is fairly easy, we can use the removeChild() method available in the div tag and pass the reference of our...
Read more >
Element.remove() - Web APIs - MDN Web Docs
The Element.remove() method removes the element from the DOM. Syntax. remove()
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found