| import UIKit | |
| extension UIStackView { | |
| func removeAllArrangedSubviews() { | |
| let removedSubviews = arrangedSubviews.reduce([]) { (allSubviews, subview) -> [UIView] in | |
| self.removeArrangedSubview(subview) | |
| return allSubviews + [subview] | |
| } |
Mobile Safari does not support position: fixed when an input focused and virtual keyboard displayed.
To force it work the same way as Mobile Chrome, you have to use position: absolute, height: 100% for the whole page or a container for your pseudo-fixed elements, intercept scroll, touchend, focus, and blur events.
The trick is to put the tapped input control to the bottom of screen before it activates focus. In that case iOS Safari always scrolls viewport predictably and window.innerHeight becomes exactly visible height.
Open https://avesus.github.io/docs/ios-keep-fixed-on-input-focus.html in Mobile Safari to see how it works.
Please avoid forms where you have several focusable elements because more tricks to fix position will be necessary, those were added just for demonstration purposes.
| // Optional declares a type of keyed type T where all keys are optional. | |
| // This allows | |
| type Optional<T> = { [P in keyof T]? :T[P] } | |
| interface Foo { | |
| x :number | |
| y :number | |
| } | |
| type OptionalFoo = Optional<Foo> |
Short (72 chars or less) summary
More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).
Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
| import UIKit | |
| class ChatCollectionViewFlowLayout: UICollectionViewFlowLayout { | |
| private var topMostVisibleItem = Int.max | |
| private var bottomMostVisibleItem = -Int.max | |
| private var offset: CGFloat = 0.0 | |
| private var visibleAttributes: [UICollectionViewLayoutAttributes]? |
https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff
While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.
JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu
| import { Provider } from 'mobx-react/native'; | |
| const SPECIAL_REACT_KEYS = { children: true, key: true, ref: true }; | |
| export default class MobxRnnProvider extends Provider { | |
| props: { | |
| store: Object | |
| }; | |
| context: { |