How to change button with jQuery when new video scrolls up into view on page?
On this page http://kimcolemanprojects.com/djangolive_1.html there are five videos.
When you click on each video the next video scrolls up into view with jQuery.
Because of this jQuery effect, I had to disable the video controls. So I decided to put a play/pause button to the left of each video.
However, I now need some help with making a script that will change the button when each new video scrolls into view. I have a piece of script that changes the titles as the different videos scroll into view, which is also on the left of each video, please see script below.
- $(window).load(function () { // Scroll to titles on click
- $('a').on('click', function () {
- var target = $(this).attr('href');
- $('html,body').animate({
- scrollTop: $(target).offset().top
- }, 'slow');
- return false;
- });
- // jQuery `inView`-expression
- $.extend($.expr[':'], {
- inView: function (el) {
- var width = $(el).width(),
- height = $(el).height(),
- offset = $(el).offset(),
- vp_dimensions = {
- height: $(window).height(),
- width: $(window).width()
- }, y_offset = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop),
- x_offset = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
- return(offset.top < (y_offset + vp_dimensions.height) && offset.left < (x_offset + vp_dimensions.width) && (offset.top + height) > y_offset && (offset.left + width) > x_offset);
- }
- }); // Change the titles on scroll
- $(window).scroll(function () {
- $('li').each(function () {
- var self = $(this),
- title = self.find('video').attr('title');
- if(self.is(':inView')) {
- $('#title').find('h2').text(title);
- }
- });
- }).scroll();
- });
Thanks for your time
Angela