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.

80 lines
2.4 KiB

  1. /**
  2. _enyo.CollapsingArranger_ is an <a href="#enyo.Arranger">enyo.Arranger</a>
  3. that displays the active control, along with some number of inactive
  4. controls to fill the available space. The active control is positioned on
  5. the left side of the container and the rest of the views are laid out to the
  6. right. The last control, if visible, will expand to fill whatever space is
  7. not taken up by the previous controls.
  8. For best results with CollapsingArranger, you should set a minimum width
  9. for each control via a CSS style, e.g., _min-width: 25%_ or
  10. _min-width: 250px_.
  11. Transitions between arrangements are handled by sliding the new control in
  12. from the right and collapsing the old control to the left.
  13. */
  14. enyo.kind({
  15. name: "enyo.CollapsingArranger",
  16. kind: "CarouselArranger",
  17. size: function() {
  18. this.clearLastSize();
  19. this.inherited(arguments);
  20. },
  21. //* @protected
  22. // clear size from last if it's not actually the last
  23. // (required for adding another control)
  24. clearLastSize: function() {
  25. for (var i=0, c$=this.container.getPanels(), c; c=c$[i]; i++) {
  26. if (c._fit && i != c$.length-1) {
  27. c.applyStyle("width", null);
  28. c._fit = null;
  29. }
  30. }
  31. },
  32. //* @public
  33. arrange: function(inC, inIndex) {
  34. var c$ = this.container.getPanels();
  35. for (var i=0, e=this.containerPadding.left, m, c; c=c$[i]; i++) {
  36. this.arrangeControl(c, {left: e});
  37. if (i >= inIndex) {
  38. e += c.width + c.marginWidth;
  39. }
  40. // FIXME: overdragging-ish
  41. if (i == c$.length - 1 && inIndex < 0) {
  42. this.arrangeControl(c, {left: e - inIndex});
  43. }
  44. }
  45. },
  46. calcArrangementDifference: function(inI0, inA0, inI1, inA1) {
  47. var i = this.container.getPanels().length-1;
  48. return Math.abs(inA1[i].left - inA0[i].left);
  49. },
  50. flowControl: function(inControl, inA) {
  51. this.inherited(arguments);
  52. if (this.container.realtimeFit) {
  53. var c$ = this.container.getPanels();
  54. var l = c$.length-1;
  55. var last = c$[l];
  56. if (inControl == last) {
  57. this.fitControl(inControl, inA.left);
  58. }
  59. }
  60. },
  61. finish: function() {
  62. this.inherited(arguments);
  63. if (!this.container.realtimeFit && this.containerBounds) {
  64. var c$ = this.container.getPanels();
  65. var a$ = this.container.arrangement;
  66. var l = c$.length-1;
  67. var c = c$[l];
  68. this.fitControl(c, a$[l].left);
  69. }
  70. },
  71. //* @protected
  72. fitControl: function(inControl, inOffset) {
  73. inControl._fit = true;
  74. inControl.applyStyle("width", (this.containerBounds.width - inOffset) + "px");
  75. inControl.resized();
  76. }
  77. });