Fix ripple for touchpads
Fix record audio bug
This commit is contained in:
parent
735721fee8
commit
38867d6e56
@ -16,6 +16,8 @@ import emoticonsDropdown from "../emoticonsDropdown";
|
|||||||
import PopupCreatePoll from "../popupCreatePoll";
|
import PopupCreatePoll from "../popupCreatePoll";
|
||||||
import { toast } from "../toast";
|
import { toast } from "../toast";
|
||||||
|
|
||||||
|
const RECORD_MIN_TIME = 500;
|
||||||
|
|
||||||
export class ChatInput {
|
export class ChatInput {
|
||||||
public pageEl = document.getElementById('page-chats') as HTMLDivElement;
|
public pageEl = document.getElementById('page-chats') as HTMLDivElement;
|
||||||
public messageInput = document.getElementById('input-message') as HTMLDivElement/* HTMLInputElement */;
|
public messageInput = document.getElementById('input-message') as HTMLDivElement/* HTMLInputElement */;
|
||||||
@ -515,14 +517,20 @@ export class ChatInput {
|
|||||||
|
|
||||||
if(!this.recorder || this.recording || !this.isInputEmpty()) {
|
if(!this.recorder || this.recording || !this.isInputEmpty()) {
|
||||||
if(this.recording) {
|
if(this.recording) {
|
||||||
this.recorder.stop();
|
if((Date.now() - this.recordStartTime) < RECORD_MIN_TIME) {
|
||||||
|
this.btnCancelRecord.click();
|
||||||
|
} else {
|
||||||
|
this.recorder.stop();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.sendMessage();
|
this.sendMessage();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
this.chatInput.classList.add('is-locked');
|
||||||
this.recorder.start().then(() => {
|
this.recorder.start().then(() => {
|
||||||
this.recordCanceled = false;
|
this.recordCanceled = false;
|
||||||
this.chatInput.classList.add('is-recording', 'is-locked');
|
|
||||||
|
this.chatInput.classList.add('is-recording');
|
||||||
this.recording = true;
|
this.recording = true;
|
||||||
this.updateSendBtn();
|
this.updateSendBtn();
|
||||||
opusDecodeController.setKeepAlive(true);
|
opusDecodeController.setKeepAlive(true);
|
||||||
@ -583,6 +591,8 @@ export class ChatInput {
|
|||||||
toast(e.message);
|
toast(e.message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.chatInput.classList.remove('is-recording', 'is-locked');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import mediaSizes from "../helpers/mediaSizes";
|
|
||||||
import { touchSupport } from "../lib/config";
|
import { touchSupport } from "../lib/config";
|
||||||
import { findUpClassName } from "../lib/utils";
|
import { findUpClassName } from "../lib/utils";
|
||||||
|
|
||||||
@ -19,18 +18,22 @@ export function ripple(elem: HTMLElement, callback: (id: number) => Promise<bool
|
|||||||
elem.append(r);
|
elem.append(r);
|
||||||
|
|
||||||
let handler: () => void;
|
let handler: () => void;
|
||||||
let animationEndPromise: Promise<any>;
|
//let animationEndPromise: Promise<number>;
|
||||||
const drawRipple = (clientX: number, clientY: number) => {
|
const drawRipple = (clientX: number, clientY: number) => {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
const span = document.createElement('span');
|
const span = document.createElement('span');
|
||||||
|
|
||||||
const clickID = rippleClickID++;
|
const clickID = rippleClickID++;
|
||||||
|
|
||||||
//console.log('ripple drawRipple');
|
//console.log('ripple drawRipple');
|
||||||
|
|
||||||
let duration: number;
|
const duration = +window.getComputedStyle(r).getPropertyValue('--ripple-duration').replace('s', '') * 1000;
|
||||||
|
//console.log('ripple duration', duration);
|
||||||
|
|
||||||
handler = () => {
|
handler = () => {
|
||||||
|
//handler = () => animationEndPromise.then((duration) => {
|
||||||
|
//console.log('ripple animation was:', duration);
|
||||||
|
|
||||||
//const duration = isSquare || mediaSizes.isMobile ? 200 : 700;
|
//const duration = isSquare || mediaSizes.isMobile ? 200 : 700;
|
||||||
//return;
|
//return;
|
||||||
let elapsedTime = Date.now() - startTime;
|
let elapsedTime = Date.now() - startTime;
|
||||||
@ -54,6 +57,7 @@ export function ripple(elem: HTMLElement, callback: (id: number) => Promise<bool
|
|||||||
|
|
||||||
handler = null;
|
handler = null;
|
||||||
};
|
};
|
||||||
|
//});
|
||||||
|
|
||||||
callback && callback(clickID);
|
callback && callback(clickID);
|
||||||
|
|
||||||
@ -100,14 +104,21 @@ export function ripple(elem: HTMLElement, callback: (id: number) => Promise<bool
|
|||||||
span.style.left = x + 'px';
|
span.style.left = x + 'px';
|
||||||
span.style.top = y + 'px';
|
span.style.top = y + 'px';
|
||||||
|
|
||||||
|
// нижний код выполняется с задержкой
|
||||||
|
/* animationEndPromise = new Promise((resolve) => {
|
||||||
|
span.addEventListener('animationend', () => {
|
||||||
|
// 713 -> 700
|
||||||
|
resolve(((Date.now() - startTime) / 100 | 0) * 100);
|
||||||
|
}, {once: true});
|
||||||
|
}); */
|
||||||
|
|
||||||
animationEndPromise = new Promise((resolve) => {
|
// нижний код не всегда включает анимацию ПРИ КЛИКЕ НА ТАЧПАД БЕЗ ТАПТИК ЭНЖИНА
|
||||||
span.addEventListener('animationend', resolve, {once: true});
|
/* span.style.display = 'none';
|
||||||
});
|
|
||||||
|
|
||||||
r.append(span);
|
r.append(span);
|
||||||
|
|
||||||
duration = +window.getComputedStyle(span).getPropertyValue('animation-duration').replace('s', '') * 1000;
|
duration = +window.getComputedStyle(span).getPropertyValue('animation-duration').replace('s', '') * 1000;
|
||||||
|
span.style.display = ''; */
|
||||||
|
|
||||||
|
r.append(span);
|
||||||
|
|
||||||
//r.classList.add('active');
|
//r.classList.add('active');
|
||||||
//handler();
|
//handler();
|
||||||
|
@ -362,6 +362,10 @@
|
|||||||
.btn-icon {
|
.btn-icon {
|
||||||
color: #c6cbce;
|
color: #c6cbce;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:not(.is-recording) #btn-send {
|
||||||
|
color: #c6cbce;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.is-recording {
|
&.is-recording {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
* --------------------------------------------------
|
* --------------------------------------------------
|
||||||
*/
|
*/
|
||||||
.c-ripple {
|
.c-ripple {
|
||||||
|
--ripple-duration: .7s;
|
||||||
//display: none !important;
|
//display: none !important;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
@ -51,6 +52,7 @@
|
|||||||
//overflow: hidden;
|
//overflow: hidden;
|
||||||
|
|
||||||
.btn-menu &, .c-ripple.is-square & {
|
.btn-menu &, .c-ripple.is-square & {
|
||||||
|
animation-name: ripple-effect-handhelds;
|
||||||
animation-duration: .2s;
|
animation-duration: .2s;
|
||||||
transition-duration: .1s;
|
transition-duration: .1s;
|
||||||
//border-radius: 15%;
|
//border-radius: 15%;
|
||||||
@ -63,15 +65,26 @@
|
|||||||
} */
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-menu &, &.is-square {
|
||||||
|
--ripple-duration: .2s;
|
||||||
|
}
|
||||||
|
|
||||||
&__circle.hiding, &__square.hiding {
|
&__circle.hiding, &__square.hiding {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@include respond-to(handhelds) {
|
@include respond-to(handhelds) {
|
||||||
.chats-container ul li > .rp .c-ripple__circle {
|
.chats-container ul li > .rp {
|
||||||
animation-duration: .2s;
|
.c-ripple {
|
||||||
transition-duration: .1s;
|
--ripple-duration: .2s;
|
||||||
|
|
||||||
|
&__circle {
|
||||||
|
animation-duration: .2s;
|
||||||
|
transition-duration: .1s;
|
||||||
|
animation-name: ripple-effect-handhelds;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +93,16 @@
|
|||||||
transform: scale(0);
|
transform: scale(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
to {
|
||||||
|
transform: scale(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes ripple-effect-handhelds {
|
||||||
|
0% {
|
||||||
|
transform: scale(.85);
|
||||||
|
}
|
||||||
|
|
||||||
to {
|
to {
|
||||||
transform: scale(2);
|
transform: scale(2);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user