The layout transition API makes it easy to animate between a node's generated layouts in response to some internal state change in a node.
Imagine you wanted to implement this sign up form and animate in the new field when tapping the next button:
// | |
// CurrencyDelegate.swift | |
// TextFieldDelegate | |
// | |
// Created by Timothy Isenman on 12/10/17. | |
// Copyright © 2017 Timothy Isenman. All rights reserved. | |
// | |
import Foundation | |
import UIKit |
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { | |
if let digit = Int(string) { | |
amount = amount * 10 + digit | |
textField.text = String(describing: currencyAmount()!) | |
} else if string == "" { | |
amount = amount / 10 | |
textField.text = String(describing: currencyAmount()!) | |
} |
//: Implementation of a redux-like pattern in swift. Its current form lacks subscriptions. | |
import UIKit | |
/*: | |
## The Message | |
A message sent to the store's reducer to perform internal state mutation. | |
This is a protocol to provide significant flexibility in the types of Messages the app layer can provide the store. The most common case is an enum type with associated values. |
The layout transition API makes it easy to animate between a node's generated layouts in response to some internal state change in a node.
Imagine you wanted to implement this sign up form and animate in the new field when tapping the next button:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ | |
[layout prepareLayout]; | |
CGSize size = [layout collectionViewContentSize]; | |
CGRect rect = CGRectMake(0, 0, size.width, size.height); | |
NSArray *layoutAttributes = [layout layoutAttributesForElementsInRect:rect]; | |
for (UICollectionViewLayoutAttributes *attributes in layoutAttributes) { | |
switch (attributes.representedElementCategory) { | |
case UICollectionElementCategoryCell: | |
NSLog(@"Cell"); | |
break; |
postfix operator ° {} | |
postfix func ° (degrees: CGFloat) -> CGFloat { | |
return degrees * CGFloat(M_PI / 180.0) | |
} | |
// Example usage | |
let view = UIView() | |
view.transform = CGAffineTransformMakeRotation(45°) |
Unofficial documentation to internal Riot Games APIs for LOL eSports.
Component = React.createClass | |
render: -> | |
`<ExampleComponent videos={this.props.videos} />` |
if (typeof Function.prototype.method !== 'function') { | |
Function.prototype.method = function(name, implementation) { | |
this.prototype[name] = implementation; | |
return this; | |
}; | |
} | |
var Person = function() { | |
this.name = name; | |
}; |
function Animal() { | |
var name = 'Lion'; | |
// privileged method | |
this.getName = function() { | |
return name; | |
}; | |
} | |
var lion = new Animal(); |