简体   繁体   English

角-单击flexbox网格单元以全宽扩展下方区域

[英]angular - click flexbox grid cell to expand area below with full width

I have something like calendar grid using flexbox inside a ionic 3 project. 我在ionic 3项目中使用flexbox的日历网格之类的东西。

标准检视

The cells are one array 细胞是一个阵列

<div class="sb-calendar-wrapper">
    <div class="sb-calendar-month">
        <div class="sb-calendar-row">
            <div class="sb-calendar-cell sb-cell-labels sb-week-day" *ngFor="let day of sbcalendar.dayLabels">
                {{day}}
            </div>
        </div>
        <div class="sb-calendar-row">
            <div class="sb-calendar-cell sb-cell" *ngFor="let day of calendarDays, let j=index" (click)="openCalendarDay(day)" [ngStyle]="{'height': (day.isOpen) ? '300px' : '60px'}">{{j}}
            </div>
        </div>
    </div>
</div>

.sb-cell {
    position: relative;
    border-bottom: 1px solid rgba(130, 171, 183, 0.2);
    padding: 5px;
    height: calc((100vh - 150px)/6);
    .sb-calendar-day-list{
        position: absolute;
        width: 100vw;
        left: 0;
        top:calc((100vh - 150px)/6);
        background: #ccc;
        height: calc( 300px - calc((100vh - 150px)/6));
    }
}

When I click on any day, i want the "row" to expand to display an area which I can use for eg displaying items of that cell. 当我单击任意一天时,我希望“行”展开以显示一个区域,该区域可用于例如显示该单元格的项目。

展开视图

The problem I'm facing is how to position that list element, so that i will fill the entire space or width. 我面临的问题是如何定位该列表元素,以便我将填充整个空间或宽度。 With position:relative of the cell I can position everything fine except for the left:0, which doesnt work for most cells. 使用position:relative相对于单元格,我可以将所有位置正确,除了left:0,这对大多数单元格都无效。

In summary when i click any day, a box that fills the entire view width should expand. 总之,当我单击任意一天时,将填充一个填充整个视图宽度的框。 thanks for any suggestions! 感谢您的任何建议!

EDIT1 EDIT1

I don't want to create manual rows after each n-cell. 我不想在每个n单元之后创建手动行。 The cell array should stay as a single array while the flexitem widths controls how many items are in each row. 单元格数组应保持为单个数组,而弹性项目宽度控制每行中有多少个项目。

在此处输入图片说明

I think you can organize those days on the same line as a row. 我认为您可以连续安排那些日子。 At the end of each row, you can add a place holder div with an ng-if condition. 在每行的末尾,您可以添加带有ng-if条件的占位符div。 Whenever you click on a day of that row, you can check the row index for showing the div or not. 每当您单击该行的某一天时,都可以检查行索引是否显示div。 That div will hold an area that you want. 该div将保留您想要的区域。

html: HTML:

<div class="flexbox-row" ng-repeat="row in rows track by $index">
  <div class="flexbox-col clickable" ng-click="showRow($index)">
    1
  </div>
  <div class="flexbox-col clickable" ng-click="showRow($index)">
    2
  </div>
  <div class="flexbox-col clickable" ng-click="showRow($index)">
    3...
  </div>
  <!-- Place holder div -->
  <div ng-if="showRow() === $index">
    <div data-custom-directive></div>
  </div>
</div>

Show row code: 显示行代码:

scope.showRow = function ($index) {
  // Return activeRow
  if ($index === undefined) {
    return scope.activeRow;
  }
  // Hide if same row
  if ($index === scope.activeFlight) {
    scope.activeRow = null;
    return;
  }
  // Show row
  scope.activeRow = parseInt($index);
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM