Browse Source

New multiselect input animation

master
Eduard Kuzmenko 4 years ago
parent
commit
3b3cf54724
  1. 23
      src/components/chat/selection.ts
  2. 48
      src/scss/partials/_chat.scss

23
src/components/chat/selection.ts

@ -275,23 +275,34 @@ export default class ChatSelection {
blurActiveElement(); // * for mobile keyboards blurActiveElement(); // * for mobile keyboards
let transform = ''; let transform = '', borderRadius = '';
const forwards = !!this.selectedMids.size || forceSelection; const forwards = !!this.selectedMids.size || forceSelection;
if(forwards) { if(forwards) {
const p = this.input.rowsWrapper.parentElement; const p = this.input.rowsWrapper.parentElement;
const widthFrom = p.querySelector('.fake-rows-wrapper').scrollWidth; const fakeSelectionWrapper = p.querySelector('.fake-selection-wrapper');
const widthTo = p.querySelector('.fake-selection-wrapper').scrollWidth; const fakeRowsWrapper = p.querySelector('.fake-rows-wrapper');
const btnSendWidth = this.input.btnSendContainer.scrollWidth - (.5625 * 16); const fakeSelectionRect = fakeSelectionWrapper.getBoundingClientRect();
const fakeRowsRect = fakeRowsWrapper.getBoundingClientRect();
const widthFrom = fakeRowsRect.width;
const widthTo = fakeSelectionRect.width;
if(widthFrom !== widthTo) { if(widthFrom !== widthTo) {
const scale = widthTo / widthFrom; const scale = (widthTo/* - 8 */) / widthFrom;
transform = `translateX(${btnSendWidth * scale}px) scaleX(${scale})`; const initTranslateX = (widthFrom - widthTo) / 2;
const needTranslateX = fakeSelectionRect.left - fakeRowsRect.left - initTranslateX;
transform = `translateX(${needTranslateX}px) scaleX(${scale})`;
if(scale < 1) {
const br = 12;
borderRadius = '' + (br + br * (1 - scale)) + 'px';
}
//scale = widthTo / widthFrom; //scale = widthTo / widthFrom;
} }
} }
SetTransition(this.input.rowsWrapper, 'is-centering', forwards, 200); SetTransition(this.input.rowsWrapper, 'is-centering', forwards, 200);
this.input.rowsWrapper.style.transform = transform; this.input.rowsWrapper.style.transform = transform;
this.input.rowsWrapper.style.borderRadius = borderRadius;
SetTransition(bubblesContainer, 'is-selecting', forwards, 200, () => { SetTransition(bubblesContainer, 'is-selecting', forwards, 200, () => {
if(!this.isSelecting) { if(!this.isSelecting) {
this.selectionInputWrapper.remove(); this.selectionInputWrapper.remove();

48
src/scss/partials/_chat.scss

@ -612,12 +612,16 @@ $chat-helper-size: 39px;
} }
} }
.selection-wrapper { .selection-wrapper, .fake-selection-wrapper {
position: absolute; position: absolute;
left: 50%; left: 50%;
top: 0; top: 0;
width: 28.75rem;
transform: translateX(-50%); transform: translateX(-50%);
width: 28.75rem;
max-width: calc(100% - (var(--padding-horizontal) * 2));
}
.selection-wrapper {
border-radius: $border-radius-big; border-radius: $border-radius-big;
//z-index: 2; //z-index: 2;
box-shadow: none; box-shadow: none;
@ -698,28 +702,38 @@ $chat-helper-size: 39px;
visibility: hidden; visibility: hidden;
} }
.fake-rows-wrapper { .rows-wrapper, .fake-rows-wrapper {
width: calc(100% - var(--chat-input-size) - (var(--padding-horizontal) * 2) - .5625rem); .chat-input.type-pinned & {
width: 17.125rem;
}
.chat-input.type-pinned.can-pin & {
width: 13.125rem;
}
} }
.fake-selection-wrapper { .fake-rows-wrapper {
width: 460px; position: absolute;
left: var(--padding-horizontal);
top: 0;
width: calc(100% - var(--chat-input-size) - (var(--padding-horizontal) * 2) - .5625rem);
} }
.rows-wrapper { .rows-wrapper {
transform: scaleX(1); transform: scaleX(1);
transition: transform .2s, width .2s, max-height .2s, border-bottom-right-radius .1s; transition: transform .2s, width .2s, max-height .2s, border-radius .1s;
&:after { &.is-centered {
transition: transform .1s; margin: 0 auto;
}
.chat-input.type-pinned & { & ~ .fake-rows-wrapper {
width: 17.125rem; left: 50%;
transform: translateX(-50%);
}
} }
.chat-input.type-pinned.can-pin & { &:after {
width: 13.125rem; transition: transform .1s;
} }
&.is-centering:not(.backwards), &.is-centered { &.is-centering:not(.backwards), &.is-centered {
@ -730,10 +744,6 @@ $chat-helper-size: 39px;
} }
} }
/* &.is-centered, &.is-centered.is-centering:not(.backwards) {
transform: translate3d(calc(((var(--messages-container-width) - var(--chat-input-padding) * 2) - 100%) / 2), 0, 0);
} */
@include respond-to(handhelds) { @include respond-to(handhelds) {
--padding-vertical: .5px; --padding-vertical: .5px;
--padding-horizontal: .5rem; --padding-horizontal: .5rem;
@ -970,7 +980,7 @@ $chat-helper-size: 39px;
&.is-selecting { &.is-selecting {
&:not(.backwards) .is-in .bubble-content-wrapper { &:not(.backwards) .is-in .bubble-content-wrapper {
transform: translateX(2.5rem); transform: scale(1) translateX(2.5rem);
} }
// ! this animation will slow down chat input's animation due to count of elements // ! this animation will slow down chat input's animation due to count of elements

Loading…
Cancel
Save