GitXplorerGitXplorer
l

priority-overflow

public
1 stars
1 forks
0 issues

Commits

List of commits on branch master.
Unverified
bd6992d9a5ebcdcbe3602ef3d237cf056b0322d1

addItems to addItem

lling1726 committed 3 years ago
Unverified
f213a1f4ce4a96da2c6e7974c26cac1d3299e338

use closures instead of class

lling1726 committed 3 years ago
Unverified
40464ce563e319424d28c2a701bc631a867913ff

deregister correctly

lling1726 committed 3 years ago
Unverified
5493f4e818c11131a4ea9883ad437225f3815af5

fix selection

lling1726 committed 3 years ago
Unverified
b8d3d2db4a783c3a93212ff33d0f7e0ffba202f7

fix debouncer

lling1726 committed 3 years ago
Unverified
268c11ba735fc798ba1e9bfb16662bc42377e416

overflow menu is not just another overflow item

lling1726 committed 3 years ago

README

The README file for this repository.

Priority overflow implementation

Usage

  • npm install
  • npm start

The app will allow you to try out the different scenarios that this tool supports.

Supported use cases

DOM Order overflow

Simply hides items that no longer fit outside the right (left for rtl) boundary of the viewport.

Reverse DOM Order overflow

Can overflow from the beginning of the container instead of the end.

RTL support

Overflow will work in the same way for RTL and LTR.

Custom overflow order

Allows setting priorities to each overflow item, so that when overflow occurs, the items with the least priority are hidden first

Subscribe for updates

It's possible to subscribe to updates in item visibility which can be used to implement additional UI around overflow.

Not in scope

Overflow menus

The tool does not support managing a dropdown menu for overflow items, since requirements can vary for each invidividual use case. However it's possible to subscribe to changes in item visibility which can be used to implement additional UI around overflow.

How it works

ResizeObserver

The overflow management is done using a ResizeObserver, which watches and reports resizes of a specific container element where this priority overflow pattern needs to be implemented.

Priority queues

In order to support overflow not only for DOM order, but also for custom order, managed overflow items are stored in priority queues. This results in O(log(n)) time for displaying/hiding each item, where n is the number of items. Overflow that is only based on DOM order does not need this extra complexity.

display: none

Overflowed items are manually set with display: none. This benefits frameworks like React, which can result in extra rerenders to remove a rendered item.

Item visibility subscription

It's possible to subscribe to changes in item visibility state. This can let you manage additional pieces of UI such as rendering dividers or overflow dropdown menus.