You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: JS/JS-br.md
+25-25Lines changed: 25 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1125,50 +1125,50 @@ A implementação completa da ƒunção não é tão difícil.
1125
1125
1126
1126
# Throttle
1127
1127
1128
-
`Debounce`and`Throttle`are different in nature. `Debounce`is to turn multiple executions into one last execution, and`Throttle`is to turn multiple executions into executions at regular intervals.
1128
+
`Debounce`e`Throttle`possuem naturezas diferentes. `Debounce`é para tornar multiplas execuções na última execução, e`Throttle`é para tornar multiplas execuções em uma execução de intervalos regulares.
1129
1129
1130
1130
```js
1131
-
//The first two parameters with debounce are the same function
1132
-
// options: You can pass two properties
1133
-
// trailing: Last time does not execute
1134
-
// leading: First time does not execute
1135
-
//The two properties cannot coexist, otherwise the function cannot be executed
1131
+
//Os dois primeiro parâmetros com debounce são a mesma função
1132
+
// options: você pode passar duas propriedades
1133
+
// trailing: o último tempo não é executado
1134
+
// leading: o primeiro tempo não é executado
1135
+
//As duas propriedades não coexistem, contudo a função não será executada
1136
1136
_.throttle=function(func, wait, options) {
1137
1137
var context, args, result;
1138
1138
var timeout =null;
1139
-
//Previous timestamp
1139
+
// timestamp anterior
1140
1140
var previous =0;
1141
-
//Set empty if options is not passed
1141
+
//Defina vázio se as opções não forem passadas
1142
1142
if (!options) options = {};
1143
-
// Timer callback function
1143
+
//Função Timer callback
1144
1144
varlater=function() {
1145
-
//If you set `leading`, then set `previous` to zero
1146
-
//The first `if` statement of the following function is used
1145
+
//se você definiu `leading`, então defina `previous` para zero
1146
+
//O primeiro if da seguinte função é usada
1147
1147
previous =options.leading===false?0:_.now();
1148
-
//The first is prevented memory leaks and the second is judged the following timers when setting `timeout` to null
1148
+
//O primeiro é prevenindo memory leaks e o segundo é julgado os seguintes timers quando configurado `timeout` para null
1149
1149
timeout =null;
1150
1150
result =func.apply(context, args);
1151
1151
if (!timeout) context = args =null;
1152
1152
};
1153
1153
returnfunction() {
1154
-
//Get current timestamp
1154
+
//Obtenha o timestamp atual
1155
1155
var now =_.now();
1156
-
//It must be true when it entering firstly
1157
-
//If you do not need to execute the function firstly
1158
-
//Set the last timestamp to current
1159
-
//Then it will be greater than 0 when the remaining time is calculated next
1156
+
//Deve ser verdado quando entrar pela primeira vez
1157
+
//Se você não precisa executar essa função na primeira vez
1158
+
//Defina o último timestamp para o atual
1159
+
//Então ele será maior que 0 quando o termo remanecente for calculado da próxima vez
1160
1160
if (!previous &&options.leading===false)
1161
1161
previous = now;
1162
1162
var remaining = wait - (now - previous);
1163
1163
context =this;
1164
1164
args =arguments;
1165
-
//This condition will only be entered if it set `trailing`
1166
-
//This condition will be entered firstly if it not set `leading`
1167
-
//Another point, you may think that this condition will not be entered if you turn on the timer
1168
-
//In fact, it will still enter because the timer delay is not accurate
1169
-
//It is very likely that you set 2 seconds, but it needs 2.2 seconds to trigger, then this time will enter this condition
1165
+
//Essa condição só será preenchida se definido para `trailing`
1166
+
//Essa condição só será preenchida no ínicio se não definido `leading`
1167
+
//Outro ponto, você deve pensar que essa condição não será preenchida se você ligar o timer
1168
+
//De fato, será assim até entrar porque o atraso do timer não é acurado
1169
+
//Isso é muito como se você setar a 2 segundos, mas ele precisa 2.2 segundos para disparar, então o tempo será preenchido nessa condição
1170
1170
if (remaining <=0|| remaining > wait) {
1171
-
//Clean up if there exist a timer otherwise it call twice callback
1171
+
//Limpe se existe um timer e ele chama a callback duas vezes
0 commit comments