update docs

This commit is contained in:
Harvey Zack committed 2023-05-13 21:57:45 +08:00
1 parent 84c84e4cda
commit e3e42eb399
115 files changed
+279 -598

No files matched your search

+2 -2
View File
@@ -1,4 +1,4 @@
import { throttle } from '../utils';
import { debounce } from '../utils';
export default function resizeInit(art, events) {
const { option, constructor } = art;
@@ -12,7 +12,7 @@ export default function resizeInit(art, events) {
notice.show = '';
});
const resizeFn = throttle(() => art.emit('resize'), constructor.RESIZE_TIME);
const resizeFn = debounce(() => art.emit('resize'), constructor.RESIZE_TIME);
events.proxy(window, ['orientationchange', 'resize'], () => resizeFn());
if (screen && screen.orientation && screen.orientation.onchange) {
events.proxy(screen.orientation, 'change', () => resizeFn());
+1 -1
View File
@@ -217,7 +217,7 @@ Artplayer.NOTICE_TIME = 2000;
Artplayer.SETTING_WIDTH = 250;
Artplayer.SETTING_ITEM_WIDTH = 200;
Artplayer.SETTING_ITEM_HEIGHT = 35;
Artplayer.RESIZE_TIME = 500;
Artplayer.RESIZE_TIME = 200;
Artplayer.SCROLL_TIME = 200;
Artplayer.SCROLL_GAP = 50;
Artplayer.AUTO_PLAYBACK_MAX = 10;
+18 -32
View File
@@ -2,45 +2,31 @@ export function sleep(ms = 0) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
export function debounce(func, wait, context) {
export function debounce(func, duration) {
let timeout;
function fn(...args) {
const later = function later() {
return function (...args) {
const effect = () => {
timeout = null;
func.apply(context, args);
return func.apply(this, args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
}
fn.clearTimeout = function ct() {
clearTimeout(timeout);
timeout = setTimeout(effect, duration);
};
return fn;
}
export function throttle(callback, delay) {
let isThrottled = false;
let args;
let context;
function fn(...args2) {
if (isThrottled) {
args = args2;
context = this;
return;
export function throttle(func, duration) {
let shouldWait = false;
return function (...args) {
if (!shouldWait) {
func.apply(this, args);
shouldWait = true;
setTimeout(function () {
shouldWait = false;
}, duration);
}
isThrottled = true;
callback.apply(this, args2);
setTimeout(() => {
isThrottled = false;
if (args) {
fn.apply(context, args);
args = null;
context = null;
}
}, delay);
}
return fn;
};
}