mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Пофиксил прыгающую анимацию переходов
This commit is contained in:
@ -40,6 +40,7 @@ class Body extends BaseAuthBody {
|
|||||||
color="blue"
|
color="blue"
|
||||||
className={styles.activationCodeInput}
|
className={styles.activationCodeInput}
|
||||||
autoFocus
|
autoFocus
|
||||||
|
onFocus={this.fixAutoFocus}
|
||||||
required
|
required
|
||||||
placeholder={messages.enterTheCode}
|
placeholder={messages.enterTheCode}
|
||||||
/>
|
/>
|
||||||
|
@ -39,6 +39,35 @@ export default class BaseAuthBody extends Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fixes some issues with scroll, when input beeing focused
|
||||||
|
*
|
||||||
|
* When an element is focused, by default browsers will scroll its parents to display
|
||||||
|
* focused item to user. This behavior may cause unexpected visual effects, when
|
||||||
|
* you animating apearing of an input (e.g. transform) and auto focusing it. In
|
||||||
|
* that case the browser will scroll the parent container so that input will be
|
||||||
|
* visible.
|
||||||
|
* This method will fix that issue by finding parent with overflow: hidden and
|
||||||
|
* reseting its scrollLeft value to 0.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* <input autoFocus onFocus={this.fixAutoFocus} />
|
||||||
|
*
|
||||||
|
* @param {Object} event
|
||||||
|
*/
|
||||||
|
fixAutoFocus = (event) => {
|
||||||
|
let el = event.target;
|
||||||
|
|
||||||
|
while (el.parentNode) {
|
||||||
|
el = el.parentNode;
|
||||||
|
|
||||||
|
if (getComputedStyle(el).overflow === 'hidden') {
|
||||||
|
el.scrollLeft = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
serialize() {
|
serialize() {
|
||||||
return Object.keys(this.form).reduce((acc, key) => {
|
return Object.keys(this.form).reduce((acc, key) => {
|
||||||
acc[key] = this.form[key].getValue();
|
acc[key] = this.form[key].getValue();
|
||||||
|
@ -37,6 +37,7 @@ class Body extends BaseAuthBody {
|
|||||||
icon="envelope"
|
icon="envelope"
|
||||||
color="lightViolet"
|
color="lightViolet"
|
||||||
autoFocus
|
autoFocus
|
||||||
|
onFocus={this.fixAutoFocus}
|
||||||
required
|
required
|
||||||
placeholder={messages.accountEmail}
|
placeholder={messages.accountEmail}
|
||||||
/>
|
/>
|
||||||
|
@ -30,6 +30,7 @@ class Body extends BaseAuthBody {
|
|||||||
<Input {...this.bindField('login')}
|
<Input {...this.bindField('login')}
|
||||||
icon="envelope"
|
icon="envelope"
|
||||||
autoFocus
|
autoFocus
|
||||||
|
onFocus={this.fixAutoFocus}
|
||||||
required
|
required
|
||||||
placeholder={messages.emailOrUsername}
|
placeholder={messages.emailOrUsername}
|
||||||
/>
|
/>
|
||||||
|
@ -91,7 +91,7 @@ class PanelTransition extends Component {
|
|||||||
|
|
||||||
const contentHeight = {
|
const contentHeight = {
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
height: forceHeight ? common.switchContextHeightSpring : 'auto'
|
height: forceHeight ? common.style.switchContextHeightSpring : 'auto'
|
||||||
};
|
};
|
||||||
|
|
||||||
const bodyHeight = {
|
const bodyHeight = {
|
||||||
@ -141,6 +141,7 @@ class PanelTransition extends Component {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} config
|
* @param {Object} config
|
||||||
|
* @param {string} config.key
|
||||||
* @param {Object} [options]
|
* @param {Object} [options]
|
||||||
* @param {Object} [options.isLeave=false] - true, if this is a leave transition
|
* @param {Object} [options.isLeave=false] - true, if this is a leave transition
|
||||||
*
|
*
|
||||||
@ -298,8 +299,8 @@ class PanelTransition extends Component {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} key
|
* @param {string} key
|
||||||
* @param {Object} props
|
* @param {Object} style
|
||||||
* @param {number} props.opacitySpring
|
* @param {number} style.opacitySpring
|
||||||
*
|
*
|
||||||
* @return {Object}
|
* @return {Object}
|
||||||
*/
|
*/
|
||||||
|
@ -46,6 +46,7 @@ class Body extends BaseAuthBody {
|
|||||||
icon="key"
|
icon="key"
|
||||||
type="password"
|
type="password"
|
||||||
autoFocus
|
autoFocus
|
||||||
|
onFocus={this.fixAutoFocus}
|
||||||
required
|
required
|
||||||
placeholder={messages.accountPassword}
|
placeholder={messages.accountPassword}
|
||||||
/>
|
/>
|
||||||
|
@ -35,6 +35,7 @@ class Body extends BaseAuthBody {
|
|||||||
icon="key"
|
icon="key"
|
||||||
color="darkBlue"
|
color="darkBlue"
|
||||||
autoFocus
|
autoFocus
|
||||||
|
onFocus={this.fixAutoFocus}
|
||||||
required
|
required
|
||||||
placeholder={passwordChangedMessages.newPassword}
|
placeholder={passwordChangedMessages.newPassword}
|
||||||
/>
|
/>
|
||||||
|
@ -38,6 +38,7 @@ class Body extends BaseAuthBody {
|
|||||||
color="blue"
|
color="blue"
|
||||||
type="text"
|
type="text"
|
||||||
autoFocus
|
autoFocus
|
||||||
|
onFocus={this.fixAutoFocus}
|
||||||
required
|
required
|
||||||
placeholder={messages.yourNickname}
|
placeholder={messages.yourNickname}
|
||||||
/>
|
/>
|
||||||
|
Reference in New Issue
Block a user