소스 검색

Merge pull request #1144 from kkrisstoff/chat-animation-fix

Chat animation fix
j8
yanas 8 년 전
부모
커밋
c26b144f0d
1개의 변경된 파일14개의 추가작업 그리고 9개의 파일을 삭제
  1. 14
    9
      modules/UI/side_pannels/chat/Chat.js

+ 14
- 9
modules/UI/side_pannels/chat/Chat.js 파일 보기

157
     chat.height(window.innerHeight - 15 - msgareaHeight);
157
     chat.height(window.innerHeight - 15 - msgareaHeight);
158
 }
158
 }
159
 
159
 
160
+/**
161
+ * Focus input after 400 ms
162
+ * Found input by id
163
+ *
164
+ * @param id {string} input id
165
+ */
166
+function deferredFocus(id){
167
+    setTimeout(function (){
168
+        $(`#${id}`).focus();
169
+    }, 400);
170
+}
160
 /**
171
 /**
161
  * Chat related user interface.
172
  * Chat related user interface.
162
  */
173
  */
180
                 let val = this.value;
191
                 let val = this.value;
181
                 this.value = '';
192
                 this.value = '';
182
                 eventEmitter.emit(UIEvents.NICKNAME_CHANGED, val);
193
                 eventEmitter.emit(UIEvents.NICKNAME_CHANGED, val);
194
+                deferredFocus('usermsg');
183
             }
195
             }
184
         });
196
         });
185
 
197
 
223
                 // if we are in conversation mode focus on the text input
235
                 // if we are in conversation mode focus on the text input
224
                 // if we are not, focus on the display name input
236
                 // if we are not, focus on the display name input
225
                 if (APP.settings.getDisplayName())
237
                 if (APP.settings.getDisplayName())
226
-                    $('#usermsg').focus();
238
+                    deferredFocus('usermsg');
227
                 else
239
                 else
228
-                    $('#nickinput').focus();
240
+                    deferredFocus('nickinput');
229
             });
241
             });
230
 
242
 
231
         addSmileys();
243
         addSmileys();
318
     setChatConversationMode (isConversationMode) {
330
     setChatConversationMode (isConversationMode) {
319
         $('#' + CHAT_CONTAINER_ID)
331
         $('#' + CHAT_CONTAINER_ID)
320
             .toggleClass('is-conversation-mode', isConversationMode);
332
             .toggleClass('is-conversation-mode', isConversationMode);
321
-
322
-        // this is needed when we transition from no conversation mode to
323
-        // conversation mode. When user enters his nickname and hits enter,
324
-        // to focus on the write area.
325
-        if (isConversationMode) {
326
-            $('#usermsg').focus();
327
-        }
328
     },
333
     },
329
 
334
 
330
     /**
335
     /**

Loading…
취소
저장