Skip to content

Commit

Permalink
allow scroll comment content on wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
haojiezhe12345 committed Jun 22, 2024
1 parent 4093728 commit cc05fc1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
<img class="avatar" src="https://haojiezhe12345.top:82/madohomu/api/data/images/avatars/浩劫者12345.jpg" onerror="this.onerror=null;this.src='https://haojiezhe12345.top:82/madohomu/api/data/images/defaultAvatar.png'">
<div class="sender"><span class="ui zh">浩劫者12345 (站长)</span><span class="ui en">haojiezhe12345</span></div>
<div class="id"><span class="ui zh">#置顶</span><span class="ui en">#Pinned</span></div>
<div class="comment" onwheel="if (!isFullscreen) event.preventDefault()">
<div class="comment">
<div class="ui zh">
欢迎来到 <strong style="text-decoration: underline;">MadoHomu.love</strong> !<br>
这是一个以<strong><span style="color: #ffbbdd;"></span><span style="color: #d5a2ff;"></span><span style="color: #ffbbdd;"></span></strong>为主题的留言网站<br>
Expand Down
14 changes: 10 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ function insertComment(comment, isKami = false) {
${comment.sender == '匿名用户' ? '<span class="ui zh">匿名用户</span><span class="ui en">Anonymous</span>' : comment.sender}
</div>
<div class="id">#${comment.id}${isKami == true ? ' (kami.im)' : ''}</div>
<div class="comment" onwheel="if (!isFullscreen) event.preventDefault()">
<div class="comment">
${htmlEscape(comment.comment)}
${imgsDOM}
</div>
Expand Down Expand Up @@ -1764,9 +1764,15 @@ const Comments = {
loadComments()

this.elements.container.onwheel = e => {
if (isFullscreen) {

} else {
if (!isFullscreen) {
let target = e.target
while (this.elements.container.contains(target)) {
if (target.classList.contains('comment')) {
// console.log(target.scrollHeight, target.clientHeight)
if (target.scrollHeight > target.clientHeight) return
}
target = target.parentNode
}
e.deltaY > 0 ? this.seek(1) : this.seek(-1)
}
}
Expand Down

0 comments on commit cc05fc1

Please sign in to comment.