[S] Dynamically update height
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
<!-- Course list card -->
|
<!-- Course list card -->
|
||||||
<el-col :span="8" class="overall-span">
|
<el-col :span="8" class="overall-span">
|
||||||
<el-card id="course-list" class="right" style="height: 70vh" body-style="padding: 0">
|
<el-card id="course-list" class="right" ref="cl" body-style="padding: 0">
|
||||||
<div class="header padding-fix">
|
<div class="header padding-fix">
|
||||||
<div class="text">Course List</div>
|
<div class="text">Course List</div>
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Actual course list -->
|
<!-- Actual course list -->
|
||||||
<div class="list padding-fix">
|
<div class="list padding-fix" :style="{height: courseListHeight + 'px'}">
|
||||||
<!-- Every course -->
|
<!-- Every course -->
|
||||||
<div v-for="(course, index) in uniqueCourses" class="item vertical-center">
|
<div v-for="(course, index) in uniqueCourses" class="item vertical-center">
|
||||||
<span class="name">{{course.name}}</span>
|
<span class="name">{{course.name}}</span>
|
||||||
@@ -58,11 +58,16 @@
|
|||||||
directory: any[] = []
|
directory: any[] = []
|
||||||
loading = true
|
loading = true
|
||||||
|
|
||||||
|
courseListHeight: number = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before rendering
|
* Called before rendering
|
||||||
*/
|
*/
|
||||||
created()
|
created()
|
||||||
{
|
{
|
||||||
|
// Update width dynamically
|
||||||
|
window.addEventListener("resize", this.updateHeight);
|
||||||
|
|
||||||
// Get courses
|
// Get courses
|
||||||
App.http.post('/course-info', {}).then(result =>
|
App.http.post('/course-info', {}).then(result =>
|
||||||
{
|
{
|
||||||
@@ -80,6 +85,34 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called on destroy
|
||||||
|
*/
|
||||||
|
destroyed()
|
||||||
|
{
|
||||||
|
// Remove width updater
|
||||||
|
window.removeEventListener("resize", this.updateHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called on vue update
|
||||||
|
*/
|
||||||
|
updated()
|
||||||
|
{
|
||||||
|
this.updateHeight()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update header width. (CSS doesn't work)
|
||||||
|
* https://stackoverflow.com/questions/17011195/positionfixed-and-widthinherit-with-percentage-parent
|
||||||
|
*/
|
||||||
|
updateHeight()
|
||||||
|
{
|
||||||
|
if ((<any> this.$refs.cl) == null) return;
|
||||||
|
this.courseListHeight = (<Vue> this.$refs.cl).$el.clientHeight - 15 - 102;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
get filteredCourses()
|
get filteredCourses()
|
||||||
{
|
{
|
||||||
let year = GPAUtils.getSchoolYear();
|
let year = GPAUtils.getSchoolYear();
|
||||||
@@ -141,7 +174,7 @@
|
|||||||
#course-list
|
#course-list
|
||||||
{
|
{
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
|
height: 70vh;
|
||||||
|
|
||||||
.padding-fix
|
.padding-fix
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user