Skip to content

Commit

Permalink
Merge pull request #876 from ss22219/dev
Browse files Browse the repository at this point in the history
Update album.js
  • Loading branch information
ted423 authored Jun 27, 2022
2 parents 8e208d3 + b726086 commit 33cd812
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions resource/libs/album/album.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ window.album = function (options) {
theme: "",
IE: ("v" == "\v"),
init() {
console.log('this\'s album.js');
this.options = $.extend(this.options, options);
if (!this.options.parent) {
this.options.parent = $(document.body);
Expand Down Expand Up @@ -328,8 +329,15 @@ window.album = function (options) {
if (!this.options.keepThumbBar) {
// 鼠标离开和进入图片列表时
this.controlBar.on("mouseleave", () => {
self.hideThumbsBar();
if(self.hideThumbsBarTimer)
clearTimeout(self.hideThumbsBarTimer);
// 隐藏图片列表
self.hideThumbsBarTimer = setTimeout(() => {
self.hideThumbsBar();
}, 500);
}).on("mouseenter", () => {
if(self.hideThumbsBarTimer)
clearTimeout(self.hideThumbsBarTimer);
self.showThumbsBar();
// 鼠标滚轮上一张、下一张
}).on("mousewheel DOMMouseScroll", event => {
Expand All @@ -346,13 +354,27 @@ window.album = function (options) {
});

// 隐藏图片列表
setTimeout(() => {
self.hideThumbsBarTimer = setTimeout(() => {
self.hideThumbsBar();
}, 1000);

} else {
// this.listBar.css({
// opacity: .6
// });
// 鼠标离开和进入图片列表时
this.controlBar.on("mouseenter", () => {
self.showThumbsBar();
// 鼠标滚轮上一张、下一张
}).on("mousewheel DOMMouseScroll", event => {
// $.log("mousewheel", event);
const v = (event.type == "mousewheel" ? event.originalEvent.wheelDelta : event.originalEvent.detail);
if (v < 0) {
self.gotoImage("next");
} else {
self.gotoImage("prev");
}

event.preventDefault();
event.stopPropagation();
});
}

// 上一张
Expand Down Expand Up @@ -440,7 +462,7 @@ window.album = function (options) {
},
hideThumbsBar() {
const _self = this;
this.listBar.animate({
this.listBar.stop().animate({
height: 30,
opacity: .2
}, () => {
Expand All @@ -453,7 +475,7 @@ window.album = function (options) {
},
showThumbsBar() {
const _self = this;
this.listBar.animate({
this.listBar.stop().animate({
height: this.options.listHeight,
opacity: .8
}, () => {
Expand Down Expand Up @@ -936,4 +958,4 @@ window.album = function (options) {
return _img;
}
}).init();
};
};

0 comments on commit 33cd812

Please sign in to comment.