简介:Tether可以用固定定位实现浮窗,提示等效果。
一、初始化方法
new Tether({
element: yellowBox,//挂载元素
target: greenBox,//触发对象
attachment: 'top right',//触摸定位
targetAttachment: 'top left'//目标定位
});
二、浮窗的偏移量
// offset:`${offsetY}px ${offsetX}px`,
targetOffset: this.getOffset(
cWidth,
clientX,
cHeight,
clientY,
targetWidth
),
三、Constraints
个人理解浮窗不足以展示时父页面出现scroll
constraints: [
{
to: "scrollParent",
pin: true,
attachment: "together",
},
{
to: "window",
attachment: "together",
},
],