12
12
*/
13
13
( function ( $ , undefined ) {
14
14
15
- var interaction , pointerHook ;
16
-
17
15
$ . widget ( "ui.interaction" , {
18
16
version : "@VERSION" ,
17
+ started : false ,
19
18
_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
21
20
this . _interactionMove = $ . proxy ( this , "_interactionMove" ) ;
22
21
this . _interactionStop = $ . proxy ( this , "_interactionStop" ) ;
23
22
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 ) ) ;
28
25
} ,
29
26
30
27
/** abstract methods **/
@@ -53,7 +50,7 @@ $.widget( "ui.interaction", {
53
50
var started ;
54
51
55
52
// only one interaction can happen at a time
56
- if ( interaction . started ) {
53
+ if ( this . started ) {
57
54
return false ;
58
55
}
59
56
@@ -65,8 +62,8 @@ $.widget( "ui.interaction", {
65
62
// check if the widget wants the event to start an interaction
66
63
started = ( this . _start ( event , pointerPosition ) !== false ) ;
67
64
if ( started ) {
68
- interaction . started = true ;
69
- interaction . hooks [ hook ] . handle ( this ,
65
+ this . started = true ;
66
+ this . handle ( this ,
70
67
this . _interactionMove , this . _interactionStop ) ;
71
68
}
72
69
@@ -80,22 +77,14 @@ $.widget( "ui.interaction", {
80
77
81
78
_interactionStop : function ( event , pointerPosition ) {
82
79
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
+ } ,
92
82
93
- pointerHook = interaction . hooks . pointer = {
94
83
setup : function ( widget , start ) {
95
84
widget . _on ( widget . widget ( ) , {
96
85
"pointerdown" : function ( event ) {
97
86
event = event . originalEvent ;
98
- if ( pointerHook . id ) {
87
+ if ( this . id ) {
99
88
return ;
100
89
}
101
90
@@ -108,7 +97,7 @@ pointerHook = interaction.hooks.pointer = {
108
97
109
98
if ( started ) {
110
99
// track pointer which is performing the interaction
111
- pointerHook . id = event . pointerId ;
100
+ this . id = event . pointerId ;
112
101
113
102
// prevent selection
114
103
event . preventDefault ( ) ;
@@ -123,7 +112,7 @@ pointerHook = interaction.hooks.pointer = {
123
112
event = event . originalEvent ;
124
113
125
114
// Only move if original pointer moves
126
- if ( event . pointerId !== pointerHook . id ) {
115
+ if ( event . pointerId !== this . id ) {
127
116
return ;
128
117
}
129
118
@@ -137,7 +126,7 @@ pointerHook = interaction.hooks.pointer = {
137
126
event = event . originalEvent ;
138
127
139
128
// Only stop if original pointer stops
140
- if ( event . pointerId !== pointerHook . id ) {
129
+ if ( event . pointerId !== this . id ) {
141
130
return ;
142
131
}
143
132
@@ -146,7 +135,7 @@ pointerHook = interaction.hooks.pointer = {
146
135
y : event . pageY
147
136
} ) ;
148
137
149
- pointerHook . id = null ;
138
+ this . id = null ;
150
139
151
140
widget . document
152
141
. unbind ( "pointermove" , moveHandler )
@@ -160,6 +149,6 @@ pointerHook = interaction.hooks.pointer = {
160
149
"pointercancel" : stopHandler
161
150
} ) ;
162
151
}
163
- } ;
152
+ } ) ;
164
153
165
154
} ) ( jQuery ) ;
0 commit comments