Skip to content

Commit

Permalink
publish v3.0.4 refix a bug with roomList
Browse files Browse the repository at this point in the history
  • Loading branch information
bergwhite committed Jul 24, 2017
1 parent 209dd5c commit 385f6d9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ gulp.task('compile-css', () => {
// 打包任务
// 逐个文件ES6转ES5并压缩
gulp.task('compile-js', () => {
const JSTaskList = ['index', 'login', 'mobile', 'room', 'roomAdd', 'userInfoMod', 'roomMember']
const JSTaskList = ['index', 'login', 'mobile', 'room', 'roomAdd', 'userInfoMod', 'roomMember', 'roomList']
return JSTaskList.map((e) => {
gulp.src(`${compileDir.js.src}${e}.js`)
.pipe(babel({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodejs-chat",
"version": "3.0.3",
"version": "3.0.4",
"private": true,
"scripts": {
"build": "gulp build",
Expand Down
1 change: 1 addition & 0 deletions public/src/css/roomList.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.box-list-wrap {
font-size: @fontTitle;
overflow-y: scroll;
}
25 changes: 16 additions & 9 deletions public/src/js/roomList.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
const roomListDOM = document.getElementsByClassName('box-list-wrap')[0]
(() => {
const roomListDOM = document.getElementsByClassName('box-list-wrap')[0]
const topTitleDOM = document.getElementsByClassName('top-title')[0]

// 通过计算获取聊天框的合适高度
function changeRoomListHeight() {
const documentHeight = document.documentElement.clientHeight
const topTitleDOMHeight = topTitleDOM.offsetHeight
const roomListDOMHeight = documentHeight - topTitleDOMHeight
roomListDOM.style.height = `${roomListDOMHeight}px`
}
// 通过计算获取房间列表的合适高度
function changeRoomListHeight() {
const documentHeight = document.documentElement.clientHeight
const topTitleDOMHeight = topTitleDOM.offsetHeight
const roomListDOMHeight = documentHeight - topTitleDOMHeight
roomListDOM.style.height = `${roomListDOMHeight}px`
}

document.body.onload = () => changeRoomListHeight()
// 视窗改变时重新计算高度
window.addEventListener('resize', () => changeRoomListHeight(), false)

// 文档加载完成时重新计算高度
document.body.onload = () => changeRoomListHeight()
})()
2 changes: 1 addition & 1 deletion views/roomList.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<html>
<head>
<%- include common/head.ejs %>
<script type="text/javascript" src="/js/roomList.min.js"></script>
</head>
<body>
<div class="room-list">
<%- include common/infoTop.ejs %>
<%- include room/roomList.ejs %>
<script type="text/javascript" src="/js/roomList.min.js"></script>
</div>
</body>
</html>

0 comments on commit 385f6d9

Please sign in to comment.