mirror of
https://github.com/pinry/pinry.git
synced 2025-11-18 02:40:40 +01:00
Feature: Optimize resize events trigger
This commit is contained in:
committed by
Isaac Bythewood
parent
488138767f
commit
051c1735d6
@@ -198,11 +198,18 @@ Vue.component('pin-container', {
|
|||||||
});
|
});
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
var previousResize = 0;
|
||||||
var throttle = function(type, name, obj) {
|
var throttle = function(type, name, obj) {
|
||||||
obj = obj || window;
|
obj = obj || window;
|
||||||
var running = false;
|
var running = false;
|
||||||
var func = function() {
|
var func = function() {
|
||||||
if (running) { return; }
|
if (running) { return; }
|
||||||
|
var now = new Date().getTime();
|
||||||
|
console.log(now, previousResize, now - previousResize);
|
||||||
|
if ((now - previousResize) < 200) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
previousResize = now;
|
||||||
running = true;
|
running = true;
|
||||||
requestAnimationFrame(function() {
|
requestAnimationFrame(function() {
|
||||||
obj.dispatchEvent(new CustomEvent(name));
|
obj.dispatchEvent(new CustomEvent(name));
|
||||||
|
|||||||
Reference in New Issue
Block a user