buttons: handle widget-targeted dragend instead of document global event (issue #48)

This commit is contained in:
jean-emmanuel 2017-02-15 16:38:57 +01:00
parent b1c25de869
commit d09021ebe3
2 changed files with 5 additions and 7 deletions

View file

@ -1,5 +1,4 @@
var _widgets_base = require('../common/_widgets_base'),
$document = $(document),
osc = require('../../osc')
module.exports = class Push extends _widgets_base {
@ -68,9 +67,9 @@ module.exports = class Push extends _widgets_base {
fakeclick(){
if (!this.active) this.setValuePrivate(this.widgetData.on,{send:true,sync:true})
$document.on('dragend.push',()=>{
this.widget.on('dragend.push',()=>{
this.setValuePrivate(this.widgetData.off,{send:true,sync:true})
$document.off('dragend.push')
this.widget.off('dragend.push')
this.widget.on('draginit.push',()=>{
this.widget.off('draginit.push')
this.fakeclick()

View file

@ -1,5 +1,4 @@
var _widgets_base = require('../common/_widgets_base'),
$document = $(document)
var _widgets_base = require('../common/_widgets_base')
module.exports = class Toggle extends _widgets_base {
@ -59,8 +58,8 @@ module.exports = class Toggle extends _widgets_base {
var newVal = this.widget.state?this.widgetData.off:this.widgetData.on
this.setValue(newVal,{sync:true,send:true})
$document.on('dragend.toggle',()=>{
$document.off('dragend.toggle')
this.widget.on('dragend.toggle',()=>{
this.widget.off('dragend.toggle')
this.widget.on('draginit.toggle',()=>{
this.widget.off('draginit.toggle')
this.fakeclick()