This commit is contained in:
Harvey Zack committed 2018-10-24 13:43:11 +08:00
1 parent 9fd3e580bb
commit 4ce05442c7
36 files changed
+731 -683

No files matched your search

+14 -11
View File
@@ -1,7 +1,10 @@
export default class Thumbnails {
constructor(art, option) {
this.art = art;
constructor(option) {
this.option = option;
}
apply(art) {
this.art = art;
this.init();
}
@@ -12,12 +15,12 @@ export default class Thumbnails {
} = this.art;
proxy($progress, 'mousemove', event => {
this.option.ref.style.display = 'block';
this.option.$control.style.display = 'block';
this.showThumbnails(event);
});
proxy($progress, 'mouseout', () => {
this.option.ref.style.display = 'none';
this.option.$control.style.display = 'none';
});
}
@@ -30,17 +33,17 @@ export default class Thumbnails {
let yIndex = Math.ceil(perIndex / column);
let xIndex = perIndex % column || column;
this.option.ref.style.backgroundImage = `url(${url})`;
this.option.ref.style.height = `${height}px`;
this.option.ref.style.width = `${width}px`;
this.option.ref.style.backgroundPosition = `-${--xIndex * width}px -${--yIndex * height}px`;
this.option.$control.style.backgroundImage = `url(${url})`;
this.option.$control.style.height = `${height}px`;
this.option.$control.style.width = `${width}px`;
this.option.$control.style.backgroundPosition = `-${--xIndex * width}px -${--yIndex * height}px`;
if (posWidth <= width / 2) {
this.option.ref.style.left = 0;
this.option.$control.style.left = 0;
} else if (posWidth > $progress.clientWidth - width / 2) {
this.option.ref.style.left = `${$progress.clientWidth - width}px`;
this.option.$control.style.left = `${$progress.clientWidth - width}px`;
} else {
this.option.ref.style.left = `${posWidth - width / 2}px`;
this.option.$control.style.left = `${posWidth - width / 2}px`;
}
}
}