phuocng / html-dom

Common tasks of managing HTML DOM with vanilla JavaScript. Give me 1 ⭐if it’s useful.
https://phuoc.ng/collection/html-dom
MIT License
6.52k stars 459 forks source link

mouseDownHandler is not attached to listener #238

Open 7flash opened 2 years ago

7flash commented 2 years ago

https://github.com/1milligram/html-dom/blob/master/posts/drag-to-scroll.md

ricardo-reis-1970 commented 1 year ago

Hi @7flash.

I literally just came here looking for the same as you. You are right: the mouseDownHandler is unattached, but in the article page the demo works, right?

The answer is in this repo (or in the DevTools of the article page). If you visit the demo file in https://github.com/phuocng/html-dom/blob/master/assets/demo/drag-to-scroll/index.html, you'll find the missing bit right at the end of the <script>:

                // Attach the handler
                ele.addEventListener('mousedown', mouseDownHandler);

Yes, I agree that the article should highlight this instead of leaving it to be found by the stubborn.