Skip to content

Instantly share code, notes, and snippets.

@nickbutcher
Created July 24, 2019 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickbutcher/68bf9dbcd76b2754ecf91b73117cfd06 to your computer and use it in GitHub Desktop.
Save nickbutcher/68bf9dbcd76b2754ecf91b73117cfd06 to your computer and use it in GitHub Desktop.
/* Copyright 2019 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
fun View.spring(
property: ViewProperty
): SpringAnimation {
val key = getKey(property)
var springAnim = getTag(key) as? SpringAnimation?
if (springAnim == null) {
springAnim = SpringAnimation(this, property)
setTag(key, springAnim)
}
return springAnim
}
@dfeverx
Copy link

dfeverx commented Sep 21, 2019

Is this ViewProperty from DynamicAnimation.ViewProperty?

@nickbutcher
Copy link
Author

@dfeverx yes.

@dfeverx
Copy link

dfeverx commented Sep 21, 2019

when I try this code in ide ,i get an error at "get Key(property)"

@dfeverx
Copy link

dfeverx commented Sep 21, 2019

Unresolved reference: getKey

@nickbutcher
Copy link
Author

Yeah these are minimal snippets for a blog post. See this PR for a more complete implementation: nickbutcher/plaid#751

@dfeverx
Copy link

dfeverx commented Sep 21, 2019

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment