Skip to content

Commit

Permalink
v1.5.8
Browse files Browse the repository at this point in the history
ListItem: returned onClick in selectable mode
Button: stopPropagation={true} for Tappable
Tappable: added new property stopPropagation
ScrollView: optimized property pass prevented
  • Loading branch information
ArthurStam committed May 25, 2018
1 parent 92975ee commit 4c33c4e
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vkontakte/vkui",
"version": "1.5.7",
"version": "1.5.8",
"main": "dist/vkui.js",
"repository": "https://github.com/VKCOM/VKUI",
"description": "VKUI library",
Expand Down
2 changes: 1 addition & 1 deletion src/components/ButtonNew/ButtonNew.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class ButtonNew extends React.Component {
});

return (
<Tappable className={classNames} {...restProps}>
<Tappable className={classNames} stopPropagation {...restProps}>
<div className="ButtonNew__in">
{before && <div className="ButtonNew__before">{before}</div>}
{children && <div className="ButtonNew__content">{children}</div>}
Expand Down
1 change: 1 addition & 0 deletions src/components/ButtonOld/ButtonOld.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default class ButtonOld extends Component {
component={component}
className={classnames(baseClassNames, className, modifiers)}
style={style}
stopPropagation
{...nativeProps}
>
{children}
Expand Down
10 changes: 8 additions & 2 deletions src/components/ListItem/ListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ export default class ListItem extends Component {

get document () { return this.context.document || document; }

emptyClickHandler () {}
onSelectableClick = (e) => {
if (e.target.tagName.toLowerCase() === 'input') {
e.stopPropagation();
} else {
this.props.onClick && this.props.onClick(e);
}
};

activateRemove = () => {
this.setState({ isRemoveActivated: true, height: this.rootEl.offsetHeight });
Expand Down Expand Up @@ -133,7 +139,7 @@ export default class ListItem extends Component {
<Tappable
component={selectable ? 'label' : 'div'}
className="ListItem__in"
onClick={selectable ? this.emptyClickHandler : onClick}
onClick={selectable ? this.onSelectableClick : onClick}
style={{ transform: `translateX(-${this.state.removeOffset}px)` }}
>
{selectable &&
Expand Down
2 changes: 1 addition & 1 deletion src/components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class ScrollView extends Component {
className={classnames(baseClassNames, className, {
'ScrollView--centered': this.props.centered
})}
{...removeObjectKeys(this.props, ['header', 'onPull', 'className', 'activePanel', 'prevPanel', 'nextPanel', 'fixedLayout', 'theme', 'centered'])}
{...removeObjectKeys(this.props, ['header', 'onPull', 'className', 'activePanel', 'prevPanel', 'nextPanel', 'fixedLayout', 'theme', 'centered', 'optimized'])}
ref={this.getRef}
>
<div className="ScrollView__in" style={{ paddingBottom: this.insets.bottom || null }}>
Expand Down
21 changes: 11 additions & 10 deletions src/components/Tappable/Tappable.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ export default class Tappable extends Component {
PropTypes.element
]),
role: PropTypes.string,
activeEffectDelay: PropTypes.number
activeEffectDelay: PropTypes.number,
stopPropagation: PropTypes.bool
};

static defaultProps = {
component: 'div',
role: 'button',
stopPropagation: false,
activeEffectDelay: ACTIVE_EFFECT_DELAY
};

Expand All @@ -71,6 +73,7 @@ export default class Tappable extends Component {
* @returns {void}
*/
onStart = ({ originalEvent }) => {
this.props.stopPropagation && originalEvent.stopPropagation();
if (originalEvent.touches && originalEvent.touches.length > 1) {
return deactivateOtherInstances();
}
Expand All @@ -89,8 +92,9 @@ export default class Tappable extends Component {
*
* @returns {void}
*/
onMove = (e) => {
if (e.shiftXAbs > 20 || e.shiftYAbs > 20) {
onMove = ({ originalEvent, shiftXAbs, shiftYAbs }) => {
this.props.stopPropagation && originalEvent.stopPropagation();
if (shiftXAbs > 20 || shiftYAbs > 20) {
this.isSlide = true;
this.stop();
}
Expand All @@ -102,6 +106,7 @@ export default class Tappable extends Component {
* @returns {void}
*/
onEnd = ({ originalEvent }) => {
this.props.stopPropagation && originalEvent.stopPropagation();
const now = ts();

if (originalEvent.touches && originalEvent.touches.length > 0) {
Expand Down Expand Up @@ -168,10 +173,6 @@ export default class Tappable extends Component {
}, 225);
};

onClick = (e) => {
this.props.onClick && this.props.onClick(e);
};

/**
* Устанавливает активное выделение
*
Expand Down Expand Up @@ -256,16 +257,16 @@ export default class Tappable extends Component {
}

const nativeProps = removeObjectKeys(Object.assign({}, this.props), [
'onClick',
'children',
'className',
'propagation',
'component',
'activeEffectDelay'
'activeEffectDelay',
'stopPropagation'
]);

return (
<Component className={classes} {...props} {...nativeProps} onClick={this.onClick}>
<Component className={classes} {...props} {...nativeProps}>
{osname === ANDROID && (
<span className="Tappable__waves" ref={this.getContainer}>
{Object.keys(clicks).map(k => (
Expand Down

0 comments on commit 4c33c4e

Please sign in to comment.