Feature: Optimize resize events trigger

This commit is contained in:
winkidney
2019-03-07 17:55:14 +08:00
committed by Isaac Bythewood
parent 488138767f
commit 051c1735d6

View File

@@ -198,11 +198,18 @@ Vue.component('pin-container', {
});
(function() {
var previousResize = 0;
var throttle = function(type, name, obj) {
obj = obj || window;
var running = false;
var func = function() {
if (running) { return; }
var now = new Date().getTime();
console.log(now, previousResize, now - previousResize);
if ((now - previousResize) < 200) {
return
}
previousResize = now;
running = true;
requestAnimationFrame(function() {
obj.dispatchEvent(new CustomEvent(name));