fx.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2011 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /**
  15. * @fileoverview A collection of CSS3 targeted animation, based on
  16. * {@code goog.fx.css3.Transition}.
  17. *
  18. * @author chrishenry@google.com (Chris Henry)
  19. */
  20. goog.provide('goog.fx.css3');
  21. goog.require('goog.fx.css3.Transition');
  22. /**
  23. * Creates a transition to fade the element.
  24. * @param {Element} element The element to fade.
  25. * @param {number} duration Duration in seconds.
  26. * @param {string} timing The CSS3 timing function.
  27. * @param {number} startOpacity Starting opacity.
  28. * @param {number} endOpacity Ending opacity.
  29. * @return {!goog.fx.css3.Transition} The transition object.
  30. */
  31. goog.fx.css3.fade = function(
  32. element, duration, timing, startOpacity, endOpacity) {
  33. return new goog.fx.css3.Transition(
  34. element, duration, {'opacity': startOpacity}, {'opacity': endOpacity},
  35. {property: 'opacity', duration: duration, timing: timing, delay: 0});
  36. };
  37. /**
  38. * Creates a transition to fade in the element.
  39. * @param {Element} element The element to fade in.
  40. * @param {number} duration Duration in seconds.
  41. * @return {!goog.fx.css3.Transition} The transition object.
  42. */
  43. goog.fx.css3.fadeIn = function(element, duration) {
  44. return goog.fx.css3.fade(element, duration, 'ease-out', 0, 1);
  45. };
  46. /**
  47. * Creates a transition to fade out the element.
  48. * @param {Element} element The element to fade out.
  49. * @param {number} duration Duration in seconds.
  50. * @return {!goog.fx.css3.Transition} The transition object.
  51. */
  52. goog.fx.css3.fadeOut = function(element, duration) {
  53. return goog.fx.css3.fade(element, duration, 'ease-in', 1, 0);
  54. };