From 878e09d732771964781104288994a9544f11a24e Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 17 十一月 2023 18:03:25 +0800
Subject: [PATCH] 2023-11-17

---
 src/menu/stylecontroller/index.jsx |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/menu/stylecontroller/index.jsx b/src/menu/stylecontroller/index.jsx
index b60a0b0..b2e0d63 100644
--- a/src/menu/stylecontroller/index.jsx
+++ b/src/menu/stylecontroller/index.jsx
@@ -56,6 +56,7 @@
   }
 
   callback = null
+  timer = null
 
   shouldComponentUpdate (nextProps, nextState) {
     return !is(fromJS(this.state), fromJS(nextState))
@@ -96,6 +97,8 @@
     }
 
     this.callback = callback
+    this.timer = null
+
     let card = fromJS(style).toJS()
     let borposition = 'outer'
 
@@ -163,7 +166,7 @@
     this.callback = null
   }
 
-  updateStyle = (style) => {
+  updateStyle = (style, delay) => {
     const { card } = this.state
 
     let _style = {
@@ -191,7 +194,15 @@
       card: _style,
     })
 
-    this.callback && this.callback(_style)
+    this.timer && clearTimeout(this.timer)
+
+    if (delay) {
+      this.timer = setTimeout(() => {
+        this.callback && this.callback(_style)
+      }, 300)
+    } else {
+      this.callback && this.callback(_style)
+    }
   }
 
   /**
@@ -208,7 +219,7 @@
       value = 300
     }
 
-    this.updateStyle({fontSize: `${value}px`})
+    this.updateStyle({fontSize: `${value}px`}, true)
   }
 
   /**
@@ -219,7 +230,7 @@
 
     if (isNaN(value) || value < 1 || value > 10) return
 
-    this.updateStyle({lineHeight: value})
+    this.updateStyle({lineHeight: value}, true)
   }
 
   /**
@@ -230,7 +241,7 @@
 
     if (isNaN(value) || value < 0 || value > 100) return
 
-    this.updateStyle({letterSpacing: `${value}px`})
+    this.updateStyle({letterSpacing: `${value}px`}, true)
   }
 
   /**
@@ -241,7 +252,7 @@
 
     if (isNaN(value) || value < 0 || value > 100) return
 
-    this.updateStyle({textIndent: `${value}px`})
+    this.updateStyle({textIndent: `${value}px`}, true)
   }
 
   changeBackground = (val) => {

--
Gitblit v1.8.0