Commit 7a11749 1 parent a302b31 commit 7a11749 Copy full SHA for 7a11749
File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ Your manager has the following signature :
122
122
on: Function ,
123
123
off: Function ,
124
124
get: Function , // get a specific joystick
125
+ destroy: Function ,
125
126
options: {
126
127
zone: Element ,
127
128
multitouch: Boolean ,
@@ -164,6 +165,14 @@ An helper to get an instance via its identifier.
164
165
manager .get (0 );
165
166
```
166
167
168
+ #### ` manager.destroy() `
169
+
170
+ Gently remove all nipples from the DOM and unbind all events.
171
+
172
+ ``` javascript
173
+ manager .destroy ();
174
+ ```
175
+
167
176
### nipple instance (joystick)
168
177
169
178
Each joystick has the following signature :
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ var Manager = function (options) {
11
11
self . nipples . on = self . on . bind ( self ) ;
12
12
self . nipples . off = self . off . bind ( self ) ;
13
13
self . nipples . options = self . options ;
14
+ self . nipples . destroy = self . destroy . bind ( self ) ;
14
15
self . nipples . get = function ( id ) {
15
16
for ( var i = 0 , max = self . nipples . length ; i < max ; i += 1 ) {
16
17
if ( self . nipples [ i ] . identifier === id ) {
@@ -270,3 +271,12 @@ Manager.prototype.processOnEnd = function (evt) {
270
271
var index = self . nipples . indexOf ( nipple ) ;
271
272
self . nipples . splice ( index , 1 ) ;
272
273
} ;
274
+
275
+ // Cleanly destroy the manager
276
+ Manager . prototype . destroy = function ( ) {
277
+ this . off ( ) ;
278
+ this . unbindEvt ( this . options . zone , 'start' ) ;
279
+ this . nipples . forEach ( function ( nipple ) {
280
+ nipple . destroy ( ) ;
281
+ } ) ;
282
+ }
You can’t perform that action at this time.
0 commit comments