|
|
@ -52,16 +52,28 @@ export default { |
|
|
|
}, |
|
|
|
listenerChange(list, index, cb) { |
|
|
|
const activeStyle = list[index].style; |
|
|
|
const screenWidth = this.$parent.$el.offsetWidth |
|
|
|
const screenHeight = this.$parent.$el.offsetHeight |
|
|
|
// 上边缘 |
|
|
|
if (Math.abs(activeStyle.top) <= value) { |
|
|
|
activeStyle.top = 0; |
|
|
|
cb && cb(list[index], index); |
|
|
|
} |
|
|
|
// 下边缘 |
|
|
|
if (Math.abs(activeStyle.top+activeStyle.height - screenHeight) <= value) { |
|
|
|
activeStyle.top = screenHeight - activeStyle.height; |
|
|
|
cb && cb(list[index], index); |
|
|
|
} |
|
|
|
// 左边缘 |
|
|
|
if (Math.abs(activeStyle.left) <= value) { |
|
|
|
activeStyle.left = 0; |
|
|
|
cb && cb(list[index], index); |
|
|
|
} |
|
|
|
// 右边缘 |
|
|
|
if (Math.abs(activeStyle.left+activeStyle.width-screenWidth) <= value) { |
|
|
|
activeStyle.left = screenWidth - activeStyle.width; |
|
|
|
cb && cb(list[index], index); |
|
|
|
} |
|
|
|
if (list.length==1) { |
|
|
|
return |
|
|
|
} |
|
|
|