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

Christopher Paccione
Christopher Paccione
14,831 Points

Pause Vimeo video on scrolll

Hello Everyone,

I've been building this site for the past month.

http://staging.mysteamist.com/

It's set to go live on March 2nd, and I would like to pause the embedded Vimeo video which is set to autoplay on the home page when you scroll away from it, and then un-pause it when you scroll back to it.

I'm using fullpage.js on the home page.

I'm definitely not a JavaScript ninja, but if I could be pointed in the right direction, it would be much appreciated.

Thanks!

4 Answers

Dave McFarland
STAFF
Dave McFarland
Treehouse Teacher

Hi Christopher Paccione

Check out the latest episode of the Treehouse Show. Nick Pettit and Jason Seifer discuss a JS library called vissense. It can let you run code when a page element starts to leave the screen. So, for example, as a user scrolls your page and the video begins to exit the viewport, you can stop the video. Hope that helps.

Christopher Paccione
Christopher Paccione
14,831 Points

Thanks Dave I'll check it out, and I appreciate the help. I just ran into a completely separate issue, which probably needs it's own thread, and that's scrolling over an iframe on IOS. I'm using fullpage.js on the home page, and the only way to scroll on an iphone with a fullscreen iframe, is by touching the black background on top and bottom of the iframe.

Dave McFarland
Dave McFarland
Treehouse Teacher

HI Christopher Paccione

That seems to be a common problem. I was looking at a similar project -- https://github.com/lukesnowden/FSVS -- and the author says that he hasn't figured out a way to deal with scrolling on iOS.

Christopher Paccione
Christopher Paccione
14,831 Points

Thanks Dave, I'll check out the link! I ended up using two fixed transparent divs. It wasn't the best solution, but it worked given the time constraints.

Christopher Paccione
Christopher Paccione
14,831 Points

Wow small world, I just realized I purchased your book yesterday. "JavaScript & jQuery the missing manual", how weird. :)