Skip to content

Commit

Permalink
Update album.js
Browse files Browse the repository at this point in the history
1.Add keepThumbBar mode mouse wheel support
2.Fix when mouse fast move in and out thumb bar several times abnormal hide/show
  • Loading branch information
ss22219 authored Aug 19, 2021
1 parent b496378 commit b726086
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions resource/libs/album/album.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* 对数字进行四舍五入操作
* @param {number} precision
*/
Number.prototype.toRound = function (precision) {
Number.prototype.toRound = function (precision) {
if (isNaN(precision) || precision == null || precision < 0) {
precision = 0;
}
Expand Down Expand Up @@ -47,7 +47,7 @@ window.album = function (options) {
resizeRate: 5,
listHeight: 160,
// 保持缩略图栏
keepThumbBar: true,
keepThumbBar: false,
maxSize: 100,
minSize: 5,
allowContextmenu: false,
Expand Down 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,9 +354,10 @@ window.album = function (options) {
});

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

} else {
// 鼠标离开和进入图片列表时
this.controlBar.on("mouseenter", () => {
Expand Down Expand Up @@ -453,7 +462,7 @@ window.album = function (options) {
},
hideThumbsBar() {
const _self = this;
this.listBar.animate({
this.listBar.stop().animate({
height: 30,
opacity: .2
}, () => {
Expand All @@ -466,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

0 comments on commit b726086

Please sign in to comment.