南宫28
// Video Control
var vidBtn = $('.video_control_btn');
var heroVdieo = document.querySelector('#heatsinkVideo');
vidBtn.on('click', function(event){
var $this = $(this);
if ($this.hasClass("pause")) {
$this.removeClass("pause").addClass("resume");
heroVdieo.pause();
} else if ($this.hasClass("resume")) {
$this.removeClass("resume").addClass("pause");
heroVdieo.play();
}
});
var videoTrigger = $(".trigger")[0];
var videoLoaded = false;
var uniformVideoLoaded = false;
var responseVideoLoaded = false;
if (videoTrigger != null){
window.addEventListener('scroll', function (event) {
if (triggerInViewport(videoTrigger)) {
if (document.querySelector('#heatsinkVideo source')) {
vidBtn.removeClass("resume").addClass("pause");
heroVdieo.play();
} else {
var source = document.createElement('source');
source.src = 'http://dlcdnwebimgs.junchengjj.com/files/media/0FC65822-E16E-414C-A35C-A1B5F36B2550/v1/video/heatsink.mp4';
source.type = 'video/mp4';
heroVdieo.appendChild(source);
//videoLoaded = true;
}
} else {
vidBtn.removeClass("pause").addClass("resume");
heroVdieo.pause();
}
if (isInViewport($(".trigger-uniform")[0]) && uniformVideoLoaded != true) {
//load video file
var source = document.createElement('source');
source.src = 'http://dlcdnwebimgs.junchengjj.com/files/media/323592BE-69E2-4C59-BF1D-352BD8D2D8F7/v1/video/uniform-brightness.mp4';
source.type = 'video/mp4';
document.querySelector('#uniform-vid1').appendChild(source);
var source2 = document.createElement('source');
source2.src = 'http://dlcdnwebimgs.junchengjj.com/files/media/323592BE-69E2-4C59-BF1D-352BD8D2D8F7/v1/video/without-uniform-brightness.mp4';
source2.type = 'video/mp4';
document.querySelector('#uniform-vid2').appendChild(source2);
uniformVideoLoaded = true;
}
if (isInViewport($(".trigger-response")[0]) && responseVideoLoaded != true) {
//load video file
var source3 = document.createElement('source');
source3.src = 'http://dlcdnwebimgs.junchengjj.com/files/media/0FC65822-E16E-414C-A35C-A1B5F36B2550/v1/video/with.mp4';
source3.type = 'video/mp4';
document.querySelector('#response-vid1').appendChild(source3);
var source4 = document.createElement('source');
source4.src = 'http://dlcdnwebimgs.junchengjj.com/files/media/0FC65822-E16E-414C-A35C-A1B5F36B2550/v1/video/without.mp4';
source4.type = 'video/mp4';
document.querySelector('#response-vid2').appendChild(source4);
responseVideoLoaded = true;
}
}, false);
}