Skip to content

Commit 1398b09

Browse files
committed
Interaction: Remove the hook abstraction as it is not needed with pointer events
1 parent 9cde172 commit 1398b09

File tree

1 file changed

+15
-26
lines changed

1 file changed

+15
-26
lines changed

ui/jquery.ui.interaction.js

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@
1212
*/
1313
(function( $, undefined ) {
1414

15-
var interaction, pointerHook;
16-
1715
$.widget( "ui.interaction", {
1816
version: "@VERSION",
17+
started: false,
1918
_create: function() {
20-
// force the context so we can pass these methods to the hooks
19+
// force the context so we can pass these methods to the hook
2120
this._interactionMove = $.proxy( this, "_interactionMove" );
2221
this._interactionStop = $.proxy( this, "_interactionStop" );
2322

24-
// initialize all hooks for this widget
25-
for ( var hook in interaction.hooks ) {
26-
interaction.hooks[ hook ].setup( this, this._startProxy( hook ) );
27-
}
23+
// initialize hook for this widget
24+
this.setup( this, this._startProxy( this ) );
2825
},
2926

3027
/** abstract methods **/
@@ -53,7 +50,7 @@ $.widget( "ui.interaction", {
5350
var started;
5451

5552
// only one interaction can happen at a time
56-
if ( interaction.started ) {
53+
if ( this.started ) {
5754
return false;
5855
}
5956

@@ -65,8 +62,8 @@ $.widget( "ui.interaction", {
6562
// check if the widget wants the event to start an interaction
6663
started = ( this._start( event, pointerPosition ) !== false );
6764
if ( started ) {
68-
interaction.started = true;
69-
interaction.hooks[ hook ].handle( this,
65+
this.started = true;
66+
this.handle( this,
7067
this._interactionMove, this._interactionStop );
7168
}
7269

@@ -80,22 +77,14 @@ $.widget( "ui.interaction", {
8077

8178
_interactionStop: function( event, pointerPosition ) {
8279
this._stop( event, pointerPosition );
83-
interaction.started = false;
84-
}
85-
});
86-
87-
interaction = $.ui.interaction;
88-
$.extend( interaction, {
89-
started: false,
90-
hooks: {}
91-
});
80+
this.started = false;
81+
},
9282

93-
pointerHook = interaction.hooks.pointer = {
9483
setup: function( widget, start ) {
9584
widget._on( widget.widget(), {
9685
"pointerdown": function( event ) {
9786
event = event.originalEvent;
98-
if ( pointerHook.id ) {
87+
if ( this.id ) {
9988
return;
10089
}
10190

@@ -108,7 +97,7 @@ pointerHook = interaction.hooks.pointer = {
10897

10998
if ( started ) {
11099
// track pointer which is performing the interaction
111-
pointerHook.id = event.pointerId;
100+
this.id = event.pointerId;
112101

113102
// prevent selection
114103
event.preventDefault();
@@ -123,7 +112,7 @@ pointerHook = interaction.hooks.pointer = {
123112
event = event.originalEvent;
124113

125114
// Only move if original pointer moves
126-
if ( event.pointerId !== pointerHook.id ) {
115+
if ( event.pointerId !== this.id ) {
127116
return;
128117
}
129118

@@ -137,7 +126,7 @@ pointerHook = interaction.hooks.pointer = {
137126
event = event.originalEvent;
138127

139128
// Only stop if original pointer stops
140-
if ( event.pointerId !== pointerHook.id ) {
129+
if ( event.pointerId !== this.id ) {
141130
return;
142131
}
143132

@@ -146,7 +135,7 @@ pointerHook = interaction.hooks.pointer = {
146135
y: event.pageY
147136
});
148137

149-
pointerHook.id = null;
138+
this.id = null;
150139

151140
widget.document
152141
.unbind( "pointermove", moveHandler )
@@ -160,6 +149,6 @@ pointerHook = interaction.hooks.pointer = {
160149
"pointercancel": stopHandler
161150
});
162151
}
163-
};
152+
});
164153

165154
})( jQuery );

0 commit comments

Comments
 (0)