Skip to content

Commit 7627557

Browse files
committed
Version 1.0.2
- The button works with mouse and touch events
1 parent 0e057ed commit 7627557

4 files changed

Lines changed: 20 additions & 11 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ plugins {
2424
id "base"
2525
}
2626

27-
version "1.0.1"
27+
version "1.0.2"
2828
group "org.imdc"
2929

3030

gateway/src/main/resources/mounted/Components.js

Lines changed: 10 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/packages/client/typescript/components/Button.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class Button extends React.Component<ButtonProps & React.DetailedHTMLProp
4040
return (
4141
<button
4242
{...remainingProps}
43+
draggable={false}
4344
disabled={disabled}
4445
className={classes}
4546
ref={forwardRef}

web/packages/client/typescript/components/MomentaryButton.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,27 +142,31 @@ export class MomentaryButton extends Component<ComponentProps<MomentaryButtonPro
142142
}
143143

144144
@bind
145-
handleMouseDown() {
145+
handleMouseDown(e) {
146146
const {
147147
enabled
148148
} = this.props.props;
149149

150150
if (enabled && !this.state.isActive) {
151151
this.mouseInitiated = true;
152152
this.setOn();
153+
window.addEventListener("pointerup", this.handleMouseUp);
153154
window.addEventListener("mouseup", this.handleMouseUp);
155+
window.addEventListener("touchend", this.handleMouseUp);
154156
}
155157
}
156158

157159
@bind
158-
handleMouseUp() {
160+
handleMouseUp(e) {
159161
const {
160162
enabled,
161163
onTime
162164
} = this.props.props;
163165

164166
if (enabled && this.mouseInitiated) {
167+
window.removeEventListener("pointerup", this.handleMouseUp);
165168
window.removeEventListener("mouseup", this.handleMouseUp);
169+
window.removeEventListener("touchend", this.handleMouseUp);
166170

167171
const timeLeft = onTime - (Date.now() - this.pressedTime);
168172
if (onTime == 0 || timeLeft <= 0) {
@@ -218,8 +222,8 @@ export class MomentaryButton extends Component<ComponentProps<MomentaryButtonPro
218222
{ ...styleProps }
219223
disabled={!enabled}
220224
secondary={false}
221-
onMouseUp={this.handleMouseUp}
222-
onMouseDown={this.handleMouseDown}
225+
onPointerUp={this.handleMouseUp}
226+
onPointerDown={this.handleMouseDown}
223227
>
224228
{ textElement }
225229
{ iconElement }

0 commit comments

Comments
 (0)