但我有一个问题:如何更改滑块开始的位置。滑块开始诠释,他的中间,我没有看到这个代码,其中一个设置:
function trackLocation(e) {
var rect = videoContainer.getBoundingClientRect(),
position = ((e.pageX - rect.left)/videoContainer.offsetWidth)*100;
if (position <= 100) {
videoClipper.style.width = position+"%";
clippedVideo.style.width = ((100/position)*100)+"%";
clippedVideo.style.zIndex = 3;
}
}
var videoContainer = document.getElementById("video-compare-container"),
videoClipper = document.getElementById("video-clipper"),
clippedVideo = videoClipper.getElementsByTagName("video")[0];
videoContainer.addEventListener("mousemove", trackLocation, false);
videoContainer.addEventListener("touchstart",trackLocation,false);
videoContainer.addEventListener("touchmove",trackLocation,false);
+1
欢迎底部的堆栈溢出,请[参观](https://stackoverflow.com/tour),确保你阅读了[我如何问一个好问题?](https://stackoverflow.com/help/how-to-ask)和用更多的信息更新了你的问题。 –
+0
对易读性进行少量编辑。 –