Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

A little feedback and help with a jQuery project I'm working on :)

Hi everyone!

I'm working on this pen at the moment and getting close to were I want it to be but there is a little snag.

I'm sure dragging around blocks of code isn't everyone's cup of tea and should you want to copy the code from the small pre block on the post then your out of luck.

Unless:

The dragging can be disabled. I have added a button on there to disable it and assumed a simple if statement would serve me well based on a given class but apparently not.

If you could have a look and see if I'm making an error somewhere or its a little mix up in order I'd be very grateful!

Also if you have a peak please let me know what you think of the concept in general to :)

Craig

1 Answer

Feedback:

I'm on a laptop, so I don't think the dragging really adds anything for me because side-scrolling on a touch pad is already a pretty nice user experience. It might be a nice feature on a desktop as an alternative to a scroll bar. Might it work on mobile? That would definitely be useful.

The expansion and lightbox features are really nice.

It is certainly a worthwhile project for implementation practice, and it looks good.

Your Current Snag:

I believe your problem is stemming from where you're putting your if expression.

if ( this.prev().children('.grab-and-drag').hasClass('move') ) {
  // window mouse events code omitted for brevity 
}

If I'm not mistaken, this is being evaluated when the preHeader function is first run. That means those mouse events are always being bound, because the page loads with the move class active.

It's a pretty ugly solution, but I fixed this by checking for the move class inside the mouse events. There's probably a more elegant way to do it.

Hopefully that helps. Happy coding! :)