Jemt / Fit.UI

Fit.UI is a JavaScript based UI framework built on Object Oriented principles
http://fitui.org
GNU Lesser General Public License v3.0
19 stars 7 forks source link

Draggable: No need to update z-index on every activation - prevents scroll on iPhone #156

Open FlowIT-JIT opened 2 years ago

FlowIT-JIT commented 2 years ago

A draggable element will have its z-index increased by 1 every time the element is clicked/touched, to make sure it remains on top of other draggable elements - just like windows on a computer. However, this will quickly exhaust the reserved span of z-index values reserved for this (10.000-50.000) - the z-index value 50.000 is reserved for dialogs which must remain on top of draggable elements (alert, confirm, prompt).

Avoid incrementing z-index on every activation. It is only necessary to increment the z-index value when the previous draggable element activated is different from the current one being activated.

Avoid keeping a reference to previously activated elements - consider using a hash instead. Keeping a reference might prevent the browser from garbage collecting elements and associated event handlers which could hold large amounts of data in memory.

Jemt commented 2 years ago

Changed title to reflect a newly found problem related to updating z-index every time a draggable is touched. It prevents overflow:auto from working on iPhone (iOS 15.3.1) and on iPad (iOS 14.7.1). We use overflow:auto in Dialog to allow dialog content to be scrolled.