---
title: "Discussion on \"滾來滾去的 Wheel vs Scroll event\" | Hashnode"
description: "Discussion on \"滾來滾去的 Wheel vs Scroll event\". 昨天處理一個需求是：「網頁的畫面往上滑時要隱藏頂端選單，往下滑時再顯示選單」\n聽起來好像只要偵測滾動方向是吧？好的好的！\n於是天真的小白選擇了 wheel 來實作，沒想到這就是錯誤的開始：\n  $(window).on('wheel', function(event){\n      if(event.originalEvent.deltaY < 0){\n        // up       \n      } else {\n        // down    \n      }\n    }\n  ..."
url: "https://hashnode.com/posts/wheel-vs-scroll-event/6288a478929bcf4c721d28fe"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [滾來滾去的 Wheel vs Scroll event](https://beareatapple.hashnode.dev/wheel-vs-scroll-event?utm_source=hashnode&utm_medium=feed)

昨天處理一個需求是：「網頁的畫面往上滑時要隱藏頂端選單，往下滑時再顯示選單」 聽起來好像只要偵測滾動方向是吧？好的好的！ 於是天真的小白選擇了 wheel 來實作，沒想到這就是錯誤的開始： $(window).on('wheel', function(event){ if(event.originalEvent.deltaY < 0){ // up } else { // down } } ...

May 21, 2022 · 1 min read · beareatapple.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[White Bunny](https://hashnode.com/@WhiteBunny)

@WhiteBunny · Taipei, TW

  
[View profile](https://hashnode.com/@WhiteBunny)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
