mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-19 01:31:38 +00:00
made 'this' of the toggler's callbacks reference the right thing if called as a method...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
9316998873
commit
be9c4ebdc9
@ -66,6 +66,9 @@
|
|||||||
// called after (post) the change is made. If two are given then the first
|
// called after (post) the change is made. If two are given then the first
|
||||||
// is called before the change and the second after the change.
|
// is called before the change and the second after the change.
|
||||||
// The callbacks are passed the current action.
|
// The callbacks are passed the current action.
|
||||||
|
// The callback function will have this set to the same value as the toggler
|
||||||
|
// itself, e.g. if the toggler is called as a method, the callback's this
|
||||||
|
// will reference the object.
|
||||||
//
|
//
|
||||||
// NOTE: the pre-callback will get the "intent" action, i.e. the state the
|
// NOTE: the pre-callback will get the "intent" action, i.e. the state the
|
||||||
// we are changing into but the changes are not yet made.
|
// we are changing into but the changes are not yet made.
|
||||||
@ -154,9 +157,11 @@ function createCSSClassToggler(elem, class_list, callback_a, callback_b){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: the callbacks are passed the same this as the calling
|
||||||
|
// function, this will enable them to act as metods correctly
|
||||||
// pre callback...
|
// pre callback...
|
||||||
if(callback_pre != null){
|
if(callback_pre != null){
|
||||||
if(callback_pre(action) === false){
|
if(callback_pre.call(this, action) === false){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,7 +172,7 @@ function createCSSClassToggler(elem, class_list, callback_a, callback_b){
|
|||||||
}
|
}
|
||||||
// post callback...
|
// post callback...
|
||||||
if(callback_post != null){
|
if(callback_post != null){
|
||||||
callback_post(action)
|
callback_post.call(this, action)
|
||||||
}
|
}
|
||||||
|
|
||||||
return action
|
return action
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user