Learn Pointer Events In 15 Minutes

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 มิ.ย. 2024
  • Almost everyone defaults to using mouse events such as mousedown and mouseup, but this is not ideal. Mouse events do not include things like touch and pen interactions and duplicating all your mouse events into touch events is not ideal either. This is where pointer events come in. Pointer events work for all types of input (mouse, touch, pen, etc.) and best of all they include a few additional features and methods that make doing complex interactions incredibly easy.
    📚 Materials/References:
    Touch Events Video: • Learn JavaScript Touch...
    Event Listener Crash Course Video: • Learn JavaScript Event...
    🌎 Find Me Here:
    My Blog: blog.webdevsimplified.com
    My Courses: courses.webdevsimplified.com
    Patreon: / webdevsimplified
    Twitter: / devsimplified
    Discord: / discord
    GitHub: github.com/WebDevSimplified
    CodePen: codepen.io/WebDevSimplified
    ⏱️ Timestamps:
    00:00 - Introduction
    01:16 - Pointer Event Basics
    09:10 - Pointer Capturing
    #PointerEvents #WDS #JavaScript

ความคิดเห็น • 153

  • @ShellBryson
    @ShellBryson 2 ปีที่แล้ว +187

    I’ve been doing web dev for… well since the web was a thing, and before that. Yeah, I have a grey beard. Anyway, stuff like this just blows my mind: I had no idea pointer events included so much. I’m a professional FED (for decades now) screaming to keep up and this stuff is so f-ing cool. Really appreciate these videos, they’re a crutch for this ageing web engineer.

    • @labialkosta261
      @labialkosta261 2 ปีที่แล้ว +1

      can you give me some advises ??. i'm full stack web dev. hope you can share your experience with me.

    • @hikari1690
      @hikari1690 2 ปีที่แล้ว +1

      @@labialkosta261 I'd like to know what a full stack developer does too 🤣

    • @sicfxmusic
      @sicfxmusic 2 ปีที่แล้ว +1

      @@hikari1690 Are you living beneath the thick Antarctic ice sheets? But I'm surprised you got your emojis right!! 😍😍

    • @daleryanaldover6545
      @daleryanaldover6545 2 ปีที่แล้ว +3

      @@hikari1690 not sure if you are joking but for starters, fullstack dev position usually requires to deal with databases and servers (they call this Back-end) and developing UI, interfaces for users (Front-end). But most of the time fullstack devs are just being abused to do just whatever the hell the company wants em to do, which is pretty much everything. From deployment, testing, documentation, api etc. this is why fullstack dev is a one man team for small companies. In a larger project you work with fellow fullstack devs which is nice.

    • @bruhmoment3731
      @bruhmoment3731 ปีที่แล้ว +2

      You're a fed? you work for the FBI?

  • @miladk4943
    @miladk4943 ปีที่แล้ว +4

    Man plz never stop creating videos.

  • @dannyvsr
    @dannyvsr 2 ปีที่แล้ว +6

    Thanks for all that you do Kyle. I would really love a dedicated video on Git, on the more advanced commands like Rebase, Revert, Cherry Pick, how to undo a commit that has already been pushed to the repo etc. I think this would help a lot of people out. Thanks again, your are fantastic at what you do

  • @marktellez3701
    @marktellez3701 2 ปีที่แล้ว +2

    This is the most mind blowing thing I have seen in awhile and the presentation was a masterclass.
    Thanks Kyle!

  • @marsrocks247
    @marsrocks247 2 ปีที่แล้ว +2

    This is one of few channels that respects the audiences intelligence and drops relevant pro-tips

  • @pointer333
    @pointer333 ปีที่แล้ว +2

    You just earned a subscription, sir! The presentation is so dang concise and logical!

  • @AliMoeeny
    @AliMoeeny 2 ปีที่แล้ว +3

    Amazing, thank you very much. Pointer capturing is clutch when you need it and if you don't know it exists, you are going to spend a lot of time debugging your own implementation. Thanks again for the excellent video, as always.

  • @bobdinitto
    @bobdinitto 2 ปีที่แล้ว

    Wow this is awesomely powerful stuff. Although my current project has a very simple UI that wouldn't need this I've often wondered how to integrate mouse and touch input in HTML and these pointer events are prefect! Thanks for the insight, Kyle, and as usual your very succinct delivery!

  • @aram5642
    @aram5642 2 ปีที่แล้ว +33

    Should you ever run out of ideas for next video, I would love to see a summary of all the event coordinate properties ending with X and Y: pageX/Y, offsetX/Y, clientX/Y, layerX/Y, etc. I am sure your rundown will be the best possible.

  • @CondeAlberto
    @CondeAlberto ปีที่แล้ว

    Kyle, I have been watching your videos for weeks now, and I still have to see one that is not extremely well researched, entertaining and useful.
    it is no wonder you are so succesful. Congratulations on an excellent job.

  • @jugibur2117
    @jugibur2117 2 ปีที่แล้ว +1

    Great stuff, as always. Learned a lot, thanks Kyle!

  • @marksheard1210
    @marksheard1210 ปีที่แล้ว +1

    Ok that`s it, on my next project i am going to have to just test pointer events out on Both my Mouse AND my Touchscreen. Nicely done Sire! 👍

  • @schizoidman9459
    @schizoidman9459 2 ปีที่แล้ว +3

    Hi Kyle! I am impressed with the contents of your videos for quite some time. I have a PhD in Computer Science and I only use web programming for my Github website. I am really glad to see that there are young fellows here on TH-cam such as yourself that are so competent, clear, and spot on. This video is a jewel and I want to congratulate you for its content. I was an university professor and I loved to explain things in a way to make people understand it. I know you must have spent hours and hours to prepare this video, but the result is amazing. It is quite a bit "dense", but this is not a complaint, it's good this way. I am subscribing to your channel right now and keeping this video for future use. I have already exchanged the mouse events by pointer events in my site but unfortunately my Canvas demos with user interaction are not working on mobiles for some reason. If you have some ideas what could be the problem please let me know. Cheers!

  • @juanmurga1571
    @juanmurga1571 2 หลายเดือนก่อน

    Thank you man! I love when you talk about topics that is find to hard good examples

  • @micheledibe
    @micheledibe ปีที่แล้ว

    I had yet to learn of the existence of these new events.
    Thanks for sharing and for keeping up these good tutorials.

  • @jma42
    @jma42 2 ปีที่แล้ว +1

    man just perfect timing for this upload, my friend was asking me to implement a custom video player

  • @me_manish_prajapati
    @me_manish_prajapati 2 ปีที่แล้ว +3

    Even experienced developers should watch all of ur videos ❤️❤️ great content nd concepts

  • @carltone
    @carltone ปีที่แล้ว +1

    Kyle, Thank-you for creating this video. I’m a microcontroller hobbyist. I have recently learned JS and (HTML ,CSS as required). Intent being to use phone, tablet or computer to connect to the microcontroller. The Pointer method looks like what I need. Furthermore, I watched your o event video. The Usb connection / debugging interface ( assuming I can connect) will enable me to cleanup optimize my tablet interface . Many thanks for your effort creating these Excellent ‘concise ‘ technical videos . Well done !!

  • @yusufmustahan8711
    @yusufmustahan8711 2 ปีที่แล้ว +1

    You've always got the best update man 😊

  • @somehappyguy6598
    @somehappyguy6598 2 ปีที่แล้ว

    Thanks man for the great contente you create. I am a fullstack engineer and still come to learn a lot from your videos :)

  • @markcaz
    @markcaz 2 ปีที่แล้ว

    Thanks for video, I was always confused on mouse vs. pointer events, this helps. Only problem is your move & up handlers are nested in your down handler, leaving stray closures / event handlers.

  • @marinvhs
    @marinvhs ปีที่แล้ว

    Excellent video + explanations.

  • @vladropotica5687
    @vladropotica5687 6 หลายเดือนก่อน

    Thank you. This video came up perfectly for me, didn't know what to do with my draggable slider.

  • @_the_one_1
    @_the_one_1 2 ปีที่แล้ว

    WOW! That's amazing video, I learned something today! THANK YOU

  • @raymondyoo5461
    @raymondyoo5461 2 ปีที่แล้ว

    Wow another miraculous video. Thanks 👍👍

  • @the13den
    @the13den ปีที่แล้ว

    Amazing and useful video, thank you bro

  • @raymondbyczko
    @raymondbyczko ปีที่แล้ว

    Great content, as usual!

  • @parahumanoid
    @parahumanoid 2 ปีที่แล้ว +1

    I find myself dashing back and forth between Kyle and a couple other content providers: some simpler stuff in depth with others, and more hardcore with Kyle. Basically so because Kyle relies on my being well up to speed with simpler things an we frequently don't know those things as thoroughly as it may seem to us. Some are easier-paced also, or narrowly targetted. Like Kevin Powell: I know Kyle can do as well in CSS, but to my taste, Kevin does more to transfer exactly the CSS part of the game to us in an easier to understand way. But then again when I know I need to go hardcore with pure ES or ME*N and WebAssembly and similar scary things, I come to Kyle. Great thanks for great content!

  • @simeydotme
    @simeydotme 2 ปีที่แล้ว

    really well done!
    I'm off to re-write all the interaction events on my range-slider component, now. haha.

  • @DeepakisDemigod
    @DeepakisDemigod ปีที่แล้ว

    Pointer solves issue for every touch or mouse event thanks brother ♥️♥️♥️👍👍👍

  • @waleedmumtaz
    @waleedmumtaz ปีที่แล้ว

    Awesome! Learned a lot!

  • @robinparadise
    @robinparadise 2 ปีที่แล้ว

    Holly molly, setPointerCapture, this would have saved me many hours of work. Great Tip!👍

  • @niomeda
    @niomeda 2 ปีที่แล้ว

    Very informiative video. Thanks for sharing

  • @ShiloBuff
    @ShiloBuff 2 ปีที่แล้ว +8

    In one of the React JS apps I am working on, pointer events didn't get executed as expected for a textarea on Android. (Technically I was using MUI TextField.) I don't exactly remember the issue. But I ended up having to use touch events instead. And then decided just to use mouse events for PC devices. I expected pointer events to work in this case and curious why it didn't.
    (For more detail: I was trying to capture the touch down state for document selection change. On that note, I also was unable to get onselectionchange to work for textarea.)
    Maybe I will revisit this to see if there was conflicts with native touch events.

  • @vintprox
    @vintprox 2 ปีที่แล้ว +1

    I didn't even know these exist. Thanks!

  • @VaibhavShewale
    @VaibhavShewale 2 ปีที่แล้ว +1

    the thing i didn't knew existed, it is just awesome. Hope so i can be able to use it somewhere

  • @anandphani7100
    @anandphani7100 2 ปีที่แล้ว

    Thanks for your videos, it is very helpful.

  • @kuoyulu6714
    @kuoyulu6714 2 หลายเดือนก่อน

    this is so fast and amazing!

  • @AeroSW
    @AeroSW 2 ปีที่แล้ว

    A new trick learnt by this full stack engineer. Thank you for the video.

  • @kevinoo1991
    @kevinoo1991 2 ปีที่แล้ว

    Very interesting! Thanks!

  • @maxwarren4277
    @maxwarren4277 ปีที่แล้ว +1

    Can you please make more videos on pointer events!? Just an overall tutorial would be great. Where you use it in a project or something like that.

  • @tommysmith5479
    @tommysmith5479 2 ปีที่แล้ว

    Great video, dude.

  • @parvezmusharafswe
    @parvezmusharafswe 2 ปีที่แล้ว

    Your short videos are very effective

  • @flibben
    @flibben 2 ปีที่แล้ว

    Very cool, great video :)

  • @bok7660
    @bok7660 2 ปีที่แล้ว

    Would love to see canvas next!

  • @yajirushik2871
    @yajirushik2871 ปีที่แล้ว

    Month ago I have found bug in my app, after search found pointer events. Now I'm using only pointer / key events in my apps. Googled 'double pointer down event' and found Your video, thank You!. Why very time when I'm searching any tutorial google shows You, Kevin Powell or DevEd :D.

  • @IBITZEE
    @IBITZEE 2 ปีที่แล้ว

    dude... you rule on this... thanks!

  • @dragonkora670
    @dragonkora670 2 ปีที่แล้ว

    You are the saver man🔥

  • @ARS-fi5dp
    @ARS-fi5dp 2 ปีที่แล้ว

    Thank you man 🙏

  • @aidanzipzap
    @aidanzipzap 2 ปีที่แล้ว

    thanks man, useful.

  • @AlexDBaxter
    @AlexDBaxter 2 ปีที่แล้ว +1

    Nice vid about events that I knew nothing about! Having mouse events, touch events, and now pointer events is a bit of a pain really. Quick note on your positioning code: it only works if the timeline element is at 100% of the page width; you need to offset it by the timeline rectangle X to get the correct timeline handle-position in this case. I would also clamp it to 0-100% range:
    function clamp(n, min, max) {
    return (n < min) ? min : (n > max) ? max : n;
    }
    function setTimelinePosition(e) {
    const rect = timeline.getBoundingClientRect();
    const pos = clamp(((e.clientX - rect.x) / rect.width) * 100, 0, 100);
    timeline.style.setProperty('--handle-position', `${pos}%`);
    }
    - this should work regardless of the x-position of the timeline div.

    • @pointer333
      @pointer333 ปีที่แล้ว

      lordie thank you!

  • @shahfaisal3923
    @shahfaisal3923 2 ปีที่แล้ว

    Thank you so much for wathcing and have a good DEV. 😁

  • @jaidhingra2811
    @jaidhingra2811 11 หลายเดือนก่อน

    I am creating a video editing application and I have a major problem which you have fixed with setPointerCapture().
    Thank you so much for that.

  • @justdoeverything8883
    @justdoeverything8883 2 ปีที่แล้ว

    This is so helpful! WOW! Would be nice if you shared how you set up your dev server, someone said it's vscode live server?

  • @MrKeysk
    @MrKeysk 2 ปีที่แล้ว

    Hey, nice video and thanks for your help, I'm currently in a training to become front-end dev and I've learned so much thanks to your videos ! I really appreciate the time & effort !
    I have a question though : why don't you use semi colons at the end of every line in your JavaScript ? Is it optional ?

    • @jamiusamin877
      @jamiusamin877 2 ปีที่แล้ว

      yes it's optional

    • @Laura69
      @Laura69 2 ปีที่แล้ว

      It is called "automatic semicolon insertion".

  • @GameplaySheep
    @GameplaySheep 2 ปีที่แล้ว

    Hello! Cool video!
    A little thing made me wonder...
    The auto complete suggested both append() and appendChild() on the document. What really is the difference between the two? Appending something wouldn't make it its child?

  • @gtagtagtagtag
    @gtagtagtagtag 2 ปีที่แล้ว

    Really appreciated

  • @diegognoatto8706
    @diegognoatto8706 ปีที่แล้ว

    boom cool stuff, since the release of gsap observer plugin im in heaven dealing with all this weard implementations, would be cool to see some content on it, theres no much avaliable yet cause its new

  • @jmann2885
    @jmann2885 2 ปีที่แล้ว +6

    Create a new web developer guide 2022 with all the new things that u posted this year ….like the one u created in 2021 plzzz😇 god bless u mate for all the hard work u do for the people

  • @YtResolver
    @YtResolver 18 วันที่ผ่านมา +1

    Hi kyle can you make a tutorial about the youtube play video window how it minimizes when you push it down or press the back key and when you have a 2nd thought of watching the content still you just drag it up again. 😅

  • @infienite9215
    @infienite9215 2 ปีที่แล้ว

    I accidentally read the title as "Pointers In 15 Minutes". Pretty much thought this was a C++ video

  • @daleryanaldover6545
    @daleryanaldover6545 2 ปีที่แล้ว

    Kyle never let us down with his content. JavaScript is such a huge mess (basically because of how huge it is) and it is easy to overlook useful api methods that are already built-in such as pointer capture.

  • @GuRuGeorge03
    @GuRuGeorge03 2 ปีที่แล้ว

    oh this is great, i didnt know pointer events existed lol

  • @massiresogore7906
    @massiresogore7906 2 ปีที่แล้ว

    Best Video i love it 🥰🥰🥰🥰🥰🥰🥰

  • @victorgenaro4388
    @victorgenaro4388 ปีที่แล้ว

    magestic!

  • @tanaymishra3375
    @tanaymishra3375 2 ปีที่แล้ว

    Well time to Update Website code.. Thanks.😀

  • @dasdunetechnologies1695
    @dasdunetechnologies1695 2 ปีที่แล้ว +2

    Nice! How do you put your JS code to the phone and run it ? Maybe simply host the code in a HTML file and download it to your phone. ?

    • @petrlaskevic1948
      @petrlaskevic1948 2 ปีที่แล้ว

      Hello, it's simply Chrome USB debugging, you just have the page opened on your Android phone, and the debugging enabled.

  • @frontend_ko
    @frontend_ko 10 หลายเดือนก่อน

    hi thanks for nice video. i have a question... in touch device, during mousemove event, mouseleave/out events doesn't get fired even if the position of touch has left the currentTarget of mouseleave/out. how can i detect it?

  • @jaya_surya
    @jaya_surya 2 ปีที่แล้ว

    Thanks!

  • @yigitruzgaruzun7289
    @yigitruzgaruzun7289 2 ปีที่แล้ว

    Thanks

  • @gamevillage9584
    @gamevillage9584 2 ปีที่แล้ว +1

    Pointer events are gr8, that's my first impression when i first used them in one of my reactjs projects, i replaced the entire browser scrolling with my own, it's pretty fast too, can handle nested scrolling horizontal/vertical, keyboard show/hide, custom scrollbar, infinity scrolling, scroll end animation, free scrolling, snap scroll, and so on, Pretty awesome stuff but css [touch-event: none], fail to apply to nested child elements, So i handled it a react way.
    Pointer events are for controlled environment, my scroll emulation let the user do all kinds of sh!t, so i dropped it.

    • @michastruck2584
      @michastruck2584 2 ปีที่แล้ว

      touch-event: none is probably just not inherited by grandchildren and so on. Maybe a global rule like * {touch-event: none;}?

  • @bloodaid
    @bloodaid 2 ปีที่แล้ว

    I trust this guy with my life

  • @soniablanche5672
    @soniablanche5672 2 ปีที่แล้ว

    does "click" event work on all mobile/tablets? I read somewhere it's binded to the touch event, but some other sources say it's not reliable. My own phone works with the click event but I can't generalize from that.

    • @lionhunter4513
      @lionhunter4513 2 ปีที่แล้ว

      I think the Click Event should be Fine also for mobile devices Touch Input

  • @mainendra
    @mainendra 2 ปีที่แล้ว

    Best one is `setPointerCapture` 👍

  • @stoncjoesperanto8632
    @stoncjoesperanto8632 2 ปีที่แล้ว +1

    Please increase code text size, to make it readable on smartphones. Thanks

  • @simonwillover4175
    @simonwillover4175 2 ปีที่แล้ว

    Hey WDS, why dont you ever use onpointerdown? Its perfectly valid, just like addEventListener(pointerDown, ...)
    I think your answer is "because onpointerdown only allows for one pointer event to be set, and can easily be overwritten by other scripts; addEventListener allows the most compatibility with other scripts, such as liraries, and apis. Plus addEventListener keeps our event listener private, so we can easily control which scripts are given certain pieces of data from the user."

  • @meganweber5057
    @meganweber5057 ปีที่แล้ว +1

    Does touch-action: none in css do the same thing as preventDefault in a touchstart listener?

    • @pointer333
      @pointer333 ปีที่แล้ว

      Would also love an answer to this! It doesn't seem like it, but I'm debugging in safari ios, and i'm new to web languages, so i can't tell for sure.

  • @singh.aadarsh
    @singh.aadarsh 2 ปีที่แล้ว

    Amazing....

  • @mohamadcheaib
    @mohamadcheaib 10 หลายเดือนก่อน

    why we cannot add touch-action: none via javscript, i was trying but it didnt work!, so add remove the touch action bsed on a specefic scenario, because disabling touch action for good will prevent the application to scroll to other sections

  • @Unisaur64
    @Unisaur64 ปีที่แล้ว

    Can anyone explain why changing "e.target" to "timeline" @11:45 resolves the glitchiness? Or why it's a bug at all?

  • @anvarichn
    @anvarichn ปีที่แล้ว

    Is it possible to see markup and css for these, please? git or codepen?

  • @7heMech
    @7heMech 2 ปีที่แล้ว +1

    cool *thumbup*

  • @stefanlodders9521
    @stefanlodders9521 ปีที่แล้ว

    Would be the substitute for "onclick" "onpointerdown"? Or does this lead into issues?

    • @rossclutterbuck1060
      @rossclutterbuck1060 ปีที่แล้ว

      it's still a click event, so addEventListener("click", cb) as usual.
      And use event listeners, never do onclick or whatever

  • @socalledsound
    @socalledsound ปีที่แล้ว

    am I the only one who is having issues with pointerup? it works as long as it's the first event (pointerdown commented out) but if pointerdown exists it doesn't seem to fire. any advice appreciated!

  • @sheriffderek
    @sheriffderek 2 ปีที่แล้ว

    I noticed this on MPN: "Note: Pointer events are not available in Web Workers."

  • @Latcci
    @Latcci 2 ปีที่แล้ว +2

    soon we will get thumbnails like : "Stop using Javascript"

  • @MuhammadAhmedAshraf
    @MuhammadAhmedAshraf 2 ปีที่แล้ว +3

    Can you make the paper ripple animation like the youtube has on retry button or other google products ???

  • @fkangalov
    @fkangalov 2 ปีที่แล้ว +1

    Hello, how are you doing the interactive mobile to browser emulator ? How do I do that? Thanks.

    • @leepowelldev
      @leepowelldev 2 ปีที่แล้ว

      Also interested in how

    • @pointer333
      @pointer333 ปีที่แล้ว

      He tells you in the beginning of the video that his last video on touch events covers that.

  • @akshaygadekar9926
    @akshaygadekar9926 2 ปีที่แล้ว

    Does touch event has pen support too?

  • @romy4romy4
    @romy4romy4 ปีที่แล้ว

    Before using something check caniuse as the most first step

  • @kuruvi5662
    @kuruvi5662 2 ปีที่แล้ว

    Along with mouse events and point events I want some knowledge on Chris Evans too 😂

  • @DasBauer
    @DasBauer 2 ปีที่แล้ว

    Still I am waiting for WCAG 2.1 compliance. Please include/cover that topic

  • @web_hub
    @web_hub 2 ปีที่แล้ว

    What do you mean by no stack to full stack ?

    • @m1m2m3
      @m1m2m3 2 ปีที่แล้ว

      zero to hero

    • @TheTiffanyAching
      @TheTiffanyAching 2 ปีที่แล้ว

      Stack and pointer. Not what they used to be.

  • @augischadiegils.5109
    @augischadiegils.5109 2 ปีที่แล้ว

    ❤️❤️❤️

  • @ygormartinsr
    @ygormartinsr 2 ปีที่แล้ว

    Lesgoo

  • @insaanonline
    @insaanonline ปีที่แล้ว

    nice 📷

  • @sainathkamble387
    @sainathkamble387 2 ปีที่แล้ว

    Sir make a video on microservices

  • @skyray3335
    @skyray3335 2 ปีที่แล้ว

    I'm from India ...I wanna buy yr react course... But 60 dollars is just too much for me ... And i can't use coupons ... What should I do

  • @kuroexmachina
    @kuroexmachina 2 ปีที่แล้ว

    sheeeeeeesh

  • @TheBlackmanIsGod
    @TheBlackmanIsGod 7 หลายเดือนก่อน

    How do you hold all of this stuff in your mind?!?!?!? INSANE!!!im so jealous and feel so rage about it…..Do you take Adderall or something???