|
@@ -190,17 +190,20 @@ export default {
|
|
//鼠标按下,计算当前元素距离可视区的距离
|
|
//鼠标按下,计算当前元素距离可视区的距离
|
|
let disX = e.clientX - oDiv.offsetLeft;
|
|
let disX = e.clientX - oDiv.offsetLeft;
|
|
let disY = e.clientY - oDiv.offsetTop;
|
|
let disY = e.clientY - oDiv.offsetTop;
|
|
-
|
|
|
|
|
|
+ let wrapW = document.querySelector('.timer').offsetWidth
|
|
|
|
+ let imgW = document.querySelector('.imgWrap').offsetWidth
|
|
|
|
+ console.log(imgW - wrapW)
|
|
document.onmousemove = function (e) {
|
|
document.onmousemove = function (e) {
|
|
//通过事件委托,计算移动的距离
|
|
//通过事件委托,计算移动的距离
|
|
let l = e.clientX - disX;
|
|
let l = e.clientX - disX;
|
|
let t = e.clientY - disY;
|
|
let t = e.clientY - disY;
|
|
- console.log(oDiv.offsetWidth, l, oDiv.offsetLeft)
|
|
|
|
|
|
+ // console.log(oDiv.offsetWidth, l, oDiv.offsetLeft)
|
|
//移动当前元素
|
|
//移动当前元素
|
|
|
|
+
|
|
if (l > 0) {
|
|
if (l > 0) {
|
|
l = 0;
|
|
l = 0;
|
|
- } else if (l < -978) {
|
|
|
|
- l = -978
|
|
|
|
|
|
+ } else if (l < -(imgW - wrapW) + 2) {
|
|
|
|
+ l = -(imgW - wrapW) + 2
|
|
}
|
|
}
|
|
|
|
|
|
oDiv.style.left = l + "px";
|
|
oDiv.style.left = l + "px";
|