not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.0 KiB

  1. /**
  2. A control that appears or disappears based on its _open_ property.
  3. It appears or disappears with a sliding animation whose direction is
  4. determined by the _orient_ property.
  5. */
  6. enyo.kind({
  7. name: "onyx.Drawer",
  8. published: {
  9. //* The visibility state of the drawer's associated control
  10. open: true,
  11. //* "v" for vertical animation; "h" for horizontal animation
  12. orient: "v"
  13. },
  14. style: "overflow: hidden; position: relative;",
  15. tools: [
  16. {kind: "Animator", onStep: "animatorStep", onEnd: "animatorEnd"},
  17. {name: "client", style: "position: relative;", classes: "enyo-border-box"}
  18. ],
  19. create: function() {
  20. this.inherited(arguments);
  21. this.openChanged();
  22. },
  23. initComponents: function() {
  24. this.createChrome(this.tools);
  25. this.inherited(arguments);
  26. },
  27. openChanged: function() {
  28. this.$.client.show();
  29. if (this.hasNode()) {
  30. if (this.$.animator.isAnimating()) {
  31. this.$.animator.reverse();
  32. } else {
  33. var v = this.orient == "v";
  34. var d = v ? "height" : "width";
  35. var p = v ? "top" : "left";
  36. // unfixing the height/width is needed to properly
  37. // measure the scrollHeight/Width DOM property, but
  38. // can cause a momentary flash of content on some browsers
  39. this.applyStyle(d, null);
  40. var s = this.hasNode()[v ? "scrollHeight" : "scrollWidth"];
  41. this.$.animator.play({
  42. startValue: this.open ? 0 : s,
  43. endValue: this.open ? s : 0,
  44. dimension: d,
  45. position: p
  46. });
  47. }
  48. } else {
  49. this.$.client.setShowing(this.open);
  50. }
  51. },
  52. animatorStep: function(inSender) {
  53. if (this.hasNode()) {
  54. var d = inSender.dimension;
  55. this.node.style[d] = this.domStyles[d] = inSender.value + "px";
  56. }
  57. var cn = this.$.client.hasNode();
  58. if (cn) {
  59. var p = inSender.position;
  60. var o = (this.open ? inSender.endValue : inSender.startValue);
  61. cn.style[p] = this.$.client.domStyles[p] = (inSender.value - o) + "px";
  62. }
  63. if (this.container) {
  64. this.container.resized();
  65. }
  66. },
  67. animatorEnd: function() {
  68. if (!this.open) {
  69. this.$.client.hide();
  70. }
  71. if (this.container) {
  72. this.container.resized();
  73. }
  74. }
  75. });