js原生放大镜插件及H5+css+js代码
原生js放大镜插件:
<!将此段代码封装在mfPulgin.js文件中!>
class Magnifier {
constructor(newSmallBox, newBigBox, newMask) {
this.smallBox = newSmallBox;
this.bigBox = newBigBox;
this.mask = newMask;
}
onmouseover() {
let that = this;
this.smallBox.onmouseover = function() {
that.bigBox.style.display = “block”;
that.mask.style.display = “block”;
}
}
onmouseout() {
let that = this;
this.smallBox.onmouseout = function() {
that.bigBox.style.display = “none”;
that.mask.style.display = “none”;
}
}
onmousemove() {
let that = this;
this.smallBox.onmousemove = function(evt) {
let e = evt || event;
let left = e.pageX - this.offsetLeft - that.mask.offsetWidth / 2;
let top =