Flexbox + JavaScript Image Gallery -

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 พ.ย. 2024
  • Today we build a pretty nifty image gallery using Flexbox, CSS transitions and a sprinkle of JS to get things interactive. Grab all the exercises and starter files over at JavaScript30.com

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

  • @kaivosukeltaja
    @kaivosukeltaja 6 ปีที่แล้ว +8

    Great stuff! One thing worth mentioning for viewers unfamiliar with flexbox is that `flex: 1` is a shorthand for `flex-grow: 1` which may help understand why it does what it does.

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

    To prevent the double click bug, use the code below:
    function toggleOpen(e) {
    if(e.detail < 2) this.classList.toggle("open");
    }
    detail property(event) returns an integer value that specifies the additional info about the event. The return value depends on the type of events.
    For mouse click events, the returns value is the number of clicks.

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

    This is the first... series am actually going to finish, am trying really hard not to stop halfway.

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

    This is not just web development, this is art! Thanks Wes Bos.

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

    JS using event delegation :
    // Selecting Common parent
    const panels = document.querySelector(".panels");
    panels.addEventListener("click" , function(e) {
    // Always selecting div with .panel (event when clicked on the text)
    const target = e.target.closest(".panel")
    // Adding and removing classes on clicked target
    target.classList.toggle("open")
    target.classList.toggle("open-active")
    })

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

    I watched whole flex box series in one hour.I learn a lot. Thanks!

  • @ינוןאלבז-כ1ז
    @ינוןאלבז-כ1ז 4 ปีที่แล้ว

    The best series ever made about js on the net. Takes a walk even for premium courses

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

    dood i have been studying with a private teacher for over 6 months, and all these videos are like next level compared to what we've done

  • @joelh6589
    @joelh6589 5 ปีที่แล้ว +3

    'Why don't you split it among yourself, children?' - chuckled. And thanks for the great content!

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

    Mr.Bos thank you so much for this video and the entire series.

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

    This is by far your best series. Thank you sir !

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

    Your Course Is Amazing .....Thanks alot for this

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

    I wanted to open the box on mouseover as opposed to click so it was bit tricky to get the transitionend working right for the top and bottom text. What I ended up doing was adding a transition-delay to those items instead.

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

    this is really cool, but how well does the design work? if this wasn't part of a javascript tutorial i wouldn't have known that these are clickable items on an interactive page, what would be a good way to make it obvious to a user that there's more to this than a composite image with some motivational words over it?

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

    I like the 'instant' formula of these videos but sometimes I feel a bit lost. For example, what does 'flex: 1 0 auto' means? Anyways, great series, thank you man ❤

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

      it is a shorthand property means grow shrink basis

  • @nathancornwell1455
    @nathancornwell1455 4 ปีที่แล้ว

    There is one thing that i dont quite understand about this particular project. Seems if i use any other font besides Amatic SC, when i open all the panels at the same time, all the flex items aren't sharing the space and the ones on the right get shoved off the page ....I changed font-weight,font-size, etc but it only seems to work with that one particular font .

  • @rodrigoreynaga4013
    @rodrigoreynaga4013 4 ปีที่แล้ว

    Great tutorial. Thanks !

  • @harunguven8581
    @harunguven8581 3 ปีที่แล้ว

    can we do same things with tag instead of tag?
    I tried to do same but, maybe becase of 's pre-defined properties it looked like weird.

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

    If you double click panel you can see a little bug :)

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

      I used below code to prevent the bug.
      if (e.detail < 2) {
      toggleOpen();
      }

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

      @@sunjungwoo thank you

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

    Can u make this project starting with css u already put css and html I don't understand how u this project I have done my project bt its not working plz help

    • @ImranAhmed-yp2sj
      @ImranAhmed-yp2sj 2 ปีที่แล้ว

      dear this is JavaScript project series not CSS, but still Wes Bos explain the things, which we can achieve easily, thanks

  • @Guatdefook
    @Guatdefook 5 ปีที่แล้ว

    Loving this series. I was wondering, is there a way to tie sound to the panel open on click?

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

    Well, flexbox is powerful!!!

  • @jamesbrooks9321
    @jamesbrooks9321 5 ปีที่แล้ว

    i started playing around with this and anything i do seems to cause the text that flies in to function in reverse (it starts in view and flies out when clicked) wtf

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

    What is flex: 1 0 auto? You typed it but didn't say what it means

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

    Good tutorial.i am curious what Font and theme you are using ?
    Thanks

  • @leonidpyrlya9795
    @leonidpyrlya9795 7 ปีที่แล้ว +3

    Instead of listening to each panel, why not set a listener to the parent and delegate to children? (1 listener vs 5 listeners)

    • @DavidWMiller
      @DavidWMiller 7 ปีที่แล้ว

      Probably just for simplicity and focus. Without getting into libraries, I'm not sure there is a quick way to add event delegation that wouldn't distract from the subject at hand.
      Edit: The newer Element.matches api seems like it might make this more reasonable, but even then you've got to deal with it being named differently across browsers or polyfill it, not sure if babel does anything for it.
      Sometimes, it's better to just do things in the most direct way available, 5 listeners isn't going to hurt anything.

    • @trickshotvideo1
      @trickshotvideo1 7 ปีที่แล้ว +5

      You could simply add a listener to "panels". then when panels is click, trigger a click handler function "handleClick" which takes the event as parameter. then you could simply make a check inside that function like this : if ( event.target.classList.contains('panel') ) { event.target.classList.toggle('open') }

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

      Reco Can you though? Remember that the panel has children of it's own. What will event.target be if you click on the text?
      If you can't guarantee that the panel will be the event.target, you have to traverse up the tree until you find the panel.

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

      Yeah, you are right. You could make extra checking like if event.target.nodeName === LI, but that doesn't guarantee anything if it has children with LIs. The best way would be to create a function that finds out if the event.target is a descendant of a panel but then it would just make it not worth compared to simply add listeners on each panel. Anyways, event delegation is more suited when you know from the beginning that the children elements of a parent will be added and removed from the DOM to avoid adding and removing listeners all the time, maybe like a todo list or something.

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

      Reco Right, it's all reasonably doable with a bit of consideration. But that was my point, gets a bit off-topic ;)
      Good for a different video.

  • @lotfiholmes6397
    @lotfiholmes6397 7 ปีที่แล้ว

    Thank You!

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

    It might be of 13 minites or so but am so beginner it took me 13 hours

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

      You’ll get faster as you get more practice 😀

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

      @@WesBos Thank you so much ❤️ wes for this awesome playlist ... Learnt a lot from it and started contributing in open source all thanks to you 🌸

  • @l1v1ng_d4y_by_d4y
    @l1v1ng_d4y_by_d4y 6 ปีที่แล้ว

    how would this works for visual studios putting the java script in a desperate file

    • @charlottehughes616
      @charlottehughes616 4 ปีที่แล้ว

      Link the separate javascript file by using the attribute in your html file (usually at the bottom of the body) like this:
      *The src should point to the location of the js file. If it's inside another directory it might look something like this- src="/scripts/example.js"

  • @sessonid5082
    @sessonid5082 7 ปีที่แล้ว

    Keep it 100

  • @baguette7869
    @baguette7869 4 ปีที่แล้ว

    why are'nt my words in the middle
    ?

  • @pulok9909
    @pulok9909 3 ปีที่แล้ว

    Great